diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 49221eb8e1e1f3182869d64f16044a7745c5c507..9f740fb1b6742a4dbc35d8410544c7ba7fc8b956 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,7 @@ stages: # - test + - sonar-analysis - build - - deploy - - post-deploy variables: SONAR_URL: https://sonarqube.forge.grandlyon.com @@ -14,6 +13,24 @@ variables: # script: # - docker-compose -f docker-compose-development.tests.yml build +code_analysis: + stage: sonar-analysis + only: + - master + before_script: + - export PATH=$PATH:/usr/local/bin/sonar-scanner-3.2.0.1227-linux/bin/ + - export NODE_PATH=$NODE_PATH:`npm root -g` + script: + - > + sonar-scanner + -Dsonar.projectName=${SONAR_PROJECT_KEY} + -Dsonar.projectVersion=1.0 + -Dsonar.sourceEncoding=UTF-8 + -Dsonar.projectBaseDir=. + -Dsonar.host.url=${SONAR_URL} + -Dsonar.projectKey=${SONAR_PROJECT_KEY} + -Dsonar.login=${SONAR_TOKEN} + build_development: stage: build tags: @@ -22,12 +39,13 @@ build_development: - development - refacto script: - - export TAG=dev - - export NGINX_PORT=8081 - - export CONFIG_FILE_PATH=./config/config.json - - docker-compose build --build-arg conf=dev nginx-app + - export TAG=$CI_COMMIT_SHORT_SHA + - echo ${TAG} + - export WEB_APP_BIND_PORT=8081 + - docker-compose build --build-arg conf=dev web-app - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker-compose push + - "curl -X POST -F token=$CI_JOB_TOKEN -F ref=master -F variables[TAG]=${TAG} https://forge.grandlyon.com/api/v4/projects/310/trigger/pipeline" build_release: stage: build @@ -35,69 +53,10 @@ build_release: - build only: - tags - # except: - # - /^(?!master).+@/ script: - export TAG=$(echo $CI_COMMIT_TAG | sed 's/v//g') - - export NGINX_PORT=8081 - - export CONFIG_FILE_PATH=./config/config.json - - docker-compose build --build-arg conf=prod nginx-app + - echo ${TAG} + - export WEB_APP_BIND_PORT=8081 + - docker-compose build --build-arg conf=prod web-app - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker-compose push - -deploy_development: - stage: deploy - only: - - development - - refacto - script: - - export TAG=dev - - export NGINX_PORT=8081 - - export MATOMO_SITE_ID=1 - - export MATOMO_SERVER_URL=https://matomo-intothesky.alpha.grandlyon.com - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker-compose pull - - export CONFIG_FILE_PATH=./config/config-dev.json - - docker-compose --project-name portail-data-${TAG} up -d --force-recreate - environment: - name: development - url: https://data-reloaded-dev.alpha.grandlyon.com - -deploy_staging: - stage: deploy - only: - - development - when: manual - script: - - export TAG=staging - - export NGINX_PORT=8080 - - export MATOMO_SITE_ID=3 - - export MATOMO_SERVER_URL=https://matomo-intothesky.alpha.grandlyon.com - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - TAG=dev docker-compose pull - - docker tag $CI_REGISTRY/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/custom-apps/web-app:dev $CI_REGISTRY/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/custom-apps/web-app:${TAG} - - docker push $CI_REGISTRY/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/custom-apps/web-app:${TAG} - - export CONFIG_FILE_PATH=./config/config-rec.json - - docker-compose --project-name portail-data-${TAG} up -d --force-recreate - environment: - name: staging - url: https://data-reloaded-rec.alpha.grandlyon.com - -code_analysis: - stage: post-deploy - only: - - development - before_script: - - export PATH=$PATH:/usr/local/bin/sonar-scanner-3.2.0.1227-linux/bin/ - - export NODE_PATH=$NODE_PATH:`npm root -g` - script: - - > - sonar-scanner - -Dsonar.projectName=${SONAR_PROJECT_KEY} - -Dsonar.projectVersion=1.0 - -Dsonar.sourceEncoding=UTF-8 - -Dsonar.projectBaseDir=. - -Dsonar.host.url=${SONAR_URL} - -Dsonar.projectKey=${SONAR_PROJECT_KEY} - -Dsonar.login=${SONAR_TOKEN} - diff --git a/config/config-dev.json b/config/config-dev.json deleted file mode 100644 index f1f771ccbf8a70b1d5690fdbb65e25ee5ddd6f1a..0000000000000000000000000000000000000000 --- a/config/config-dev.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "backendUrls": { - "organizations": "https://data-reloaded-dev.alpha.grandlyon.com/api/organizations", - "resources": "https://data-reloaded-dev.alpha.grandlyon.com/api/resources", - "changelog": "https://data-reloaded-dev.alpha.grandlyon.com/api/changelog", - "credits": "https://data-reloaded-dev.alpha.grandlyon.com/api/credits/credits", - "auth": "https://data-reloaded-dev.alpha.grandlyon.com/api/authentication/", - "middlewareLegacyAuth": "https://data-reloaded-dev.alpha.grandlyon.com/api/middleware-legacy/", - "email": "https://data-reloaded-dev.alpha.grandlyon.com/api/email", - "matomo": "https://data-reloaded-dev.alpha.grandlyon.com/api/analytics/pageStats", - "elasticsearch": "https://data-reloaded-dev.alpha.grandlyon.com/api/es-consumer-aware", - "catalogue": "https://data-reloaded-dev.alpha.grandlyon.com/api/catalogue", - "reuses": "https://data-reloaded-dev.alpha.grandlyon.com/api/reuses/reuses", - "wms": "https://data-reloaded-dev.alpha.grandlyon.com/api/services/wms", - "mvt": "https://data-reloaded-dev.alpha.grandlyon.com/api/services/mvt", - "geocoder": "https://download.data.grandlyon.com/geocoding/photon", - "seo": "/share" - }, - "theFunctionalitiesInterruptor": { - "credits": true, - "reuses": true, - "partners": true - } -} \ No newline at end of file diff --git a/config/config-rec.json b/config/config-rec.json deleted file mode 100644 index a8a8030de8f35dc4b4813a51bbf544e39fc5619c..0000000000000000000000000000000000000000 --- a/config/config-rec.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "backendUrls": { - "organizations": "/api/organizations", - "resources": "/api/resources", - "changelog": "/api/changelog", - "credits": "/api/credits/credits", - "auth": "/api/authentication/", - "middlewareLegacyAuth": "/api/middleware-legacy/", - "email": "/api/email", - "matomo": "/api/analytics/pageStats", - "elasticsearch": "/api/es-consumer-aware", - "catalogue": "/api/catalogue", - "reuses": "/api/reuses/reuses", - "wms": "https://data-reloaded-rec.alpha.grandlyon.com/api/services/wms", - "mvt": "https://data-reloaded-rec.alpha.grandlyon.com/api/services/mvt", - "geocoder": "https://download.data.grandlyon.com/geocoding/photon", - "seo": "/share" - }, - "theFunctionalitiesInterruptor": { - "credits": true, - "reuses": true, - "partners": true - } -} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 188a4eaebc57368cd8cf533fb43ccd26a2dfa64c..42c8c9d1391effd578ca851cb31ed420395430d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,14 @@ version: "3" services: - nginx-app: + web-app: restart: unless-stopped build: . image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/custom-apps/web-app:${TAG} volumes: - ./nginx.conf.template:/etc/nginx/nginx.conf.template - - ${CONFIG_FILE_PATH}:/usr/share/nginx/html/assets/config/config.json - - ${CONFIG_FILE_PATH}:/usr/share/nginx/html/en/assets/config/config.json ports: - - ${NGINX_PORT}:8080 + - ${WEB_APP_BIND_PORT}:8080 command: > /bin/sh -c 'sed "s#<MATOMO_SITE_ID>#$MATOMO_SITE_ID#g; s#<MATOMO_SERVER_URL>#$MATOMO_SERVER_URL#g" /etc/nginx/nginx.conf.template