Merge branch 'test' into dev
This commit is contained in:
commit
b6091775e5
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"salixHost": "localhost",
|
||||||
|
"salixPort": 3306,
|
||||||
|
"salixUser": "root",
|
||||||
|
"salixPassword": ""
|
||||||
|
}
|
|
@ -6,10 +6,16 @@ def branchTest = "test";
|
||||||
|
|
||||||
env.BRANCH_NAME = branchName;
|
env.BRANCH_NAME = branchName;
|
||||||
env.TAG = "${env.BUILD_NUMBER}";
|
env.TAG = "${env.BUILD_NUMBER}";
|
||||||
|
env.salixUser="${env.salixUser}";
|
||||||
|
env.salixPassword="${env.salixPassword}";
|
||||||
|
env.salixHost = "${env.productionSalixHost}";
|
||||||
|
env.salixPort = "${env.productionSalixPort}";
|
||||||
|
|
||||||
switch (branchName){
|
switch (branchName){
|
||||||
case branchTest:
|
case branchTest:
|
||||||
env.NODE_ENV = "test";
|
env.NODE_ENV = "test";
|
||||||
|
env.salixHost = "${env.testSalixHost}";
|
||||||
|
env.salixPort = "${env.testSalixPort}";
|
||||||
break;
|
break;
|
||||||
case branchProduction:
|
case branchProduction:
|
||||||
env.DOCKER_HOST = "tcp://172.16.255.29:2375";
|
env.DOCKER_HOST = "tcp://172.16.255.29:2375";
|
||||||
|
@ -20,7 +26,7 @@ switch (branchName){
|
||||||
node
|
node
|
||||||
{
|
{
|
||||||
stage ('Print environment variables'){
|
stage ('Print environment variables'){
|
||||||
echo "Branch ${branchName}, Build ${env.TAG}, NODE_ENV ${env.NODE_ENV} en docker Host ${env.DOCKER_HOST}"
|
echo "Branch ${branchName}, Build ${env.TAG}, salixHost ${env.salixHost}, NODE_ENV ${env.NODE_ENV} en docker Host ${env.DOCKER_HOST}"
|
||||||
}
|
}
|
||||||
stage ('Checkout') {
|
stage ('Checkout') {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
|
|
@ -32,7 +32,7 @@ function put(mgPut) {
|
||||||
}
|
}
|
||||||
ngModule.factory('vnPut', put);
|
ngModule.factory('vnPut', put);
|
||||||
|
|
||||||
put.$inject = ['mgPatch'];
|
patch.$inject = ['mgPatch'];
|
||||||
function patch(mgPatch) {
|
function patch(mgPatch) {
|
||||||
return Object.assign({}, mgPatch, {
|
return Object.assign({}, mgPatch, {
|
||||||
success: 'vnSuccessFactoryCreate'
|
success: 'vnSuccessFactoryCreate'
|
||||||
|
|
31
gulpfile.js
31
gulpfile.js
|
@ -1,6 +1,7 @@
|
||||||
require('require-yaml');
|
require('require-yaml');
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const runSequence = require('run-sequence');
|
const runSequence = require('run-sequence');
|
||||||
|
const gulpEnv = require('gulp-env');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const PluginError = require('plugin-error');
|
const PluginError = require('plugin-error');
|
||||||
|
@ -27,6 +28,7 @@ let devServerPort = wpConfig.devServerPort;
|
||||||
let nginxDir = `${servicesDir}/nginx`;
|
let nginxDir = `${servicesDir}/nginx`;
|
||||||
let proxyConf = require(`${nginxDir}/config.yml`);
|
let proxyConf = require(`${nginxDir}/config.yml`);
|
||||||
let proxyEnvFile = `${nginxDir}/config.${env}.yml`;
|
let proxyEnvFile = `${nginxDir}/config.${env}.yml`;
|
||||||
|
let environmentFile = './.env.json';
|
||||||
|
|
||||||
if (fs.existsSync(proxyEnvFile))
|
if (fs.existsSync(proxyEnvFile))
|
||||||
Object.assign(proxyConf, require(proxyEnvFile));
|
Object.assign(proxyConf, require(proxyEnvFile));
|
||||||
|
@ -37,18 +39,24 @@ let defaultPort = proxyConf.defaultPort;
|
||||||
// Development
|
// Development
|
||||||
|
|
||||||
gulp.task('default', () => {
|
gulp.task('default', () => {
|
||||||
return gulp.start('services', 'client');
|
return gulp.start('environment', 'services', 'client');
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('client', ['build-clean'], async () => {
|
gulp.task('client', ['build-clean'], async () => {
|
||||||
await runSequenceP(['routes', 'locales'], 'watch', 'webpack-dev-server');
|
await runSequenceP(['routes', 'locales'], 'watch', 'webpack-dev-server');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('environment', () => {
|
||||||
|
gulpEnv({
|
||||||
|
file: environmentFile,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts all backend services, including the nginx proxy and the database.
|
* Starts all backend services, including the nginx proxy and the database.
|
||||||
*/
|
*/
|
||||||
gulp.task('services', async () => {
|
gulp.task('services', async () => {
|
||||||
await runSequenceP('docker-start', 'services-only', 'nginx');
|
await runSequenceP('environment', 'docker-start', 'services-only', 'nginx');
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +152,12 @@ gulp.task('docker-compose', async () => {
|
||||||
// dockerFile = 'Dockerfile';
|
// dockerFile = 'Dockerfile';
|
||||||
|
|
||||||
composeYml.services[service.name] = {
|
composeYml.services[service.name] = {
|
||||||
environment: ['NODE_ENV=${NODE_ENV}'],
|
environment: ['NODE_ENV=${NODE_ENV}',
|
||||||
|
'salixHost=${salixHost}',
|
||||||
|
'salixUser=${salixUser}',
|
||||||
|
'salixPassword=${salixPassword}',
|
||||||
|
'salixPort=${salixPort}'
|
||||||
|
],
|
||||||
container_name: `\${BRANCH_NAME}-${service.name}`,
|
container_name: `\${BRANCH_NAME}-${service.name}`,
|
||||||
image: `${service.name}:\${TAG}`,
|
image: `${service.name}:\${TAG}`,
|
||||||
build: {
|
build: {
|
||||||
|
@ -391,7 +404,7 @@ gulp.task('watch', function() {
|
||||||
* Rebuilds the docker and it's image, if these already exist, destroys and
|
* Rebuilds the docker and it's image, if these already exist, destroys and
|
||||||
* rebuilds them.
|
* rebuilds them.
|
||||||
*/
|
*/
|
||||||
gulp.task('docker-rebuild', async () => {
|
gulp.task('docker-rebuild', ['environment'], async () => {
|
||||||
try {
|
try {
|
||||||
await execP('docker rm -f dblocal');
|
await execP('docker rm -f dblocal');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
@ -434,10 +447,10 @@ gulp.task('docker-run', async () => {
|
||||||
try {
|
try {
|
||||||
await execP('docker image inspect -f "{{json .Id}}" dblocal');
|
await execP('docker image inspect -f "{{json .Id}}" dblocal');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await execP('docker build -t dblocal:latest ./services/db');
|
await execP(`docker build -t dblocal:latest --build-arg rootPassword=${process.env.salixPassword} ./services/db`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await execP('docker run -d --name dblocal -p 3306:3306 dblocal');
|
await execP(`docker run -d --name dblocal -p ${process.env.salixPort}:${process.env.salixPort} dblocal`);
|
||||||
await runSequenceP('docker-wait');
|
await runSequenceP('docker-wait');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -469,8 +482,10 @@ gulp.task('docker-wait', callback => {
|
||||||
return callback(new Error('Docker exited, please see the docker logs for more info'));
|
return callback(new Error('Docker exited, please see the docker logs for more info'));
|
||||||
|
|
||||||
let conn = mysql.createConnection({
|
let conn = mysql.createConnection({
|
||||||
host: 'localhost',
|
host: process.env.salixHost,
|
||||||
user: 'root'
|
port: process.env.salixPort,
|
||||||
|
user: process.env.salixUser,
|
||||||
|
password: process.env.salixPassword
|
||||||
});
|
});
|
||||||
conn.on('error', () => {});
|
conn.on('error', () => {});
|
||||||
conn.connect(err => {
|
conn.connect(err => {
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
"file-loader": "^1.1.6",
|
"file-loader": "^1.1.6",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
|
"gulp-env": "^0.4.0",
|
||||||
"gulp-extend": "^0.2.0",
|
"gulp-extend": "^0.2.0",
|
||||||
"gulp-install": "^1.1.0",
|
"gulp-install": "^1.1.0",
|
||||||
"gulp-jasmine": "^3.0.0",
|
"gulp-jasmine": "^3.0.0",
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
for file in changes/*/*.sql; do
|
for file in changes/*/*.sql; do
|
||||||
echo "Importing $file"
|
echo "Importing $file"
|
||||||
mysql -u root < $file
|
mysql -u root -p$salixPassword < $file
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
FROM mysql:5.6.37
|
FROM mysql:5.6.37
|
||||||
|
|
||||||
ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
|
ARG rootPassword
|
||||||
|
ENV salixPassword $rootPassword
|
||||||
|
ENV MYSQL_ROOT_PASSWORD $salixPassword
|
||||||
ENV TZ GMT-1
|
ENV TZ GMT-1
|
||||||
|
|
||||||
WORKDIR /docker-entrypoint-initdb.d
|
WORKDIR /docker-entrypoint-initdb.d
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"salixHost": "localhost",
|
||||||
|
"salixPort": 3306,
|
||||||
|
"salixUser": "root",
|
||||||
|
"salixPassword": ""
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
def branchName = "${env.BRANCH_NAME}";
|
||||||
|
def branchProduction = "master"
|
||||||
|
def branchTest = "test";
|
||||||
|
|
||||||
|
env.BRANCH_NAME = branchName;
|
||||||
|
env.TAG = "${env.BUILD_NUMBER}";
|
||||||
|
env.salixUser="${env.salixUser}";
|
||||||
|
env.salixPassword="${env.salixPassword}";
|
||||||
|
env.salixHost = "${env.productionSalixHost}";
|
||||||
|
env.salixPort = "${env.productionSalixPort}";
|
||||||
|
|
||||||
|
switch (branchName){
|
||||||
|
case branchTest:
|
||||||
|
env.NODE_ENV = "test";
|
||||||
|
env.salixHost = "${env.testSalixHost}";
|
||||||
|
env.salixPort = "${env.testSalixPort}";
|
||||||
|
break;
|
||||||
|
case branchProduction:
|
||||||
|
env.DOCKER_HOST = "tcp://172.16.255.29:2375";
|
||||||
|
env.NODE_ENV = "production"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
node
|
||||||
|
{
|
||||||
|
stage ('Print environment variables'){
|
||||||
|
echo "Branch ${branchName}, Build ${env.TAG}, salixHost ${env.salixHost}, NODE_ENV ${env.NODE_ENV} en docker Host ${env.DOCKER_HOST}"
|
||||||
|
}
|
||||||
|
stage ('Checkout') {
|
||||||
|
checkout scm
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ('install modules'){
|
||||||
|
sh "npm install"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ('build Project'){
|
||||||
|
sh "gulp build"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("docker")
|
||||||
|
{
|
||||||
|
stage ("install modules loopback service")
|
||||||
|
{
|
||||||
|
sh "cd ./services/loopback && npm install"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("Stopping/Removing Docker")
|
||||||
|
{
|
||||||
|
sh "docker-compose down --rmi 'all'"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage ("Generar dockers")
|
||||||
|
{
|
||||||
|
sh "docker-compose up -d --build"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,37 +1,41 @@
|
||||||
{
|
{
|
||||||
"db": {
|
"db": {
|
||||||
|
"name": "db",
|
||||||
"connector": "memory"
|
"connector": "memory"
|
||||||
},
|
},
|
||||||
"vn": {
|
"vn": {
|
||||||
|
"name": "mysql",
|
||||||
"connector": "mysql",
|
"connector": "mysql",
|
||||||
"database": "vn",
|
"database": "vn",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
"host": "localhost",
|
"host": "${salixHost}",
|
||||||
"port": 3306,
|
"port": "${salixPort}",
|
||||||
"username": "root",
|
"username": "${salixUser}",
|
||||||
"password": "",
|
"password": "${salixPassword}",
|
||||||
"connectTimeout": 20000,
|
"connectTimeout": 20000,
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
},
|
},
|
||||||
"salix": {
|
"salix": {
|
||||||
|
"name": "mysql",
|
||||||
"connector": "mysql",
|
"connector": "mysql",
|
||||||
"database": "salix",
|
"database": "salix",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
"host": "localhost",
|
"host": "${salixHost}",
|
||||||
"port": 3306,
|
"port": "${salixPort}",
|
||||||
"username": "root",
|
"username": "${salixUser}",
|
||||||
"password": "",
|
"password": "${salixPassword}",
|
||||||
"connectTimeout": 20000,
|
"connectTimeout": 20000,
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
},
|
},
|
||||||
"account": {
|
"account": {
|
||||||
|
"name": "mysql",
|
||||||
"connector": "mysql",
|
"connector": "mysql",
|
||||||
"database": "account",
|
"database": "account",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
"host": "localhost",
|
"host": "${salixHost}",
|
||||||
"port": 3306,
|
"port": "${salixPort}",
|
||||||
"username": "root",
|
"username": "${salixUser}",
|
||||||
"password": "",
|
"password": "${salixPassword}",
|
||||||
"connectTimeout": 20000,
|
"connectTimeout": 20000,
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
},
|
},
|
||||||
|
@ -39,10 +43,10 @@
|
||||||
"connector": "mysql",
|
"connector": "mysql",
|
||||||
"database": "edi",
|
"database": "edi",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
"host": "localhost",
|
"host": "${salixHost}",
|
||||||
"port": 3306,
|
"port": "${salixPort}",
|
||||||
"username": "root",
|
"username": "${salixUser}",
|
||||||
"password": "",
|
"password": "${salixPassword}",
|
||||||
"connectTimeout": 20000,
|
"connectTimeout": 20000,
|
||||||
"acquireTimeout": 20000
|
"acquireTimeout": 20000
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
2018/03/02 09:31:59 [notice] 7044#10044: signal process started
|
||||||
|
2018/03/02 09:31:59 [notice] 3892#15188: signal process started
|
||||||
|
2018/03/02 09:39:40 [notice] 8636#14980: signal process started
|
||||||
|
2018/03/02 12:40:36 [notice] 8340#13172: signal process started
|
Loading…
Reference in New Issue