Zero deploy downtime, deploy speed improved
This commit is contained in:
parent
a860873819
commit
e93cbda6d0
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env groovy
|
||||
|
||||
def curCompose = new File('docker-compose.current.yml')
|
||||
|
||||
// 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;
|
||||
|
||||
switch (env.BRANCH_NAME) {
|
||||
|
@ -22,7 +21,7 @@ switch (env.BRANCH_NAME) {
|
|||
|
||||
node {
|
||||
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') {
|
||||
checkout scm
|
||||
|
@ -34,11 +33,16 @@ node {
|
|||
stage ('Build project') {
|
||||
sh "gulp build"
|
||||
}
|
||||
stage ('Removing old dockers') {
|
||||
sh "docker-compose down --rmi 'all'"
|
||||
}
|
||||
stage ('Generating new dockers') {
|
||||
sh "docker build -t vn-loopback:latest ./services/loopback/"
|
||||
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 services = fs.readdirSync(servicesDir);
|
||||
services.push('..');
|
||||
services.forEach(service => {
|
||||
packageFiles.push(`${servicesDir}/${service}/package.json`);
|
||||
});
|
||||
|
@ -154,8 +153,17 @@ gulp.task('docker-compose', async () => {
|
|||
let composeYml = yaml.safeLoad(compose);
|
||||
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) {
|
||||
let dockerFile = `Dockerfile`;
|
||||
let containerName = `${namePrefix}${service.name}`;
|
||||
|
||||
let localDockerFile = `${__dirname}/services/${service.name}/Dockerfile`;
|
||||
|
||||
|
@ -163,24 +171,24 @@ gulp.task('docker-compose', async () => {
|
|||
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}'
|
||||
],
|
||||
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(
|
||||
`${service.name}:\${BRANCH_NAME}-${service.name}`
|
||||
`${service.name}:${containerName}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -8577,7 +8577,7 @@
|
|||
"lodash.groupby": "4.6.0",
|
||||
"p-queue": "1.2.0",
|
||||
"through2": "2.0.3",
|
||||
"which": "1.3.0"
|
||||
"which": "1.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"isexe": {
|
||||
|
@ -8597,9 +8597,9 @@
|
|||
}
|
||||
},
|
||||
"which": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
|
||||
"integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"isexe": "2.0.0"
|
||||
|
@ -10827,7 +10827,6 @@
|
|||
"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": "4.0.0"
|
||||
|
@ -10836,8 +10835,7 @@
|
|||
"esprima": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz",
|
||||
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue