From 55877223c5277a1a6f5a52e9e55d53741248dfef Mon Sep 17 00:00:00 2001 From: FORESTIER Fabien <fabien.forestier@soprasteria.com> Date: Fri, 7 Feb 2020 17:41:31 +0100 Subject: [PATCH] Remove deployment conf and related code has a dedicated project has been created --- .gitlab-ci.yml | 48 ++++++++-------------------------------------- README.md | 22 +++++++++++++-------- docker-compose.yml | 2 +- template.env | 7 ++++--- 4 files changed, 27 insertions(+), 52 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0240e8..8bb5b25 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,6 @@ stages: - sonar-analysis - build - - deploy variables: JWT_LIFETIME: 604800 @@ -11,7 +10,7 @@ variables: 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` @@ -31,53 +30,22 @@ build_development: only: - development script: - - export TAG=dev - - export AUTHENTICATION_SERVICE_BIND_PORT=3002 + - export TAG=$CI_COMMIT_SHORT_SHA + - echo ${TAG} + - export AUTHENTICATION_API_BIND_PORT=3002 - 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/321/trigger/pipeline" build_release: stage: build only: - tags - # except: - # - /^(?!master).+@/ script: - export TAG=$(echo $CI_COMMIT_TAG | sed 's/v//g') - - export AUTHENTICATION_SERVICE_BIND_PORT=3002 + - echo ${TAG} + - export AUTHENTICATION_API_BIND_PORT=3002 - 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 AUTHENTICATION_SERVICE_BIND_PORT=3002 - - export LEGACY_MIDDLEWARE_URL=http://vm-refonte-data-2:9000/middleware-legacy - - export KONG_URL=http://vm-refonte-data-2:9001 - - export COOKIE_DOMAIN=data-reloaded-dev.alpha.grandlyon.com - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker-compose pull - - docker-compose --project-name service-authentication-${TAG} up -d --force-recreate - -deploy_staging: - stage: deploy - only: - - development - when: manual - script: - - export TAG=staging - - export AUTHENTICATION_SERVICE_BIND_PORT=3102 - - export LEGACY_MIDDLEWARE_URL=http://vm-refonte-data-2:9100/middleware-legacy - - export KONG_URL=http://vm-refonte-data-2:9101 - - export COOKIE_DOMAIN=data-reloaded-rec.alpha.grandlyon.com - - 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/services/authentication - - docker tag $CI_REGISTRY/$REGISTRY_PATH:dev $CI_REGISTRY/$REGISTRY_PATH:${TAG} - - docker push $CI_REGISTRY/$REGISTRY_PATH:${TAG} - - docker-compose --project-name service-authentication-${TAG} up -d --force-recreate \ No newline at end of file + - docker-compose push \ No newline at end of file diff --git a/README.md b/README.md index c7900fe..aa6ce84 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,13 @@ +# Authentication service + ## Installation +This service has been developed with the [NestJS](https://nestjs.com/) framework. It requires [Node.js](https://nodejs.org/en/) in order to run. + +Once Node.js installed on your computer, you will need to install the project's dependencies. Go to the root of the project and run the following command. + ```bash -$ npm install +npm install ``` ## Environment variables @@ -13,7 +19,7 @@ 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, but you can override any of those by exporting manually the variable before launching the service. +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 @@ -21,26 +27,26 @@ You will need to provide a healthy connection to a database in order for the ser ```bash # development -$ npm run start +npm run start # watch mode -$ npm run start:dev +npm run start:dev # production mode -$ npm run start:prod +npm run start:prod ``` ## Running the app with docker ```bash # build -$ docker-compose build +docker-compose build # deploy -$ docker-compose up [-d] +docker-compose up [-d] # build and deploy -$ docker-compose up --build [-d] +docker-compose up --build [-d] ``` <!-- ## Test diff --git a/docker-compose.yml b/docker-compose.yml index 3cdb1cb..9dac5f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: . image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/services/authentication:${TAG} ports: - - ${AUTHENTICATION_SERVICE_BIND_PORT}:3000 + - ${AUTHENTICATION_API_BIND_PORT}:3000 environment: # - POST_LOGOUT_REDIRECT_URI=${POST_LOGOUT_REDIRECT_URI} # - REDIRECT_URI=${REDIRECT_URI} diff --git a/template.env b/template.env index c845acc..0b2e082 100644 --- a/template.env +++ b/template.env @@ -1,7 +1,8 @@ TAG=<version number> -AUTHENTICATION_SERVICE_BIND_PORT=<service port> +AUTHENTICATION_API_BIND_PORT=<service port> LEGACY_MIDDLEWARE_URL=<url of the legacy auth middleware> +KONG_URL=<api gateway url> +JWT_LIFETIME=<life time of the JWT> COOKIE_DOMAIN=<domain for which the cookie will be set> ACCESS_TOKEN_COOKIE_KEY=<cookie key where the access token will be stored> -KONG_URL=<api gateway url> -JWT_LIFETIME=<life time of the JWT> \ No newline at end of file + -- GitLab