diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8185b57 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM httpd:latest + +COPY web . \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e9621fd --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,70 @@ +#!/usr/bin/env groovy + +pipeline { + agent any + environment { + PROJECT_NAME = 'vn-support' + } + stages { + stage('Checkout') { + steps { + script { + if (!env.GIT_COMMITTER_EMAIL) { + env.COMMITTER_EMAIL = sh( + script: 'git --no-pager show -s --format="%ae"', + returnStdout: true + ).trim() + } else { + env.COMMITTER_EMAIL = env.GIT_COMMITTER_EMAIL; + } + } + + configFileProvider([ + configFile(fileId: "${env.PROJECT_NAME}.groovy", + variable: 'GROOVY_FILE') + ]) { + load env.GROOVY_FILE + } + + sh 'printenv' + } + } + stage('Build') { + when { + branch 'master' + } + environment { + CREDS = credentials('docker-registry') + } + steps { + sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY' + sh 'docker-compose build --parallel' + sh 'docker-compose push' + } + } + stage('Deploy') { + when { + branch 'master' + } + steps { + sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.PROJECT_NAME}" + } + } + } + post { + always { + script { + if (!env.COMMITTER_EMAIL) return + try { + mail( + to: env.COMMITTER_EMAIL, + subject: "Pipeline: ${env.JOB_NAME} (${env.BUILD_NUMBER}): ${currentBuild.currentResult}", + body: "Check status at ${env.BUILD_URL}" + ) + } catch (e) { + echo e.toString() + } + } + } + } +} \ No newline at end of file diff --git a/deploy b/deploy deleted file mode 100755 index 7dae519..0000000 --- a/deploy +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e - -vn-debuild -vn-deploy root@www1.static root@www2.static diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7ae2edb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ + +version: '3.7' +services: + web: + image: registry.verdnatura.es/vn-support + build: + context: . + dockerfile: Dockerfile + ports: + - ${PORT:?}:80