From d22403167b7188e8a85cfe9ad1f036f4c81bee3a Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 30 Apr 2021 00:39:44 +0200 Subject: [PATCH] Docker stack deploy --- Jenkinsfile | 20 ++++++-------------- docker-compose.yml | 6 ++++++ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 85914ad62..d411ddb22 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,15 +13,6 @@ pipeline { stage('Checkout') { steps { script { - if (!env.GIT_COMMITTER_EMAIL) { - env.COMMITTER_EMAIL = sh( - script: 'git --no-pager show -s --format="%ae"', - returnStdout: true - ).trim() - } else { - env.COMMITTER_EMAIL = env.GIT_COMMITTER_EMAIL; - } - switch (env.BRANCH_NAME) { case 'master': env.NODE_ENV = 'production' @@ -41,7 +32,7 @@ pipeline { load env.GROOVY_FILE } - sh 'printenv' + setEnv() } } stage('Install') { @@ -86,16 +77,14 @@ pipeline { branch 'master' }} environment { - CREDS = credentials('docker-registry') + CREDENTIALS = credentials('docker-registry') } steps { nodejs('node-v12') { sh 'gulp build' } - sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY' - sh 'docker-compose build --parallel' - sh 'docker-compose push' + dockerBuild() } } stage('Deploy') { @@ -103,6 +92,9 @@ pipeline { branch 'test' branch 'master' }} + environment { + DOCKER_HOST = "${env.SWARM_HOST}" + } steps { sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" } diff --git a/docker-compose.yml b/docker-compose.yml index 24e1446e9..f8d1c808b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,9 @@ services: - 80 deploy: replicas: 2 + placement: + constraints: + - node.role == worker back: image: registry.verdnatura.es/salix-back:${BRANCH_NAME:?} build: . @@ -31,6 +34,9 @@ services: - /mnt/storage/image:/var/lib/salix/image deploy: replicas: ${BACK_REPLICAS:?} + placement: + constraints: + - node.role == worker configs: datasources: external: true