Zero deploy downtime, deploy speed improved
This commit is contained in:
parent
a860873819
commit
e93cbda6d0
|
@ -1,9 +1,8 @@
|
||||||
#!/usr/bin/env groovy
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
def curCompose = new File('docker-compose.current.yml')
|
||||||
|
|
||||||
// TODO: We are using latest tag until image rotation it's implemented
|
// TODO: We are using latest tag until image rotation it's implemented
|
||||||
env.TAG = 'latest' /* env.BUILD_NUMBER */;
|
|
||||||
env.salixUser = env.salixUser;
|
|
||||||
env.salixPassword = env.salixPassword;
|
|
||||||
env.COMPOSER_HTTP_TIMEOUT = 300;
|
env.COMPOSER_HTTP_TIMEOUT = 300;
|
||||||
|
|
||||||
switch (env.BRANCH_NAME) {
|
switch (env.BRANCH_NAME) {
|
||||||
|
@ -22,7 +21,7 @@ switch (env.BRANCH_NAME) {
|
||||||
|
|
||||||
node {
|
node {
|
||||||
stage ('Print environment variables') {
|
stage ('Print environment variables') {
|
||||||
echo "Branch ${env.BRANCH_NAME}, tag ${env.TAG}, environament ${env.NODE_ENV}"
|
echo "Branch ${env.BRANCH_NAME}, build number ${env.BUILD_NUMBER}, environment ${env.NODE_ENV}"
|
||||||
}
|
}
|
||||||
stage ('Checkout') {
|
stage ('Checkout') {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
@ -34,11 +33,16 @@ node {
|
||||||
stage ('Build project') {
|
stage ('Build project') {
|
||||||
sh "gulp build"
|
sh "gulp build"
|
||||||
}
|
}
|
||||||
stage ('Removing old dockers') {
|
|
||||||
sh "docker-compose down --rmi 'all'"
|
|
||||||
}
|
|
||||||
stage ('Generating new dockers') {
|
stage ('Generating new dockers') {
|
||||||
sh "docker build -t vn-loopback:latest ./services/loopback/"
|
sh "docker build -t vn-loopback:latest ./services/loopback/"
|
||||||
sh "docker-compose up -d --build"
|
sh "docker-compose up -d --build"
|
||||||
|
/*
|
||||||
|
def curCompose = new File('docker-compose.current.yml')
|
||||||
|
if (curCompose.exists()) {
|
||||||
|
sh "docker-compose --file docker-compose.current.yml down --rmi all"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
def compose = new File('docker-compose.yml')
|
||||||
|
compose.renameTo 'docker-compose.current.new.yml'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
30
gulpfile.js
30
gulpfile.js
|
@ -128,7 +128,6 @@ gulp.task('install', () => {
|
||||||
|
|
||||||
let packageFiles = [];
|
let packageFiles = [];
|
||||||
let services = fs.readdirSync(servicesDir);
|
let services = fs.readdirSync(servicesDir);
|
||||||
services.push('..');
|
|
||||||
services.forEach(service => {
|
services.forEach(service => {
|
||||||
packageFiles.push(`${servicesDir}/${service}/package.json`);
|
packageFiles.push(`${servicesDir}/${service}/package.json`);
|
||||||
});
|
});
|
||||||
|
@ -154,8 +153,17 @@ gulp.task('docker-compose', async () => {
|
||||||
let composeYml = yaml.safeLoad(compose);
|
let composeYml = yaml.safeLoad(compose);
|
||||||
let services = await getServices();
|
let services = await getServices();
|
||||||
|
|
||||||
|
let imageTag = 'latest';
|
||||||
|
if (process.env.BUILD_NUMBER)
|
||||||
|
imageTag = process.env.BUILD_NUMBER;
|
||||||
|
|
||||||
|
let namePrefix = '';
|
||||||
|
if (process.env.BRANCH_NAME)
|
||||||
|
namePrefix = `${process.env.BRANCH_NAME}-`;
|
||||||
|
|
||||||
for (let service of services) {
|
for (let service of services) {
|
||||||
let dockerFile = `Dockerfile`;
|
let dockerFile = `Dockerfile`;
|
||||||
|
let containerName = `${namePrefix}${service.name}`;
|
||||||
|
|
||||||
let localDockerFile = `${__dirname}/services/${service.name}/Dockerfile`;
|
let localDockerFile = `${__dirname}/services/${service.name}/Dockerfile`;
|
||||||
|
|
||||||
|
@ -163,24 +171,24 @@ gulp.task('docker-compose', async () => {
|
||||||
dockerFile = localDockerFile;
|
dockerFile = localDockerFile;
|
||||||
|
|
||||||
composeYml.services[service.name] = {
|
composeYml.services[service.name] = {
|
||||||
|
container_name: containerName,
|
||||||
|
image: `${service.name}:${imageTag}`,
|
||||||
|
volumes: ['/config:/config'],
|
||||||
|
build: {
|
||||||
|
context: `./services`,
|
||||||
|
dockerfile: dockerFile
|
||||||
|
},
|
||||||
|
ports: [`${service.port}:${defaultPort}`],
|
||||||
environment: [
|
environment: [
|
||||||
'NODE_ENV=${NODE_ENV}',
|
'NODE_ENV=${NODE_ENV}',
|
||||||
'salixHost=${salixHost}',
|
'salixHost=${salixHost}',
|
||||||
'salixPort=${salixPort}',
|
'salixPort=${salixPort}',
|
||||||
'salixUser=${salixUser}',
|
'salixUser=${salixUser}',
|
||||||
'salixPassword=${salixPassword}'
|
'salixPassword=${salixPassword}'
|
||||||
],
|
]
|
||||||
container_name: `\${BRANCH_NAME}-${service.name}`,
|
|
||||||
image: `${service.name}:\${TAG}`,
|
|
||||||
volumes: ['/config:/config'],
|
|
||||||
build: {
|
|
||||||
context: `./services`,
|
|
||||||
dockerfile: dockerFile
|
|
||||||
},
|
|
||||||
ports: [`${service.port}:${defaultPort}`]
|
|
||||||
};
|
};
|
||||||
composeYml.services.nginx.links.push(
|
composeYml.services.nginx.links.push(
|
||||||
`${service.name}:\${BRANCH_NAME}-${service.name}`
|
`${service.name}:${containerName}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8577,7 +8577,7 @@
|
||||||
"lodash.groupby": "4.6.0",
|
"lodash.groupby": "4.6.0",
|
||||||
"p-queue": "1.2.0",
|
"p-queue": "1.2.0",
|
||||||
"through2": "2.0.3",
|
"through2": "2.0.3",
|
||||||
"which": "1.3.0"
|
"which": "1.3.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"isexe": {
|
"isexe": {
|
||||||
|
@ -8597,9 +8597,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"which": {
|
"which": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||||
"integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=",
|
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"isexe": "2.0.0"
|
"isexe": "2.0.0"
|
||||||
|
@ -10827,7 +10827,6 @@
|
||||||
"version": "3.10.0",
|
"version": "3.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz",
|
||||||
"integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
|
"integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"argparse": "1.0.9",
|
"argparse": "1.0.9",
|
||||||
"esprima": "4.0.0"
|
"esprima": "4.0.0"
|
||||||
|
@ -10836,8 +10835,7 @@
|
||||||
"esprima": {
|
"esprima": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
|
||||||
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
|
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
|
||||||
"dev": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue