Merge pull request 'refactor: feat #7441 Migration to kube' (!10) from 7441-migrationToKube into master
gitea/printnatura/pipeline/head There was a failure building this commit Details

Reviewed-on: #10
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
Guillermo Bonet 2024-05-28 05:10:50 +00:00
commit 99e7583cb3
2 changed files with 28 additions and 25 deletions

47
Jenkinsfile vendored
View File

@ -4,48 +4,51 @@ pipeline {
agent any
environment {
PROJECT_NAME = 'printnatura'
STACK_NAME = "${env.PROJECT_NAME}"
}
stages {
stage('Checkout') {
stage('Setup') {
steps {
setEnv()
echo "NODE_NAME: ${env.NODE_NAME}"
echo "WORKSPACE: ${env.WORKSPACE}"
}
}
stage('Container') {
stage('Build') {
when {
anyOf {
branch 'test'
branch 'master'
}
branch 'master'
}
environment {
CREDS = credentials('docker-registry')
CREDENTIALS = credentials('docker-registry')
}
steps {
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
sh 'docker-compose push'
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
dockerBuild()
}
}
stage('Deploy') {
when {
anyOf {
branch 'test'
branch 'master'
}
}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
CUPS = credentials('printnatura')
branch 'master'
}
steps {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
withKubeConfig([
serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes',
namespace: 'printnatura'
]) {
sh 'kubectl set image deployment/printnatura printnatura=registry.verdnatura.es/printnatura:$VERSION'
}
}
}
}
post {
unsuccessful {
always {
setEnv()
sendEmail()
}
}

View File

@ -1,7 +1,7 @@
version: '3.7'
services:
main:
image: registry.verdnatura.es/printnatura:latest
image: registry.verdnatura.es/printnatura:${VERSION:?}
build:
context: .
dockerfile: Dockerfile
@ -26,7 +26,7 @@ services:
configs:
config:
external: true
name: printnatura_config
name: printnatura-config
cups:
external: true
name: printnatura_cups
name: printnatura-cups