From 2d12be21cb45153a1c99cca7ec7dcb12438e487c Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 5 May 2022 11:05:05 +0200 Subject: [PATCH 1/4] #3974 Create test branch --- Dockerfile | 6 +++++- Jenkinsfile | 22 ++++++++++++++++++++-- debian/changelog | 2 +- docker-compose.yml | 13 ++++++------- package.json | 2 +- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 39d37ebd..97327720 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ # Not using buster because of bug: https://bugs.php.net/bug.php?id=78870 FROM debian:stretch-slim +ARG VERSION +ENV VERSION $VERSION + ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -37,8 +40,9 @@ RUN apt-get update \ cron ARG BUILD_ID=unknown +RUN echo $VERSION RUN apt-get update \ - && apt-get install -y php-vn-lib hedera-web \ + && apt-get install -y php-vn-lib hedera-web=$VERSION \ && rm -rf /var/lib/apt/lists/* CMD ["apachectl", "-D", "FOREGROUND"] diff --git a/Jenkinsfile b/Jenkinsfile index 685439ae..580ac0bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,12 +8,28 @@ pipeline { stages { stage('Checkout') { steps { + script { + def packageJson = readJSON file: 'package.json' + env.VERSION = packageJson.version + + switch (env.BRANCH_NAME) { + case 'master': + env.NODE_ENV = 'production' + env.REPLICAS = 3 + break + case 'test': + env.NODE_ENV = 'test' + env.REPLICAS = 1 + break + } + } setEnv() } } stage('Package') { when { branch 'master' + branch 'test' } agent { docker { @@ -31,6 +47,7 @@ pipeline { stage('Build') { when { branch 'master' + branch 'test' } environment { CREDS = credentials('docker-registry') @@ -44,6 +61,7 @@ pipeline { stage('Deploy') { when { branch 'master' + branch 'test' } environment { DOCKER_HOST = "${env.SWARM_HOST}" @@ -54,8 +72,8 @@ pipeline { } } post { - always { + unsuccessful { sendEmail() } } -} \ No newline at end of file +} diff --git a/debian/changelog b/debian/changelog index 79340e00..26284ccf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (1.407.65) stable; urgency=low +hedera-web (1.407.66) stable; urgency=low * Initial Release. diff --git a/docker-compose.yml b/docker-compose.yml index c4d0d50a..9674034e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,12 @@ version: '3.7' services: main: - image: registry.verdnatura.es/hedera-web + image: registry.verdnatura.es/hedera-web:${BRANCH_NAME:?} build: context: . dockerfile: Dockerfile + args: + - VERSION=${VERSION:?} ports: - 80 configs: @@ -17,12 +19,12 @@ services: - /mnt/appdata/image:/var/lib/hedera-web/image-db - /mnt/appdata/vn-access:/var/lib/hedera-web/vn-access deploy: - replicas: 3 + replicas: ${REPLICAS:?} placement: constraints: - node.role == worker cron: - image: registry.verdnatura.es/hedera-web + image: registry.verdnatura.es/hedera-web:${BRANCH_NAME:?} command: 'cron -f' configs: - source: config @@ -37,7 +39,4 @@ services: configs: config: external: true - name: ${PROJECT_NAME:?}_config - test: - external: true - name: ${PROJECT_NAME:?}_test + name: ${PROJECT_NAME:?}-${BRANCH_NAME:?} diff --git a/package.json b/package.json index 29415072..a41b7ac2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "1.407.65", + "version": "1.407.66", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { From 8ec889a9f7fbdff3503d15da69d405ee8a0873cc Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 5 May 2022 11:19:29 +0200 Subject: [PATCH 2/4] Jenkinsfile fixes --- Jenkinsfile | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 580ac0bf..86498598 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,8 +28,10 @@ pipeline { } stage('Package') { when { - branch 'master' - branch 'test' + anyOf { + branch 'master' + branch 'test' + } } agent { docker { @@ -46,8 +48,10 @@ pipeline { } stage('Build') { when { - branch 'master' - branch 'test' + anyOf { + branch 'master' + branch 'test' + } } environment { CREDS = credentials('docker-registry') @@ -60,8 +64,10 @@ pipeline { } stage('Deploy') { when { - branch 'master' - branch 'test' + anyOf { + branch 'master' + branch 'test' + } } environment { DOCKER_HOST = "${env.SWARM_HOST}" From 497f0c130b99da8a6d2a4b748ca541005edae16e Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 5 May 2022 11:35:14 +0200 Subject: [PATCH 3/4] docker-compose fix --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9674034e..e33e7216 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,6 @@ services: configs: - source: config target: /etc/hedera-web/config.my.php - - source: test - target: /etc/hedera-web/config.test.php volumes: - /mnt/appdata:/mnt/storage - /mnt/appdata/image:/var/lib/hedera-web/image-db From f5e1b11df987afe1db1a7143cee5a4458ab798f7 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 5 May 2022 11:39:49 +0200 Subject: [PATCH 4/4] Jenkinsfile fixes --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 86498598..6de5da29 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,7 @@ pipeline { agent any environment { PROJECT_NAME = 'hedera-web' + STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" } stages { stage('Checkout') { @@ -73,7 +74,7 @@ pipeline { DOCKER_HOST = "${env.SWARM_HOST}" } steps { - dockerStackDeploy() + sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" } } }