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}
restart: unless-stopped
build:
dockerfile: services/mailer/Dockerfile
context: services/mailer
environment:
- NODE_ENV
volumes:
- /config/vn-mailer
- /containers/vn-mailer:/etc/vn-mailer

View File

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