Merge branch 'test' into dev

This commit is contained in:
Joan Sanchez 2019-01-15 09:17:31 +01:00
commit d7d3c6a98d
2 changed files with 25 additions and 21 deletions

View File

@ -24,8 +24,8 @@ services:
image: registry.verdnatura.es/salix-mailer:${TAG} image: registry.verdnatura.es/salix-mailer:${TAG}
restart: unless-stopped restart: unless-stopped
build: build:
dockerfile: services/mailer/Dockerfile context: services/mailer
environment: environment:
- NODE_ENV - NODE_ENV
volumes: volumes:
- /config/vn-mailer - /containers/vn-mailer:/etc/vn-mailer

View File

@ -1,30 +1,34 @@
require('require-yaml'); require('require-yaml');
const fs = require('fs-extra'); const fs = require('fs-extra');
const package = require('../package.json'); const packageJson = require('../package.json');
let configPath = `/config/${package.name}`; let configPath = `/etc/${packageJson.name}`;
let nginxConfigPath = '/config/nginx';
let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development'; let env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
if (env === 'development') { let config = require('./config/datasources.json');
configPath = `${__dirname}/config`; let configFiles = [
nginxConfigPath = '../../nginx'; `${configPath}/datasources.json`,
`${configPath}/datasources.${env}.json`
];
for (let configFile of configFiles) {
if (fs.existsSync(configFile))
Object.assign(config, require(configFile));
} }
let config = require(`${configPath}/datasources.json`); let proxyConf = {};
let configEnvFile = `${configPath}/datasources.${env}.json`; let proxyFiles = [
'../../nginx/config.yml',
`${configPath}/config.yml`,
`${configPath}/config.${env}.yml`
];
if (fs.existsSync(configEnvFile)) for (let proxyFile of proxyFiles) {
Object.assign(config, require(configEnvFile)); if (fs.existsSync(proxyFile))
Object.assign(proxyConf, require(proxyFile));
let proxyConf = require(`${nginxConfigPath}/config.yml`); }
let proxyEnvFile = `${nginxConfigPath}/config.${env}.yml`;
if (fs.existsSync(proxyEnvFile))
Object.assign(proxyConf, require(proxyEnvFile));
config.proxy = proxyConf; config.proxy = proxyConf;
config.package = package; config.package = packageJson;
config.env = env; config.env = env;
module.exports = config; module.exports = config;