From c892c88abf174ac6488daae48e728f53192faa08 Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Wed, 22 May 2024 10:46:29 +0200 Subject: [PATCH] ci(openshift): move host config to env var --- .env.template | 1 + docker-compose.yml | 1 + src/configuration/config.dev.ts | 2 +- src/configuration/config.prod.ts | 2 +- src/configuration/config.rec.ts | 2 +- src/configuration/config.ts | 2 +- src/configuration/configuration.service.spec.ts | 4 ++-- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.env.template b/.env.template index b729b3214..619a6dc3b 100644 --- a/.env.template +++ b/.env.template @@ -1,6 +1,7 @@ # Env TAG=<version number> NODE_ENV=<dev or production> +APP_HOST=<localhost or host> # Configuration SERVICE_API_BIND_PORT=<service port> JWT_SECRET=<the secret used to sign jwt token> diff --git a/docker-compose.yml b/docker-compose.yml index 82319d9bc..78c15b718 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,6 +30,7 @@ services: MC_API_KEY: ${MC_API_KEY} MC_SERVER: ${MC_SERVER} MC_LIST_ID: ${MC_LIST_ID} + APP_HOST: ${APP_HOST} restart: unless-stopped networks: - backend diff --git a/src/configuration/config.dev.ts b/src/configuration/config.dev.ts index 8ad7cf0d1..47cda9c84 100644 --- a/src/configuration/config.dev.ts +++ b/src/configuration/config.dev.ts @@ -1,7 +1,7 @@ export const configDev = { url: process.env.MAIL_URL, token: process.env.MAIL_TOKEN, - host: 'resin-dev.grandlyon.com', + host: process.env.APP_HOST, protocol: 'https', port: '443', from: 'noreplyinclusionnumerique@grandlyon.com', diff --git a/src/configuration/config.prod.ts b/src/configuration/config.prod.ts index 284f81752..762b36a4e 100644 --- a/src/configuration/config.prod.ts +++ b/src/configuration/config.prod.ts @@ -1,7 +1,7 @@ export const configProd = { url: process.env.MAIL_URL, token: process.env.MAIL_TOKEN, - host: 'resin.grandlyon.com', + host: process.env.APP_HOST, protocol: 'https', port: '443', from: 'noreplyinclusionnumerique@grandlyon.com', diff --git a/src/configuration/config.rec.ts b/src/configuration/config.rec.ts index 0255a2074..e3d7990c1 100644 --- a/src/configuration/config.rec.ts +++ b/src/configuration/config.rec.ts @@ -1,7 +1,7 @@ export const configRec = { url: process.env.MAIL_URL, token: process.env.MAIL_TOKEN, - host: 'resin-rec.grandlyon.com', + host: process.env.APP_HOST, protocol: 'https', port: '443', from: 'noreplyinclusionnumerique@grandlyon.com', diff --git a/src/configuration/config.ts b/src/configuration/config.ts index a0183191d..babc27f9e 100644 --- a/src/configuration/config.ts +++ b/src/configuration/config.ts @@ -1,7 +1,7 @@ export const config = { url: process.env.MAIL_URL, token: process.env.MAIL_TOKEN, - host: 'localhost', + host: process.env.APP_HOST || 'localhost', protocol: 'http', port: '4200', from: 'noreplyinclusionnumerique@grandlyon.com', diff --git a/src/configuration/configuration.service.spec.ts b/src/configuration/configuration.service.spec.ts index c194af9ce..a198aee01 100644 --- a/src/configuration/configuration.service.spec.ts +++ b/src/configuration/configuration.service.spec.ts @@ -33,7 +33,7 @@ describe('ConfigurationService', () => { it('should init with dev conf', () => { process.env.NODE_ENV = 'dev'; - expect(configurationService.config.host).toBe('resin-dev.grandlyon.com'); + expect(configurationService.config.from_name).toBe('[DEV] Réseau des acteurs de la médiation numérique'); }); }); @@ -55,7 +55,7 @@ describe('ConfigurationService', () => { it('should init with prod conf', () => { process.env.NODE_ENV = 'production'; - expect(configurationService.config.host).toBe('resin.grandlyon.com'); + expect(configurationService.config.from_name).toBe('Réseau des acteurs de la médiation numérique'); }); }); -- GitLab