diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..36314c5884bd7571b6349e68219174b1964e3c63 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +# IntelliJ IDEA +.idea +###> symfony/webpack-encore-bundle ### +/node_modules/ +/public/build/ +npm-debug.log +yarn-error.log +###< symfony/webpack-encore-bundle ### diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc211f295e473df271199152d510207f6a1b1386..7385b99f01a704c35527200015283e7bbf220300 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,21 +1,39 @@ stages: - - build + - php + - nginx + - test default: + services: + - docker:dind + image: docker:latest before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - image: docker:latest - services: - - docker:dind + +php-image-build: + stage: php + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG" -f ./docker/php-fpm/Dockerfile . + - docker cp -a $(docker create "$CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG"):/var/www/tms/. php-build + - docker push "$CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG" + artifacts: + name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" + paths: + - php-build nginx-image-build: - stage: build + stage: nginx script: - docker build --pull -t "$CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_SLUG" -f ./docker/nginx/Dockerfile . - docker push "$CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_SLUG" -php-image-build: - stage: build +test: + stage: test + variables: + # Don't clone, the software is already in the image run + GIT_STRATEGY: none + dependencies: [] script: - - docker build --pull -t "$CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG" -f ./docker/php-fpm/Dockerfile . - - docker push "$CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG" + - docker run $CI_REGISTRY_IMAGE/php-fpm:$CI_COMMIT_REF_SLUG ./vendor/bin/simple-phpunit --configuration phpunit.xml.dist + ## TODO: Define unit tests + ## TODO: Add unit tests report as job artifact diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 52b335ea643be5fa9e047961737716dde233e7b1..b842f5d73b0650bc6ccfaa49da5b402d9f73b376 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -1,4 +1,5 @@ FROM gitlab-registry.in2p3.fr/cc-in2p3-devops/openshift-origin/openshift-images/nginx:stable-alpine LABEL maintainer="CNRS/CCIN2P3 DevOps Team" -ADD tms/symfony.conf /etc/nginx/conf.d/default.conf +ADD php-build/symfony.conf /etc/nginx/conf.d/default.conf +ADD php-build/public /var/www/tms/public diff --git a/docker/php-fpm/Dockerfile b/docker/php-fpm/Dockerfile index 4265f850c8acc4a00fc0b52a2c66c065cf1c7e9c..89b5128f1089f0a7d7a80e58a503054746e4e238 100644 --- a/docker/php-fpm/Dockerfile +++ b/docker/php-fpm/Dockerfile @@ -5,14 +5,12 @@ RUN apk add --no-cache --virtual .php-build zlib-dev libpng-dev libjpeg-turbo-de && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) gd mysqli pdo pdo_mysql -ADD tms /var/www/html/ -WORKDIR /var/www/html +WORKDIR /var/www/tms +ADD tms /var/www/tms RUN apk add --no-cache --virtual .php-tools composer yarn npm \ && mv .env.template .env \ && php composer.phar install \ && yarn install --ignore-engines \ - && yarn encore dev \ + && yarn encore production \ && apk del .php-tools - -EXPOSE 3315 diff --git a/tms/symfony.conf b/tms/symfony.conf index b7a7d178d22077480b367673b7f622965497e89b..7cd6e72f62d528063aeec810bb6596b8de52cdf3 100644 --- a/tms/symfony.conf +++ b/tms/symfony.conf @@ -1,21 +1,27 @@ server { listen 8081; - server_name localhost; - index index.php index.html; - root /var/www/html/public; + root /var/www/tms/public; + index index.html index.htm index.php; + server_name _; + charset utf-8; + location = /favicon.ico { log_not_found off; access_log off; } + location = /robots.txt { log_not_found off; access_log off; } - # redirect server error pages to the static page /50x.html - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; + location / { + try_files $uri $uri/ /index.php$is_args$args; } - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 - # - location / { - fastcgi_pass php-tms:9000; - fastcgi_index index.php; - include fastcgi_params; + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php-tms:9000; + fastcgi_index index.php; + include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } + + error_page 404 /index.php; + + location ~ /\.ht { + deny all; + } } diff --git a/tms/templates/tapes/main_tapes.html.twig b/tms/templates/tapes/main_tapes.html.twig index b4495cb9762e660a1f4b7c7b93c89b55f9ab0645..05046ce2b7098edc6687b40e037877bc5e09bf34 100644 --- a/tms/templates/tapes/main_tapes.html.twig +++ b/tms/templates/tapes/main_tapes.html.twig @@ -262,7 +262,7 @@ } }) - }); + }) $('#tableTapes').on( 'processing.dt', function ( e, settings, processing ) { $('#loadertable').css( 'display', processing ? 'block' : 'none' );