refs #4550 Deployment
gitea/printnatura/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2022-11-16 12:58:03 +01:00
parent 8f248f4425
commit 3ae239f3e1
2 changed files with 81 additions and 0 deletions

49
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env groovy
pipeline {
agent any
environment {
PROJECT_NAME = 'printnatura'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
stages {
stage('Checkout') {
steps {
setEnv()
}
}
stage('Container') {
when {
anyOf {
branch 'test'
}
}
environment {
CREDS = 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'
}
}
stage('Deploy') {
when {
anyOf {
branch 'test'
}
}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
}
steps {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
}
}
}
post {
unsuccessful {
sendEmail()
}
}
}

32
docker-compose.yml Normal file
View File

@ -0,0 +1,32 @@
version: '3.7'
services:
main:
image: registry.verdnatura.es/printnatura:latest
build:
context: .
dockerfile: Dockerfile
ports:
- 631
configs:
- source: config
target: /printnatura/config.local.yml
- source: cups
target: /etc/cups/cupsd.conf
volumes:
- ppd:/etc/cups/ppd
deploy:
placement:
constraints:
- node.role == worker
volumes:
ppd:
driver: rexray
driver_opts:
size: 1
configs:
config:
external: true
name: printnatura_config
cups:
external: true
name: printnatura_cups