Commit 0c5a956b authored by Nicolas CASTEJON's avatar Nicolas CASTEJON
Browse files

Merge branch 'development' into 'master'

Update the license

See merge request !11
parents 39490d2c 3fd47b5d
Pipeline #4063 passed with stage
in 18 seconds
stages:
- sonar-analysis
- build
- deploy
variables:
GROUP_HEADER: x-consumer-groups
ADMIN_GROUP_NAME: admin
ACCESS_TOKEN_COOKIE_KEY: access_token
SONAR_URL: https://sonarqube.forge.grandlyon.com
POSTGRES_EXPOSED_PORT: 5432
POSTGRES_PORT: 5432
ORGANIZATIONS_API_BIND_PORT: 3000
sonarqube:
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
......@@ -14,12 +33,12 @@ build_development:
only:
- development
script:
- export TAG=dev
- export POSTGRES_PORT=5432
- export ORGANIZATIONS_SERVICE_BIND_PORT=3000
- export TAG=$CI_COMMIT_SHORT_SHA
- echo ${TAG}
- 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/330/trigger/pipeline"
build_release:
stage: build
......@@ -27,45 +46,10 @@ build_release:
- build
only:
- tags
# except:
# - /^(?!master).+@/
script:
- export TAG=$(echo $CI_COMMIT_TAG | sed 's/v//g')
- export POSTGRES_PORT=5432
- export ORGANIZATIONS_SERVICE_BIND_PORT=3000
- echo ${TAG}
- 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 POSTGRES_PORT=5432
- export ORGANIZATIONS_SERVICE_BIND_PORT=3000
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker-compose pull
- docker-compose --project-name service-organizations-${TAG} up -d --force-recreate
environment:
name: development
deploy_staging:
stage: deploy
only:
- development
when: manual
script:
- export TAG=staging
- export POSTGRES_PORT=5433
- export ORGANIZATIONS_SERVICE_BIND_PORT=3100
- 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/services/organizations:dev $CI_REGISTRY/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/services/organizations:${TAG}
- docker push $CI_REGISTRY/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/services/organizations:${TAG}
- docker-compose --project-name service-organizations-${TAG} up -d --force-recreate
environment:
name: staging
This diff is collapsed.
# Organizations 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
......@@ -54,6 +60,4 @@ $ npm run test:e2e
# test coverage
$ npm run test:cov
``` -->
``` -->
\ No newline at end of file
# Use postgres/example user/password credentials
version: '3.1'
services:
......@@ -6,14 +5,14 @@ services:
build: .
image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/services/organizations:${TAG}
ports:
- ${ORGANIZATIONS_SERVICE_BIND_PORT}:3000
- ${ORGANIZATIONS_API_BIND_PORT}:3000
environment:
POSTGRES_USER: user
POSTGRES_USER: ${POSTGRES_USERNAME}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_ADMIN_PASSWORD: ${POSTGRES_ADMIN_PASSWORD}
POSTGRES_DB: postgres
POSTGRES_HOST: database-organizations
POSTGRES_PORT: 5432
POSTGRES_DB: ${POSTGRES_DATABASE}
POSTGRES_HOST: ${POSTGRES_HOST}
POSTGRES_PORT: ${POSTGRES_PORT}
GROUP_HEADER: ${GROUP_HEADER}
ADMIN_GROUP_NAME: ${ADMIN_GROUP_NAME}
ACCESS_TOKEN_COOKIE_KEY: ${ACCESS_TOKEN_COOKIE_KEY}
......@@ -22,15 +21,15 @@ services:
database-organizations:
image: bitnami/postgresql:11
environment:
POSTGRESQL_USERNAME: user
POSTGRESQL_USERNAME: ${POSTGRES_USERNAME}
POSTGRESQL_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRESQL_DATABASE: postgres
POSTGRESQL_DATABASE: ${POSTGRES_DATABASE}
POSTGRESQL_POSTGRES_PASSWORD : ${POSTGRES_ADMIN_PASSWORD}
restart: unless-stopped
ports:
- ${POSTGRES_PORT}:5432
- ${POSTGRES_EXPOSED_PORT}:5432
volumes:
- db-data:/bitnami/postgresql
volumes:
db-data:
db-data:
\ No newline at end of file
......@@ -3,7 +3,7 @@
"version": "3.0.1",
"description": "description",
"author": "",
"license": "MIT",
"license": "GNU Affero General Public License v3.0",
"scripts": {
"format": "prettier --write \"src/**/*.ts\"",
"start": "ts-node -r tsconfig-paths/register src/main.ts",
......
TAG=<version number>
ORGANIZATIONS_SERVICE_BIND_PORT=<service port>
GROUP_HEADER=<group header set by the api gateway>
ADMIN_GROUP_NAME=<name of the admin group>
ACCESS_TOKEN_COOKIE_KEY=<cookie key where the access token will be stored>
POSTGRES_USER=<postgres user>
POSTGRES_PASSWORD=<postgres password>
POSTGRES_ADMIN_PASSWORD=<postgres superuser password>
POSTGRES_HOST=<postgres database host>
POSTGRES_PORT=<postgres database port>
POSTGRES_DB=<postgres db>
\ No newline at end of file
TAG=<version/tag of the docker image to be deployed>
ORGANIZATIONS_API_BIND_PORT=<port on which the api will be running>
POSTGRES_USERNAME=<name of the user of the postgresql database>
POSTGRES_PASSWORD=<the PostgreSQL password>
POSTGRES_ADMIN_PASSWORD=<The admin password of the postgresql db>
POSTGRES_DATABASE=<name of database>
POSTGRES_HOST=<db-master or db-slave>
POSTGRES_PORT=<port on which the database is accessible by the service>
POSTGRES_EXPOSED_PORT=<port on which the database will be exposed>
GROUP_HEADER=<ex.: x-consumer-groups>
ADMIN_GROUP_NAME=<ex.: admin>
ACCESS_TOKEN_COOKIE_KEY=<the cookie key where the authentication pieces are located>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment