Autogenerated Nginx config and docker compose

This commit is contained in:
Juan Ferrer Toribio 2018-02-03 20:14:44 +01:00
parent 7a04327655
commit 597299b1c5
37 changed files with 390 additions and 445 deletions

View File

@ -1,4 +1,6 @@
extends: [eslint:recommended, google, plugin:jasmine/recommended]
parserOptions:
ecmaVersion: 2017
plugins:
- jasmine
env:

5
.gitignore vendored
View File

@ -1,8 +1,3 @@
.DS_Store
node_modules
build
npm-debug.log
debug.log
datasources.test.json
datasources.development.json
.idea

View File

@ -1,13 +1,11 @@
FROM node:6.9.1
FROM node:8.9.4
COPY auth /app
COPY loopback /loopback
COPY . /app
COPY ../loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]

12
docker-compose.tpl.yml Normal file
View File

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

View File

@ -1,103 +1,100 @@
version: '2'
services:
auth:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-auth"
image: "auth:${TAG}"
build:
context: ./services
dockerfile: /auth/Dockerfile
ports:
- "3000:3000"
salix:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-salix"
image: "salix:${TAG}"
build:
context: ./services
dockerfile: /salix/Dockerfile
ports:
- "3001:3001"
client:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-client"
image: "client:${TAG}"
build:
context: ./services
dockerfile: /client/Dockerfile
ports:
- "3002:3002"
mailer:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-mailer"
image: "mailer:${TAG}"
build:
context: ./services/mailer
ports:
- "3003:3003"
production:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-production"
image: "production:${TAG}"
build:
context: ./services
dockerfile: /production/Dockerfile
ports:
- "3004:3004"
route:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-route"
image: "route:${TAG}"
build:
context: ./services
dockerfile: /route/Dockerfile
ports:
- "3005:3005"
print:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-print"
image: "print:${TAG}"
build:
context: ./services
dockerfile: /print/Dockerfile
ports:
- "3006:3006"
item:
environment:
- NODE_ENV=${NODE_ENV}
container_name: "${BRANCH_NAME}-item"
image: "item:${TAG}"
build:
context: ./services
dockerfile: /item/Dockerfile
ports:
- "3007:3007"
nginx:
container_name: "${BRANCH_NAME}-nginx"
image: "nginx:${TAG}"
privileged: true
build:
context: ./services/nginx
ports:
- "80:80"
mem_limit: 200m
links:
- "auth:${BRANCH_NAME}-auth"
- "salix:${BRANCH_NAME}-salix"
- "client:${BRANCH_NAME}-client"
- "mailer:${BRANCH_NAME}-mailer"
- "production:${BRANCH_NAME}-production"
- "route:${BRANCH_NAME}-route"
- "print:${BRANCH_NAME}-print"
nginx:
container_name: '${BRANCH_NAME}-nginx'
image: 'nginx:${TAG}'
privileged: true
build:
context: ./services/nginx
ports:
- '80:80'
mem_limit: 200m
links:
- 'auth:${BRANCH_NAME}-auth'
- 'client:${BRANCH_NAME}-client'
- 'item:${BRANCH_NAME}-item'
- 'mailer:${BRANCH_NAME}-mailer'
- 'print:${BRANCH_NAME}-print'
- 'production:${BRANCH_NAME}-production'
- 'route:${BRANCH_NAME}-route'
- 'salix:${BRANCH_NAME}-salix'
auth:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-auth'
image: 'auth:${TAG}'
build:
context: ./services/auth
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3001'
client:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-client'
image: 'client:${TAG}'
build:
context: ./services/client
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3002'
item:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-item'
image: 'item:${TAG}'
build:
context: ./services/item
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3003'
mailer:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-mailer'
image: 'mailer:${TAG}'
build:
context: ./services/mailer
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3004'
print:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-print'
image: 'print:${TAG}'
build:
context: ./services/print
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3005'
production:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-production'
image: 'production:${TAG}'
build:
context: ./services/production
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3006'
route:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-route'
image: 'route:${TAG}'
build:
context: ./services/route
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3007'
salix:
environment:
- 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-salix'
image: 'salix:${TAG}'
build:
context: ./services/salix
dockerfile: /home/juan/Projects/salix/Dockerfile
ports:
- '3000:3000'

View File

@ -1,30 +1,32 @@
var gulp = require('gulp');
var jasmine = require('gulp-jasmine');
var gutil = require('gulp-util');
var wrap = require('gulp-wrap');
var concat = require('gulp-concat');
var merge = require('merge-stream');
var extend = require('gulp-extend');
var install = require('gulp-install');
var print = require('gulp-print');
var runSequence = require('run-sequence');
var del = require('del');
var fs = require('fs');
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var exec = require('child_process').exec;
var path = require('path');
const gulp = require('gulp');
const gutil = require('gulp-util');
const wrap = require('gulp-wrap');
const concat = require('gulp-concat');
const merge = require('merge-stream');
const print = require('gulp-print');
const runSequence = require('run-sequence');
const fs = require('fs-extra');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const exec = require('child_process').exec;
const path = require('path');
// Configuration
var srcDir = './client';
var buildDir = './services/nginx/static';
var langs = ['es', 'en'];
const defaultService = 'salix';
const defaultPort = 3000;
const devServerPort = 8081;
var modules = require('./client/modules.json');
var webpackConfig = require('./webpack.config.js');
const langs = ['es', 'en'];
const srcDir = './client';
const servicesDir = './services';
const nginxDir = `${servicesDir}/nginx`;
const buildDir = `${nginxDir}/static`;
// Main tasks
const modules = require('./client/modules.json');
const webpackConfig = require('./webpack.config.js');
// Development
gulp.task('default', () => {
return gulp.start('services', 'client');
@ -48,15 +50,14 @@ gulp.task('services', callback => {
});
});
gulp.task('services-run', ['nginx'], () => {
const servicesPath = './services/';
const services = fs.readdirSync(servicesPath);
services.splice(services.indexOf('loopback'), 1);
return services.forEach(service => {
const serviceJs = servicesPath.concat(service, '/server/server.js');
if (fs.existsSync(serviceJs))
require(serviceJs).start();
});
gulp.task('services-run', async () => {
const services = await getServices();
for (let service of services)
require(service.index).start(service.port);
await renderNginxConf(services, 'development');
return gulp.start('nginx');
});
gulp.task('e2e', ['docker-wait'], () => {
@ -64,21 +65,23 @@ gulp.task('e2e', ['docker-wait'], () => {
});
gulp.task('e2e-run', () => {
const jasmine = require('gulp-jasmine');
gulp.src('./e2e_tests.js')
.pipe(jasmine({reporter: 'none'}));
});
gulp.task('clean', () => {
const del = require('del');
return del([`${buildDir}/*`, `!${buildDir}/templates`, `!${buildDir}/images`], {force: true});
});
gulp.task('install', () => {
const servicesPath = './services/';
const install = require('gulp-install');
const jsonFile = [];
const services = fs.readdirSync(servicesPath);
const services = fs.readdirSync(servicesDir);
services.push('..');
services.forEach(service => {
jsonFile.push(servicesPath.concat(service, '/package.json'));
jsonFile.push(`${servicesDir}/${service}/package.json`);
});
return gulp.src(jsonFile)
.pipe(print(filepath => {
@ -89,27 +92,102 @@ gulp.task('install', () => {
}));
});
// Deployment
gulp.task('build', ['clean'], () => {
return gulp.start('routes', 'locales', 'webpack');
return gulp.start('routes', 'locales', 'webpack', 'build-conf');
});
gulp.task('build-conf', async callback => {
let compose = await fs.readFile('./docker-compose.tpl.yml', 'utf8');
const yaml = require('js-yaml');
let composeYml = yaml.safeLoad(compose);
let services = await getServices();
for (let service of services) {
let dockerFile = `${__dirname}/Dockerfile`;
if (await fs.exists(`./services/${service.name}/Dockerfile`))
dockerFile = 'Dockerfile';
composeYml.services[service.name] = {
environment: ['NODE_ENV=${NODE_ENV}'],
container_name: `\${BRANCH_NAME}-${service.name}`,
image: `${service.name}:\${TAG}`,
build: {
context: `./services/${service.name}`,
dockerfile: dockerFile
},
ports: [`${defaultPort}:${service.port}`]
};
composeYml.services.nginx.links.push(
`${service.name}:\${BRANCH_NAME}-${service.name}`
);
}
let ymlString = yaml.safeDump(composeYml);
await fs.writeFile('./docker-compose.yml', ymlString);
await renderNginxConf(services, 'production');
});
// Services
async function getServices() {
let startPort = defaultPort + 1;
let servicesData = [];
const services = fs.readdirSync(servicesDir);
const exclude = ['loopback'];
for (let service of services) {
let index = `${servicesDir}/${service}/server/server.js`;
if (!await fs.exists(index) || exclude.indexOf(service) !== -1) continue;
let port = service == defaultService ? defaultPort : startPort++;
servicesData.push({
name: service,
index: index,
port: port
});
}
return servicesData;
}
// Nginx
gulp.task('nginx', callback => {
let isWindows = /^win/.test(process.platform);
let command = isWindows ? 'start.cmd' : 'start.sh';
command = path.join(`./services/nginx/${command}`);
command = path.join(`${nginxDir}/${command}`);
exec(command, (err, stdout, stderr) => {
if (stderr) console.log(stderr);
callback(err);
});
});
async function renderNginxConf(services, env) {
const mustache = require('mustache');
let params = {
services: services,
defaultService: defaultService,
defaultPort: defaultPort,
devServerPort: devServerPort
};
let template = await fs.readFile(`${nginxDir}/nginx.${env}.mst`, 'utf8');
let nginxConf = mustache.render(template, params);
await fs.writeFile(`${nginxDir}/temp/nginx.${env}.conf`, nginxConf);
}
// Webpack
gulp.task('webpack', function(cb) {
var configCopy = Object.create(webpackConfig);
var compiler = webpack(configCopy);
let configCopy = Object.create(webpackConfig);
let compiler = webpack(configCopy);
compiler.run(function(err, stats) {
if (err) throw new gutil.PluginError('webpack', err);
@ -119,14 +197,14 @@ gulp.task('webpack', function(cb) {
});
gulp.task('webpack-dev-server', function() {
var configCopy = Object.create(webpackConfig);
let configCopy = Object.create(webpackConfig);
for (var entry in configCopy.entry) {
for (let entry in configCopy.entry) {
configCopy.entry[entry]
.unshift('webpack-dev-server/client?http://127.0.0.1:8081/');
.unshift(`webpack-dev-server/client?http://127.0.0.1:${devServerPort}/`);
}
var compiler = webpack(configCopy);
let compiler = webpack(configCopy);
new WebpackDevServer(compiler, {
publicPath: '/',
contentBase: buildDir,
@ -142,21 +220,22 @@ gulp.task('webpack-dev-server', function() {
chunks: false,
chunkModules: false
}
}).listen(8081, '127.0.0.1', function(err) {
}).listen(devServerPort, '127.0.0.1', function(err) {
if (err) throw new gutil.PluginError('webpack-dev-server', err);
});
});
// Locale
var localeFiles = `${srcDir}/**/locale/*.json`;
let localeFiles = `${srcDir}/**/locale/*.json`;
gulp.task('locales', function() {
var streams = [];
const extend = require('gulp-extend');
let streams = [];
for (var mod in modules)
for (var lang of langs) {
var localeFiles = `./client/${mod}/**/locale/${lang}.json`;
for (let mod in modules)
for (let lang of langs) {
let localeFiles = `./client/${mod}/**/locale/${lang}.json`;
streams.push(gulp.src(localeFiles)
.pipe(extend(`${lang}.json`))
.pipe(gulp.dest(`${buildDir}/locale/${mod}`)));
@ -167,7 +246,7 @@ gulp.task('locales', function() {
// Routes
var routeFiles = `${srcDir}/**/routes.json`;
let routeFiles = `${srcDir}/**/routes.json`;
gulp.task('routes', function() {
return gulp.src(routeFiles)

90
package-lock.json generated
View File

@ -113,7 +113,7 @@
"angular": {
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/angular/-/angular-1.6.8.tgz",
"integrity": "sha1-W+N4pYvpGlSJ54tZxFGM2f0nP/s="
"integrity": "sha512-9WErZIOw1Cu1V5Yxdvxz/6YpND8ntdP71fdPpufPFJvZodZXqCjQBYrHqEoMZreO5i84O3D/Jw/vepoFt68Azw=="
},
"angular-cookies": {
"version": "1.6.4",
@ -1120,7 +1120,7 @@
"bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk=",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==",
"dev": true
},
"bn.js": {
@ -3893,6 +3893,30 @@
"rc": "1.2.1",
"semver": "5.3.0",
"sumchecker": "1.3.1"
},
"dependencies": {
"fs-extra": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
"dev": true,
"requires": {
"graceful-fs": "4.1.10",
"jsonfile": "2.4.0",
"klaw": "1.3.1",
"path-is-absolute": "1.0.1",
"rimraf": "2.5.4"
}
},
"jsonfile": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
"dev": true,
"requires": {
"graceful-fs": "4.1.10"
}
}
}
},
"elliptic": {
@ -4340,7 +4364,7 @@
"inquirer": "0.12.0",
"is-my-json-valid": "2.15.0",
"is-resolvable": "1.0.0",
"js-yaml": "3.8.1",
"js-yaml": "3.10.0",
"json-stable-stringify": "1.0.1",
"levn": "0.3.0",
"lodash": "4.16.6",
@ -5287,16 +5311,13 @@
}
},
"fs-extra": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz",
"integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=",
"dev": true,
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz",
"integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==",
"requires": {
"graceful-fs": "4.1.10",
"jsonfile": "2.4.0",
"klaw": "1.3.1",
"path-is-absolute": "1.0.1",
"rimraf": "2.5.4"
"jsonfile": "4.0.0",
"universalify": "0.1.1"
}
},
"fs.realpath": {
@ -6602,8 +6623,7 @@
"graceful-fs": {
"version": "4.1.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.10.tgz",
"integrity": "sha1-8tcgwiCS90Mih3XHXjYSYyUB8TE=",
"dev": true
"integrity": "sha1-8tcgwiCS90Mih3XHXjYSYyUB8TE="
},
"graceful-readlink": {
"version": "1.0.1",
@ -9047,7 +9067,7 @@
"requires": {
"bufferstreams": "1.1.0",
"gulp-util": "3.0.7",
"js-yaml": "3.8.1",
"js-yaml": "3.10.0",
"through2": "2.0.1",
"xtend": "4.0.1"
}
@ -9890,7 +9910,7 @@
"jasmine-spec-reporter": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
"integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=",
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
"dev": true,
"requires": {
"colors": "1.1.2"
@ -9929,13 +9949,21 @@
"dev": true
},
"js-yaml": {
"version": "3.8.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.8.1.tgz",
"integrity": "sha1-eCulAgC+e55ahTcAG3gE2zrQJig=",
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
"integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
"dev": true,
"requires": {
"argparse": "1.0.9",
"esprima": "3.1.2"
"esprima": "4.0.0"
},
"dependencies": {
"esprima": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
"dev": true
}
}
},
"jsbn": {
@ -9991,10 +10019,9 @@
"dev": true
},
"jsonfile": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
"dev": true,
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"requires": {
"graceful-fs": "4.1.10"
}
@ -10025,7 +10052,7 @@
"karma": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
"integrity": "sha1-hcwI6eCiLXzpzKN8ShvoJPaisa4=",
"integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==",
"dev": true,
"requires": {
"bluebird": "3.5.1",
@ -10087,7 +10114,7 @@
"karma-firefox-launcher": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz",
"integrity": "sha1-LEcDBFLwRTHrfRPU/HZpYwu5Mzk=",
"integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA==",
"dev": true
},
"karma-jasmine": {
@ -10933,6 +10960,12 @@
"duplexer2": "0.0.2"
}
},
"mustache": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-2.3.0.tgz",
"integrity": "sha1-QCj3d4sXcIpImTCm5SrDvKDaQdA=",
"dev": true
},
"mute-stream": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz",
@ -14359,6 +14392,11 @@
"crypto-random-string": "1.0.0"
}
},
"universalify": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz",
"integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc="
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@ -14594,7 +14632,7 @@
"useragent": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
"integrity": "sha1-IX+UOtVAyyEoZYqyP8lg9qiMmXI=",
"integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==",
"dev": true,
"requires": {
"lru-cache": "4.1.1",

View File

@ -16,13 +16,13 @@
"angular-translate": "^2.13.1",
"angular-translate-loader-partial": "^2.13.1",
"flatpickr": "^2.6.3",
"fs-extra": "^5.0.0",
"material-design-lite": "^1.3.0",
"mg-crud": "^1.1.2",
"oclazyload": "^0.6.3",
"validator": "^6.2.1"
},
"devDependencies": {
"nodemon": "^1.12.1",
"angular-mocks": "^1.6.6",
"babel": "^6.5.2",
"babel-core": "^6.22.1",
@ -52,6 +52,7 @@
"html-loader": "^0.4.4",
"jasmine": "^2.9.0",
"jasmine-spec-reporter": "^4.2.1",
"js-yaml": "^3.10.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.1.0",
@ -60,9 +61,11 @@
"karma-webpack": "^2.0.9",
"md5": "^2.2.1",
"merge-stream": "^1.0.1",
"mustache": "^2.3.0",
"mysql": "^2.15.0",
"nightmare": "^2.10.0",
"node-sass": "^4.7.2",
"nodemon": "^1.12.1",
"raw-loader": "*",
"run-sequence": "^2.2.0",
"sass-loader": "^4.0.2",

21
services/.gitignore vendored
View File

@ -1,20 +1,3 @@
*.csv
*.dat
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log
datasources.test.json
datasources.development.json
db.json

View File

@ -1,3 +0,0 @@
{
"port": 3000
}

View File

@ -1,15 +0,0 @@
FROM node:6.9.1
COPY client /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3002

View File

@ -1,3 +0,0 @@
{
"port": 3002
}

View File

@ -1,15 +0,0 @@
FROM node:6.9.1
COPY item /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3007

View File

@ -1,3 +0,0 @@
{
"port": 3007
}

View File

@ -39,12 +39,15 @@ function vnBoot(app, rootDir, rootModule) {
let packageJson = require(rootDir + '/../package.json');
let appName = packageJson.name;
app.start = function() {
return app.listen(function() {
app.start = function(port) {
function onListen() {
app.emit('started');
let baseUrl = app.get('url').replace(/\/$/, '');
console.log(`Web server ${appName} listening at: %s`, baseUrl);
});
}
let args = port ? [port, onListen] : [onListen];
return app.listen.apply(app, args);
};
let config = require('./config.json');
@ -73,17 +76,13 @@ function vnBoot(app, rootDir, rootModule) {
`loopback/common/models`,
`loopback/server/models`,
`${__dirname}/../common/models`,
`${__dirname}/models`,
`${rootDir}/../common/models`,
`${rootDir}/models`
`${rootDir}/../common/models`
],
mixinDirs: [
`loopback/common/mixins`,
`loopback/server/mixins`,
`${__dirname}/../common/mixins`,
`${__dirname}/mixins`,
`${rootDir}/../common/mixins`,
`${rootDir}/mixins`
`${rootDir}/../common/mixins`
],
bootDirs: [
`${__dirname}/boot`,

View File

@ -1,13 +0,0 @@
FROM node:6.9.1
COPY . /app
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3003

View File

@ -1,6 +1,6 @@
{
"app": {
"port": 3003,
"port": 3000,
"debug": false,
"defaultLanguage": "es",
"senderMail": "noreply@localhost",

View File

@ -1,5 +1,5 @@
{
"name": "mailer",
"name": "vn-mailer",
"version": "0.0.1",
"description": "Servidor de envío de correos",
"main": "server/server.js",

View File

@ -4,7 +4,6 @@ var bodyParser = require('body-parser');
var config = require('../application/config.js');
var mail = require('../application/mail.js');
var database = require('../application/database.js');
var auth = require('../application/auth.js');
var path = require('path');
// Body parser middleware
@ -16,8 +15,8 @@ app.use('/static', express.static(path.join(__dirname, '../static')));
// Load routes
app.use('/', require('../application/router.js'));
app.start = function() {
var listener = app.listen(config.app.port, function() {
app.start = function(port) {
var listener = app.listen(port ? port : config.app.port, function() {
var servicePath = 'http://' + listener.address().address + ':' + listener.address().port;
mail.init();
database.init();

View File

@ -1,17 +1,13 @@
FROM nginx
RUN rm /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/default.conf
COPY conf-prod.conf /etc/nginx/nginx.conf
COPY tmp/nginx.production.conf /etc/nginx/nginx.conf
COPY static /usr/share/nginx/html
RUN apt-get update && apt-get -y install vim dnsmasq dnsutils
RUN rm -fr /usr/share/dns
RUN echo listen-address=127.0.0.1 > /etc/dnsmasq.d/dnsmasq.conf
CMD service dnsmasq restart && nginx -g "daemon off;"

View File

@ -1,52 +0,0 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
gzip on;
default_type application/octet-stream;
resolver 127.0.0.1;
include /etc/nginx/mime.types;
server {
listen 80;
server_name localhost;
autoindex off;
root /usr/share/nginx/html;
location ~ ^/static(?:/(.*))?$ {
alias /usr/share/nginx/html/$1;
autoindex on;
}
location ~ ^/auth(?:/(.*))?$ {
proxy_pass http://auth:3000/$1$is_args$args;
}
location ~ ^/client(?:/(.*))?$ {
proxy_pass http://client:3002/$1$is_args$args;
}
location ~ ^/mailer(?:/(.*))?$ {
proxy_pass http://mailer:3003/$1$is_args$args;
}
location ~ ^/production(?:/(.*))?$ {
proxy_pass http://production:3004/$1$is_args$args;
}
location ~ ^/route(?:/(.*))?$ {
proxy_pass http://route:3005/$1$is_args$args;
}
location ~ ^/print(?:/(.*))?$ {
proxy_pass http://print:3006/$1$is_args$args;
}
location ~ ^/item(?:/(.*))?$ {
proxy_pass http://item:3007/$1$is_args$args;
}
# Este tiene que ser el último
location ~ ^(?:/(.*))?$ {
proxy_pass http://salix:3001/$1$is_args$args;
}
}
}

View File

@ -25,40 +25,24 @@ http {
server_name localhost;
autoindex off;
{{#services}}
location ~ ^/{{name}}(?:/(.*))?$ {
proxy_pass http://127.0.0.1:{{port}}/$1$is_args$args;
}
{{/services}}
location ~ ^/static(?:/(.*))?$ {
proxy_pass http://127.0.0.1:8081/$1$is_args$args;
proxy_pass http://127.0.0.1:{{devServerPort}}/$1$is_args$args;
}
location ~ ^/auth(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3000/$1$is_args$args;
}
location ~ ^/client(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3002/$1$is_args$args;
}
location ~ ^/mailer(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3003/$1$is_args$args;
}
location ~ ^/production(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3004/$1$is_args$args;
}
location ~ ^/route(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3005/$1$is_args$args;
}
location ~ ^/print(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3006/$1$is_args$args;
}
location ~ ^/item(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3007/$1$is_args$args;
}
# Este tiene que ser el último
location ~ ^(?:/(.*))?$ {
proxy_pass http://127.0.0.1:3001/$1$is_args$args;
proxy_pass http://127.0.0.1:{{defaultPort}}/$1$is_args$args;
}
}
types {
text/html html;
application/json json;
application/javascript js;
application/javascript js;
text/css css scss;
text/xml xml;
image/x-icon ico;

View File

@ -0,0 +1,36 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
gzip on;
default_type application/octet-stream;
resolver 127.0.0.1;
include /etc/nginx/mime.types;
server {
listen 80;
server_name localhost;
autoindex off;
root /usr/share/nginx/html;
{{#services}}
location ~ ^/{{name}}(?:/(.*))?$ {
proxy_pass http://{{name}}:{{port}}/$1$is_args$args;
}
{{/services}}
location ~ ^/static(?:/(.*))?$ {
alias /usr/share/nginx/html/$1;
autoindex on;
}
location ~ ^(?:/(.*))?$ {
proxy_pass http://{{defaultService}}:{{defaultPort}}/$1$is_args$args;
}
}
}

View File

@ -2,7 +2,7 @@
set currentDir=%cd%
set nginxPrefix=%currentDir%\services\nginx
set nginxConf=%nginxPrefix%\conf-dev.conf
set nginxConf=%nginxPrefix%\temp\nginx.development.conf
if "%1"=="" goto caseStart
if "%1"=="start" goto caseStart

View File

@ -2,7 +2,7 @@
nginxBin="/usr/sbin/nginx"
nginxPrefix="${PWD}/services/nginx"
nginxConf="$nginxPrefix/conf-dev.conf"
nginxConf="$nginxPrefix/temp/nginx.development.conf"
if [ ! -f $nginxBin ]; then
nginxBin="nginx"

View File

@ -1,14 +1,14 @@
<vn-vertical>
<vn-horizontal class="list list-header">
<vn-one margin-medium-right>Población</vn-one>
<vn-one margin-medium-right>Provincia</vn-one>
<vn-two margin-medium-right>ID_Cliente</vn-two>
<vn-two>Comercial</vn-two>
</vn-horizontal>
<vn-horizontal class="list list-element">
<vn-one margin-medium-right>{{::ticket.city | ucwords}}</vn-one>
<vn-one margin-medium-right>{{::ticket.province | ucwords}}</vn-one>
<vn-two margin-medium-right>{{::ticket.client | ucwords}}</vn-two>
<vn-two>{{::ticket.worker | ucwords}}</vn-two>
</vn-horizontal>
</vn-vertical>
<vn-horizontal class="list list-header">
<vn-one margin-medium-right>Población</vn-one>
<vn-one margin-medium-right>Provincia</vn-one>
<vn-two margin-medium-right>ID_Cliente</vn-two>
<vn-two>Comercial</vn-two>
</vn-horizontal>
<vn-horizontal class="list list-element">
<vn-one margin-medium-right>{{::ticket.city | ucwords}}</vn-one>
<vn-one margin-medium-right>{{::ticket.province | ucwords}}</vn-one>
<vn-two margin-medium-right>{{::ticket.client | ucwords}}</vn-two>
<vn-two>{{::ticket.worker | ucwords}}</vn-two>
</vn-horizontal>
</vn-vertical>

View File

@ -1,13 +0,0 @@
FROM node:6.9.1
COPY . /app
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3006

View File

@ -1,6 +1,6 @@
{
"app": {
"port": 3006,
"port": 3000,
"debug": false,
"defaultLanguage": "es"
},

View File

@ -1,5 +1,5 @@
{
"name": "print",
"name": "vn-print",
"version": "0.0.1",
"description": "Servidor de impresión PDF",
"main": "server/server.js",

View File

@ -3,8 +3,6 @@ var app = module.exports = express();
var bodyParser = require('body-parser');
var config = require('../application/config.js');
var database = require('../application/database.js');
var auth = require('../application/auth.js');
var path = require('path');
// Body parser middleware
app.use(bodyParser.json());
@ -13,8 +11,8 @@ app.use(bodyParser.urlencoded({extended: true}));
// Load routes
app.use('/', require('../application/router.js'));
app.start = function() {
var listener = app.listen(config.app.port, function() {
app.start = function(port) {
var listener = app.listen(port ? port : config.app.port, function() {
var servicePath = 'http://' + listener.address().address + ':' + listener.address().port;
database.init();

View File

@ -1,15 +0,0 @@
FROM node:6.9.1
COPY production /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3004

View File

@ -1,3 +0,0 @@
# My Application
The project is generated by [LoopBack](http://loopback.io).

View File

@ -1,3 +0,0 @@
{
"port": 3004
}

View File

@ -1,15 +0,0 @@
FROM node:6.9.1
COPY route /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3005

View File

@ -1,3 +0,0 @@
{
"port": 3005
}

View File

@ -1,15 +0,0 @@
FROM node:6.9.1
COPY salix /app
COPY loopback /loopback
WORKDIR /app
RUN npm install
RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"]
EXPOSE 3001

View File

@ -1,3 +0,0 @@
{
"port": 3001
}