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] extends: [eslint:recommended, google, plugin:jasmine/recommended]
parserOptions:
ecmaVersion: 2017
plugins: plugins:
- jasmine - jasmine
env: env:

5
.gitignore vendored
View File

@ -1,8 +1,3 @@
.DS_Store
node_modules node_modules
build build
npm-debug.log 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 . /app
COPY ../loopback /loopback
COPY loopback /loopback
WORKDIR /app WORKDIR /app
RUN npm install RUN npm install
RUN npm -g install pm2 RUN npm -g install pm2
CMD ["pm2-docker", "./server/server.js"] 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' version: '2'
services: services:
auth: nginx:
environment: container_name: '${BRANCH_NAME}-nginx'
- NODE_ENV=${NODE_ENV} image: 'nginx:${TAG}'
container_name: "${BRANCH_NAME}-auth" privileged: true
image: "auth:${TAG}" build:
build: context: ./services/nginx
context: ./services ports:
dockerfile: /auth/Dockerfile - '80:80'
ports: mem_limit: 200m
- "3000:3000" links:
- 'auth:${BRANCH_NAME}-auth'
salix: - 'client:${BRANCH_NAME}-client'
environment: - 'item:${BRANCH_NAME}-item'
- NODE_ENV=${NODE_ENV} - 'mailer:${BRANCH_NAME}-mailer'
container_name: "${BRANCH_NAME}-salix" - 'print:${BRANCH_NAME}-print'
image: "salix:${TAG}" - 'production:${BRANCH_NAME}-production'
build: - 'route:${BRANCH_NAME}-route'
context: ./services - 'salix:${BRANCH_NAME}-salix'
dockerfile: /salix/Dockerfile auth:
ports: environment:
- "3001:3001" - 'NODE_ENV=${NODE_ENV}'
container_name: '${BRANCH_NAME}-auth'
client: image: 'auth:${TAG}'
environment: build:
- NODE_ENV=${NODE_ENV} context: ./services/auth
container_name: "${BRANCH_NAME}-client" dockerfile: /home/juan/Projects/salix/Dockerfile
image: "client:${TAG}" ports:
build: - '3000:3001'
context: ./services client:
dockerfile: /client/Dockerfile environment:
ports: - 'NODE_ENV=${NODE_ENV}'
- "3002:3002" container_name: '${BRANCH_NAME}-client'
image: 'client:${TAG}'
mailer: build:
environment: context: ./services/client
- NODE_ENV=${NODE_ENV} dockerfile: /home/juan/Projects/salix/Dockerfile
container_name: "${BRANCH_NAME}-mailer" ports:
image: "mailer:${TAG}" - '3000:3002'
build: item:
context: ./services/mailer environment:
ports: - 'NODE_ENV=${NODE_ENV}'
- "3003:3003" container_name: '${BRANCH_NAME}-item'
image: 'item:${TAG}'
production: build:
environment: context: ./services/item
- NODE_ENV=${NODE_ENV} dockerfile: /home/juan/Projects/salix/Dockerfile
container_name: "${BRANCH_NAME}-production" ports:
image: "production:${TAG}" - '3000:3003'
build: mailer:
context: ./services environment:
dockerfile: /production/Dockerfile - 'NODE_ENV=${NODE_ENV}'
ports: container_name: '${BRANCH_NAME}-mailer'
- "3004:3004" image: 'mailer:${TAG}'
build:
route: context: ./services/mailer
environment: dockerfile: /home/juan/Projects/salix/Dockerfile
- NODE_ENV=${NODE_ENV} ports:
container_name: "${BRANCH_NAME}-route" - '3000:3004'
image: "route:${TAG}" print:
build: environment:
context: ./services - 'NODE_ENV=${NODE_ENV}'
dockerfile: /route/Dockerfile container_name: '${BRANCH_NAME}-print'
ports: image: 'print:${TAG}'
- "3005:3005" build:
print: context: ./services/print
environment: dockerfile: /home/juan/Projects/salix/Dockerfile
- NODE_ENV=${NODE_ENV} ports:
container_name: "${BRANCH_NAME}-print" - '3000:3005'
image: "print:${TAG}" production:
build: environment:
context: ./services - 'NODE_ENV=${NODE_ENV}'
dockerfile: /print/Dockerfile container_name: '${BRANCH_NAME}-production'
ports: image: 'production:${TAG}'
- "3006:3006" build:
item: context: ./services/production
environment: dockerfile: /home/juan/Projects/salix/Dockerfile
- NODE_ENV=${NODE_ENV} ports:
container_name: "${BRANCH_NAME}-item" - '3000:3006'
image: "item:${TAG}" route:
build: environment:
context: ./services - 'NODE_ENV=${NODE_ENV}'
dockerfile: /item/Dockerfile container_name: '${BRANCH_NAME}-route'
ports: image: 'route:${TAG}'
- "3007:3007" build:
nginx: context: ./services/route
container_name: "${BRANCH_NAME}-nginx" dockerfile: /home/juan/Projects/salix/Dockerfile
image: "nginx:${TAG}" ports:
privileged: true - '3000:3007'
build: salix:
context: ./services/nginx environment:
ports: - 'NODE_ENV=${NODE_ENV}'
- "80:80" container_name: '${BRANCH_NAME}-salix'
mem_limit: 200m image: 'salix:${TAG}'
links: build:
- "auth:${BRANCH_NAME}-auth" context: ./services/salix
- "salix:${BRANCH_NAME}-salix" dockerfile: /home/juan/Projects/salix/Dockerfile
- "client:${BRANCH_NAME}-client" ports:
- "mailer:${BRANCH_NAME}-mailer" - '3000:3000'
- "production:${BRANCH_NAME}-production"
- "route:${BRANCH_NAME}-route"
- "print:${BRANCH_NAME}-print"

View File

@ -1,30 +1,32 @@
var gulp = require('gulp'); const gulp = require('gulp');
var jasmine = require('gulp-jasmine'); const gutil = require('gulp-util');
var gutil = require('gulp-util'); const wrap = require('gulp-wrap');
var wrap = require('gulp-wrap'); const concat = require('gulp-concat');
var concat = require('gulp-concat'); const merge = require('merge-stream');
var merge = require('merge-stream'); const print = require('gulp-print');
var extend = require('gulp-extend'); const runSequence = require('run-sequence');
var install = require('gulp-install'); const fs = require('fs-extra');
var print = require('gulp-print'); const webpack = require('webpack');
var runSequence = require('run-sequence'); const WebpackDevServer = require('webpack-dev-server');
var del = require('del'); const exec = require('child_process').exec;
var fs = require('fs'); const path = require('path');
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var exec = require('child_process').exec;
var path = require('path');
// Configuration // Configuration
var srcDir = './client'; const defaultService = 'salix';
var buildDir = './services/nginx/static'; const defaultPort = 3000;
var langs = ['es', 'en']; const devServerPort = 8081;
var modules = require('./client/modules.json'); const langs = ['es', 'en'];
var webpackConfig = require('./webpack.config.js'); 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', () => { gulp.task('default', () => {
return gulp.start('services', 'client'); return gulp.start('services', 'client');
@ -48,15 +50,14 @@ gulp.task('services', callback => {
}); });
}); });
gulp.task('services-run', ['nginx'], () => { gulp.task('services-run', async () => {
const servicesPath = './services/'; const services = await getServices();
const services = fs.readdirSync(servicesPath);
services.splice(services.indexOf('loopback'), 1); for (let service of services)
return services.forEach(service => { require(service.index).start(service.port);
const serviceJs = servicesPath.concat(service, '/server/server.js');
if (fs.existsSync(serviceJs)) await renderNginxConf(services, 'development');
require(serviceJs).start(); return gulp.start('nginx');
});
}); });
gulp.task('e2e', ['docker-wait'], () => { gulp.task('e2e', ['docker-wait'], () => {
@ -64,21 +65,23 @@ gulp.task('e2e', ['docker-wait'], () => {
}); });
gulp.task('e2e-run', () => { gulp.task('e2e-run', () => {
const jasmine = require('gulp-jasmine');
gulp.src('./e2e_tests.js') gulp.src('./e2e_tests.js')
.pipe(jasmine({reporter: 'none'})); .pipe(jasmine({reporter: 'none'}));
}); });
gulp.task('clean', () => { gulp.task('clean', () => {
const del = require('del');
return del([`${buildDir}/*`, `!${buildDir}/templates`, `!${buildDir}/images`], {force: true}); return del([`${buildDir}/*`, `!${buildDir}/templates`, `!${buildDir}/images`], {force: true});
}); });
gulp.task('install', () => { gulp.task('install', () => {
const servicesPath = './services/'; const install = require('gulp-install');
const jsonFile = []; const jsonFile = [];
const services = fs.readdirSync(servicesPath); const services = fs.readdirSync(servicesDir);
services.push('..'); services.push('..');
services.forEach(service => { services.forEach(service => {
jsonFile.push(servicesPath.concat(service, '/package.json')); jsonFile.push(`${servicesDir}/${service}/package.json`);
}); });
return gulp.src(jsonFile) return gulp.src(jsonFile)
.pipe(print(filepath => { .pipe(print(filepath => {
@ -89,27 +92,102 @@ gulp.task('install', () => {
})); }));
}); });
// Deployment
gulp.task('build', ['clean'], () => { 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 // Nginx
gulp.task('nginx', callback => { gulp.task('nginx', callback => {
let isWindows = /^win/.test(process.platform); let isWindows = /^win/.test(process.platform);
let command = isWindows ? 'start.cmd' : 'start.sh'; let command = isWindows ? 'start.cmd' : 'start.sh';
command = path.join(`./services/nginx/${command}`); command = path.join(`${nginxDir}/${command}`);
exec(command, (err, stdout, stderr) => { exec(command, (err, stdout, stderr) => {
if (stderr) console.log(stderr); if (stderr) console.log(stderr);
callback(err); 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 // Webpack
gulp.task('webpack', function(cb) { gulp.task('webpack', function(cb) {
var configCopy = Object.create(webpackConfig); let configCopy = Object.create(webpackConfig);
var compiler = webpack(configCopy); let compiler = webpack(configCopy);
compiler.run(function(err, stats) { compiler.run(function(err, stats) {
if (err) throw new gutil.PluginError('webpack', err); if (err) throw new gutil.PluginError('webpack', err);
@ -119,14 +197,14 @@ gulp.task('webpack', function(cb) {
}); });
gulp.task('webpack-dev-server', function() { 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] 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, { new WebpackDevServer(compiler, {
publicPath: '/', publicPath: '/',
contentBase: buildDir, contentBase: buildDir,
@ -142,21 +220,22 @@ gulp.task('webpack-dev-server', function() {
chunks: false, chunks: false,
chunkModules: 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); if (err) throw new gutil.PluginError('webpack-dev-server', err);
}); });
}); });
// Locale // Locale
var localeFiles = `${srcDir}/**/locale/*.json`; let localeFiles = `${srcDir}/**/locale/*.json`;
gulp.task('locales', function() { gulp.task('locales', function() {
var streams = []; const extend = require('gulp-extend');
let streams = [];
for (var mod in modules) for (let mod in modules)
for (var lang of langs) { for (let lang of langs) {
var localeFiles = `./client/${mod}/**/locale/${lang}.json`; let localeFiles = `./client/${mod}/**/locale/${lang}.json`;
streams.push(gulp.src(localeFiles) streams.push(gulp.src(localeFiles)
.pipe(extend(`${lang}.json`)) .pipe(extend(`${lang}.json`))
.pipe(gulp.dest(`${buildDir}/locale/${mod}`))); .pipe(gulp.dest(`${buildDir}/locale/${mod}`)));
@ -167,7 +246,7 @@ gulp.task('locales', function() {
// Routes // Routes
var routeFiles = `${srcDir}/**/routes.json`; let routeFiles = `${srcDir}/**/routes.json`;
gulp.task('routes', function() { gulp.task('routes', function() {
return gulp.src(routeFiles) return gulp.src(routeFiles)

90
package-lock.json generated
View File

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

View File

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

21
services/.gitignore vendored
View File

@ -1,20 +1,3 @@
*.csv datasources.test.json
*.dat datasources.development.json
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log
db.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 packageJson = require(rootDir + '/../package.json');
let appName = packageJson.name; let appName = packageJson.name;
app.start = function() { app.start = function(port) {
return app.listen(function() { function onListen() {
app.emit('started'); app.emit('started');
let baseUrl = app.get('url').replace(/\/$/, ''); let baseUrl = app.get('url').replace(/\/$/, '');
console.log(`Web server ${appName} listening at: %s`, baseUrl); 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'); let config = require('./config.json');
@ -73,17 +76,13 @@ function vnBoot(app, rootDir, rootModule) {
`loopback/common/models`, `loopback/common/models`,
`loopback/server/models`, `loopback/server/models`,
`${__dirname}/../common/models`, `${__dirname}/../common/models`,
`${__dirname}/models`, `${rootDir}/../common/models`
`${rootDir}/../common/models`,
`${rootDir}/models`
], ],
mixinDirs: [ mixinDirs: [
`loopback/common/mixins`, `loopback/common/mixins`,
`loopback/server/mixins`, `loopback/server/mixins`,
`${__dirname}/../common/mixins`, `${__dirname}/../common/mixins`,
`${__dirname}/mixins`, `${rootDir}/../common/mixins`
`${rootDir}/../common/mixins`,
`${rootDir}/mixins`
], ],
bootDirs: [ bootDirs: [
`${__dirname}/boot`, `${__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": { "app": {
"port": 3003, "port": 3000,
"debug": false, "debug": false,
"defaultLanguage": "es", "defaultLanguage": "es",
"senderMail": "noreply@localhost", "senderMail": "noreply@localhost",

View File

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

View File

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

View File

@ -1,17 +1,13 @@
FROM nginx FROM nginx
RUN rm /etc/nginx/nginx.conf RUN rm /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/default.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 COPY static /usr/share/nginx/html
RUN apt-get update && apt-get -y install vim dnsmasq dnsutils RUN apt-get update && apt-get -y install vim dnsmasq dnsutils
RUN rm -fr /usr/share/dns RUN rm -fr /usr/share/dns
RUN echo listen-address=127.0.0.1 > /etc/dnsmasq.d/dnsmasq.conf RUN echo listen-address=127.0.0.1 > /etc/dnsmasq.d/dnsmasq.conf
CMD service dnsmasq restart && nginx -g "daemon off;" 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; server_name localhost;
autoindex off; autoindex off;
{{#services}}
location ~ ^/{{name}}(?:/(.*))?$ {
proxy_pass http://127.0.0.1:{{port}}/$1$is_args$args;
}
{{/services}}
location ~ ^/static(?:/(.*))?$ { 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 ~ ^(?:/(.*))?$ { 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 { types {
text/html html; text/html html;
application/json json; application/json json;
application/javascript js; application/javascript js;
text/css css scss; text/css css scss;
text/xml xml; text/xml xml;
image/x-icon ico; 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 currentDir=%cd%
set nginxPrefix=%currentDir%\services\nginx set nginxPrefix=%currentDir%\services\nginx
set nginxConf=%nginxPrefix%\conf-dev.conf set nginxConf=%nginxPrefix%\temp\nginx.development.conf
if "%1"=="" goto caseStart if "%1"=="" goto caseStart
if "%1"=="start" goto caseStart if "%1"=="start" goto caseStart

View File

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

View File

@ -1,14 +1,14 @@
<vn-vertical> <vn-vertical>
<vn-horizontal class="list list-header"> <vn-horizontal class="list list-header">
<vn-one margin-medium-right>Población</vn-one> <vn-one margin-medium-right>Población</vn-one>
<vn-one margin-medium-right>Provincia</vn-one> <vn-one margin-medium-right>Provincia</vn-one>
<vn-two margin-medium-right>ID_Cliente</vn-two> <vn-two margin-medium-right>ID_Cliente</vn-two>
<vn-two>Comercial</vn-two> <vn-two>Comercial</vn-two>
</vn-horizontal> </vn-horizontal>
<vn-horizontal class="list list-element"> <vn-horizontal class="list list-element">
<vn-one margin-medium-right>{{::ticket.city | ucwords}}</vn-one> <vn-one margin-medium-right>{{::ticket.city | ucwords}}</vn-one>
<vn-one margin-medium-right>{{::ticket.province | 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 margin-medium-right>{{::ticket.client | ucwords}}</vn-two>
<vn-two>{{::ticket.worker | ucwords}}</vn-two> <vn-two>{{::ticket.worker | ucwords}}</vn-two>
</vn-horizontal> </vn-horizontal>
</vn-vertical> </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": { "app": {
"port": 3006, "port": 3000,
"debug": false, "debug": false,
"defaultLanguage": "es" "defaultLanguage": "es"
}, },

View File

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

View File

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