Lavels to compose services

This commit is contained in:
Juan 2018-06-12 11:24:43 +02:00
parent bfb89690d6
commit f24395f074
5 changed files with 23 additions and 25 deletions

View File

@ -1,5 +0,0 @@
FROM vn-loopback:latest
COPY . /app
WORKDIR /app
CMD ["pm2-docker", "./server/server.js"]

View File

@ -1,12 +1,10 @@
version: '2'
services:
nginx:
container_name: "${BRANCH_NAME}-nginx"
image: "nginx:${BUILD_NUMBER}"
privileged: true
build:
context: ./services/nginx
ports:
- "80:80"
mem_limit: 200m
mem_limit: 200m,
links: []

View File

@ -163,35 +163,44 @@ gulp.task('docker-compose', async () => {
for (let service of services) {
let dockerFile = `Dockerfile`;
let containerName = `${namePrefix}${service.name}`;
let localDockerFile = `${__dirname}/services/${service.name}/Dockerfile`;
if (await fs.exists(localDockerFile))
dockerFile = localDockerFile;
composeYml.services[service.name] = {
container_name: containerName,
image: `${service.name}:${imageTag}`,
volumes: ['/config:/config'],
build: {
context: `./services`,
dockerfile: dockerFile
},
ports: [`${service.port}:${defaultPort}`],
environment: [
'NODE_ENV=${NODE_ENV}',
'salixHost=${salixHost}',
'salixPort=${salixPort}',
'salixUser=${salixUser}',
'salixPassword=${salixPassword}'
]
environment: {
NODE_ENV: '${NODE_ENV}',
salixHost: '${salixHost}',
salixPort: '${salixPort}',
salixUser: '${salixUser}',
salixPassword: '${salixPassword}'
}
};
composeYml.services.nginx.links.push(
`${service.name}:${containerName}`
`${service.name}:${namePrefix}${service.name}`
);
}
for (let serviceName in composeYml.services) {
let service = composeYml.services[serviceName];
let data = {
container_name: `${namePrefix}${serviceName}`,
image: `${serviceName}:${imageTag}`,
labels: {
'salix.tag': imageTag
}
};
Object.assign(service, data);
}
let ymlString = yaml.safeDump(composeYml);
await fs.writeFile('./docker-compose.yml', ymlString);
});

3
services/.gitignore vendored
View File

@ -1,3 +1,2 @@
datasources.test.json
datasources.development.json
datasources.*.json
db.json

View File

@ -1,3 +0,0 @@
{
"generator-loopback": {}
}