From 5d8340989235ffc8126cb4edf3af9ec98a1f814f Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 27 May 2024 09:31:42 +0200 Subject: [PATCH 1/4] feat: refs #7442 Kubernetes deploy --- Jenkinsfile | 9 ++++++++- package.json | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6f0a642b4..661b96073 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -215,7 +215,14 @@ pipeline { def packageJson = readJSON file: 'package.json' env.VERSION = packageJson.version } - sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" + withKubeConfig([ + serverUrl: "$KUBERNETES_API", + credentialsId: 'kubernetes', + namespace: 'salix' + ]) { + sh 'kubectl set image deployment/salix-back-$BRANCH salix-back-$BRANCH=$REGISTRY/salix-back:$VERSION' + sh 'kubectl set image deployment/salix-front-$BRANCH salix-front-$BRANCH=$REGISTRY/salix-front:$VERSION' + } } } } diff --git a/package.json b/package.json index 390b61be1..be3dcca04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.0", + "version": "24.22.1", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From a18df86abdc8035d9686f377b9c600ebd7eb3f63 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 27 May 2024 09:37:17 +0200 Subject: [PATCH 2/4] fix: refs #7442 Fix kubernetes deploy --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 661b96073..9e032fa21 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -220,8 +220,8 @@ pipeline { credentialsId: 'kubernetes', namespace: 'salix' ]) { - sh 'kubectl set image deployment/salix-back-$BRANCH salix-back-$BRANCH=$REGISTRY/salix-back:$VERSION' - sh 'kubectl set image deployment/salix-front-$BRANCH salix-front-$BRANCH=$REGISTRY/salix-front:$VERSION' + sh 'kubectl set image deployment/salix-back-$BRANCH_NAME salix-back-$BRANCH_NAME=$REGISTRY/salix-back:$VERSION' + sh 'kubectl set image deployment/salix-front-$BRANCH_NAME salix-front-$BRANCH_NAME=$REGISTRY/salix-front:$VERSION' } } } From 52e9c662719ddbbbb13c4e37cd97cbb06f121747 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 27 May 2024 09:39:51 +0200 Subject: [PATCH 3/4] fix: refs #7442 Fix kubernetes deploy --- Jenkinsfile | 2 +- docker-compose.yml | 54 ---------------------------------------------- 2 files changed, 1 insertion(+), 55 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9e032fa21..e9ef4816b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -203,7 +203,7 @@ pipeline { sh 'npx myt push $NODE_ENV --force --commit' } } - stage('Docker') { + stage('Kubernetes') { when { expression { FROM_GIT } } diff --git a/docker-compose.yml b/docker-compose.yml index ec40311c0..923bb5780 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,62 +4,8 @@ services: image: registry.verdnatura.es/salix-front:${VERSION:?} build: context: front - environment: - - TZ - - NODE_ENV - ports: - - 80 - deploy: - replicas: 2 - placement: - constraints: - - node.role == worker - resources: - limits: - memory: 1G back: image: registry.verdnatura.es/salix-back:${VERSION:?} build: context: . dockerfile: back/Dockerfile - environment: - - TZ - - NODE_ENV - - DEBUG - ports: - - 3000 - configs: - - source: datasources - target: /etc/salix/datasources.json - - source: datasources_local - target: /etc/salix/datasources.local.json - - source: print - target: /etc/salix/print.json - - source: print_local - target: /etc/salix/print.local.json - volumes: - - /mnt/appdata/pdfs:/var/lib/salix/pdfs - - /mnt/appdata/dms:/var/lib/salix/dms - - /mnt/appdata/image:/var/lib/salix/image - - /mnt/appdata/vn-access:/var/lib/salix/vn-access - deploy: - replicas: ${BACK_REPLICAS:?} - placement: - constraints: - - node.role == worker - resources: - limits: - memory: 8G -configs: - datasources: - external: true - name: salix_datasources - datasources_local: - external: true - name: salix-${BRANCH_NAME:?}_datasources - print: - external: true - name: salix_print - print_local: - external: true - name: salix-${BRANCH_NAME:?}_print From b675bcd6cedb2d84be6dedc8770158c4d36e37bb Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 27 May 2024 10:07:44 +0200 Subject: [PATCH 4/4] fix: refs #7442 Fix kubernetes deploy --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e9ef4816b..9d6c57a64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,6 +24,7 @@ node { FROM_GIT = env.JOB_NAME.startsWith('gitea/') RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT RUN_BUILD = PROTECTED_BRANCH && FROM_GIT + // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables echo "NODE_NAME: ${env.NODE_NAME}" echo "WORKSPACE: ${env.WORKSPACE}" @@ -207,9 +208,6 @@ pipeline { when { expression { FROM_GIT } } - environment { - DOCKER_HOST = "${env.SWARM_HOST}" - } steps { script { def packageJson = readJSON file: 'package.json'