From 5c5d6e844cf4c3fce697860ff71ee7dca6c41be4 Mon Sep 17 00:00:00 2001 From: FORESTIER Fabien <fabien.forestier@soprasteria.com> Date: Wed, 12 Feb 2020 11:02:24 +0100 Subject: [PATCH] Remove deployment job from the CI as a dedicated project has been created --- .gitlab-ci.yml | 46 ++++------------------------------------------ README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 18 +++++++++--------- template.env | 11 +++++++++-- 4 files changed, 64 insertions(+), 53 deletions(-) create mode 100644 README.md diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2895201..63bbe7b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,14 @@ stages: - sonar-analysis - build - - deploy variables: - PROXY_HOST_TARGET: https://download.data.grandlyon.com SONAR_URL: https://sonarqube.forge.grandlyon.com sonarqube: stage: sonar-analysis only: - - development + - 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` @@ -30,11 +28,12 @@ build_development: only: - development script: - - export TAG=dev + - export TAG=$CI_COMMIT_SHORT_SHA - export PROXY_MVT_BIND_PORT=9002 - docker-compose build - 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/336/trigger/pipeline" build_release: stage: build @@ -45,41 +44,4 @@ build_release: - export PROXY_MVT_BIND_PORT=9002 - docker-compose build - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker-compose push - -deploy_development: - stage: deploy - only: - - development - script: - - export TAG=dev - - export PROXY_MVT_BIND_PORT=9003 - - export ELASTICSEARCH_URL=https://data-reloaded-dev.alpha.grandlyon.com/api/es-consumer-aware - - export TECHNICAL_ACCOUNT_USERNAME=$TECHNICAL_ACCOUNT_USERNAME - - export TECHNICAL_ACCOUNT_PASSWORD=$TECHNICAL_ACCOUNT_PASSWORD - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker-compose pull - - docker-compose --project-name proxy-map-services-${TAG} up -d --force-recreate - environment: - name: development - -deploy_staging: - stage: deploy - only: - - development - when: manual - script: - - export TAG=staging - - export PROXY_MVT_BIND_PORT=9103 - - export ELASTICSEARCH_URL=https://data-reloaded-rec.alpha.grandlyon.com/api/es-consumer-aware - - export TECHNICAL_ACCOUNT_USERNAME=$TECHNICAL_ACCOUNT_USERNAME - - export TECHNICAL_ACCOUNT_PASSWORD=$TECHNICAL_ACCOUNT_PASSWORD - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - TAG=dev docker-compose pull - - export REGISTRY_PATH=web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/proxies/web-mapping-services - - docker tag $CI_REGISTRY/$REGISTRY_PATH:dev $CI_REGISTRY/$REGISTRY_PATH:${TAG} - - docker push $CI_REGISTRY/$REGISTRY_PATH:${TAG} - - docker-compose --project-name proxy-map-services-${TAG} up -d --force-recreate - environment: - name: staging - + - docker-compose push \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9503003 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Web mapping services proxy + +## Installation + +This proxy has been developed with [Node.js](https://nodejs.org/en/) and the [http-proxy](https://www.npmjs.com/package/http-proxy) node module. + +You will need to install Node.js on your computer. Then you will need to install the project's dependencies. Go to the root of the project and run the following command. + +```bash +npm install +``` + +## Environment variables + +In order to run the code, some environment variables are needed. They are specified in the `template.env` file at the root of the project. + +For a local deployment: + +1. `cp template.env .env` +2. Edit .env according to the chosen configuration + +The values will be read from the file by default when running with docker. If you run the service outside of docker you can export those variables. + +## Running the app without docker + +```bash +# development +npm run start +``` + +## Running the app with docker + +```bash +# build +docker-compose build + +# deploy +docker-compose up [-d] + +# build and deploy +docker-compose up --build [-d] +``` diff --git a/docker-compose.yml b/docker-compose.yml index 1dfabb4..d897ecb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,11 +8,11 @@ services: ports: - ${PROXY_MVT_BIND_PORT}:9000 environment: - - REDIS_SENTINEL_HOST=redis-sentinel-1 - - REDIS_SENTINEL_PORT=26379 - - REDIS_GROUP_NAME=mymaster - - REDIS_AUTHORIZED_TTL=86400 - - REDIS_UNAUTHORIZED_TTL=60 + - REDIS_SENTINEL_HOST=${REDIS_SENTINEL_HOST} + - REDIS_SENTINEL_PORT=${REDIS_SENTINEL_PORT} + - REDIS_GROUP_NAME=${REDIS_MASTER_SET} + - REDIS_AUTHORIZED_TTL=${REDIS_AUTHORIZED_TTL} + - REDIS_UNAUTHORIZED_TTL=${REDIS_UNAUTHORIZED_TTL} - ELASTICSEARCH_URL=${ELASTICSEARCH_URL} - TECHNICAL_ACCOUNT_USERNAME=${TECHNICAL_ACCOUNT_USERNAME} - TECHNICAL_ACCOUNT_PASSWORD=${TECHNICAL_ACCOUNT_PASSWORD} @@ -24,7 +24,7 @@ services: redis-master: image: 'bitnami/redis:latest' environment: - - ALLOW_EMPTY_PASSWORD=yes + - ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD} volumes: - redis-master:/bitnami/redis/data restart: unless-stopped @@ -32,8 +32,8 @@ services: redis-sentinel-1: image: 'bitnami/redis-sentinel:latest' environment: - - REDIS_MASTER_HOST=redis-master - - REDIS_MASTER_SET=mymaster + - REDIS_MASTER_HOST=${REDIS_MASTER_HOST} + - REDIS_MASTER_SET=${REDIS_MASTER_SET} volumes: - redis-sentinel-1:/bitnami/redis/data restart: unless-stopped @@ -42,7 +42,7 @@ services: image: 'bitnami/redis:latest' command: redis-server --bind 0.0.0.0 --slaveof redis-master 6379 --dir /bitnami/redis/data environment: - - ALLOW_EMPTY_PASSWORD=yes + - ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD} volumes: - redis-slave-1:/bitnami/redis/data restart: unless-stopped diff --git a/template.env b/template.env index 680cec0..5dfdbbd 100644 --- a/template.env +++ b/template.env @@ -1,6 +1,13 @@ TAG=<tag of the image to be used> -PROXY_MVT_PORT_BIND_PORT=<proxy port> +PROXY_MAP_SERVICES_BIND_PORT=<proxy port> TECHNICAL_ACCOUNT_PASSWORD=<username of the technical account which has access to all wms and mvt> TECHNICAL_ACCOUNT_USERNAME=<password of the technical account> ELASTICSEARCH_URL=<url of the elasticsearch instance> -PROXY_HOST_TARGET=<url of the map services> \ No newline at end of file +PROXY_HOST_TARGET=<url of the map services> +REDIS_MASTER_HOST=<host of the redis master> +REDIS_SENTINEL_PORT=<port of the redis sentinel> +REDIS_SENTINEL_HOST=<host of the redis sentinel> +REDIS_MASTER_SET=<name of the group of the different sentinels> +REDIS_AUTHORIZED_TTL=<time in seconds for which the key/value will be stored in redis when the user has access to the layer> +REDIS_UNAUTHORIZED_TTL=<Time in seconds for which the key/value pair will be stored in redis when the user doesn't have access to the layer> +ALLOW_EMPTY_PASSWORD=<whether empty password is allowed or not for redis, ex: 'yes'> \ No newline at end of file -- GitLab