diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..59d387d --- /dev/null +++ b/Jenkinsfile @@ -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() + } + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b27269c --- /dev/null +++ b/docker-compose.yml @@ -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