From 96a6f4ced65c0b3a1334d8c5b5ad6516e3ace21c Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Fri, 12 Aug 2016 11:45:44 -0400 Subject: [PATCH 1/3] Getting started with image intentions --- Dockerfile | 1 + tests/image.bats | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index a567e14..a4f57fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ RUN yum -y install \ && rm /etc/httpd/conf.d/userdir.conf \ && rm /etc/httpd/conf.d/welcome.conf +ONBUILD COPY httpd-foreground /usr/local/bin/ diff --git a/tests/image.bats b/tests/image.bats index b52fe41..bbff398 100755 --- a/tests/image.bats +++ b/tests/image.bats @@ -5,4 +5,8 @@ load ../common @test "Concludes first-run experience" { result="$(docker run -i $maintainer/$imagename find /tmp/firsttimerunning)" [ "$result" != '' ] +} + +@test "Contains ONBUILD mechanism" { + grep ONBUILD Dockerfile } \ No newline at end of file From cccfb7a8fb70f30f4027acf5560c206958cf5c76 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Fri, 12 Aug 2016 12:16:28 -0400 Subject: [PATCH 2/3] Setting up ONBUILD instructions --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a4f57fc..0e384a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,8 @@ RUN yum -y install \ && rm /etc/httpd/conf.d/userdir.conf \ && rm /etc/httpd/conf.d/welcome.conf -ONBUILD +ONBUILD COPY ./certs/ /etc/httpd/certs/ +ONBUILD COPY ./conf/ /etc/httpd/conf.d/ COPY httpd-foreground /usr/local/bin/ From b036068443a8c6ac3d3cd4b2aeaa85070aad7a7f Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Fri, 12 Aug 2016 12:22:53 -0400 Subject: [PATCH 3/3] Introducing notifications to build --- Jenkinsfile | 20 ++++++++++++++++++-- bin/ci-run.sh | 2 +- bin/ci-stop.sh | 3 +-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 92b3cad..9c5c080 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,11 +27,19 @@ node('docker') { echo "Building ${maintainer}:${tag} for ${maintainer}" } - sh 'bin/rebuild.sh' + try{ + // Build Base Image + sh 'bin/rebuild.sh &> debug' + } catch(error) { + def error_details = readFile('./debug'); + def message = "BUILD ERROR: There was a problem building ${imagename}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } stage 'Start container' - sh 'bin/ci-run.sh && sleep 60' + sh 'bin/ci-run.sh' stage 'Tests' @@ -59,4 +67,12 @@ def maintainer() { def imagename() { def matcher = readFile('common.bash') =~ 'imagename="(.+)"' matcher ? matcher[0][1] : null +} + +def handleError(String message){ + echo "${message}" + currentBuild.setResult("FAILED") + slackSend color: 'danger', message: "${message}" + step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chris.bynum@levvel.io', sendToIndividuals: true]) + sh 'exit 1' } \ No newline at end of file diff --git a/bin/ci-run.sh b/bin/ci-run.sh index 70761f0..80b6c0d 100755 --- a/bin/ci-run.sh +++ b/bin/ci-run.sh @@ -3,4 +3,4 @@ # This file will run a container in the background source common.bash . -docker run -d --name=$imagename -p 80:80 -p 443:443 $maintainer/$imagename \ No newline at end of file +docker run -d --name=$imagename -p 80:80 -p 443:443 $maintainer/$imagename diff --git a/bin/ci-stop.sh b/bin/ci-stop.sh index 2ac6a32..416db9e 100755 --- a/bin/ci-stop.sh +++ b/bin/ci-stop.sh @@ -5,5 +5,4 @@ source common.bash . echo "Cleaning up Docker image($maintainer/$imagename)" docker stop $imagename >> /dev/null -docker rm $imagename -exit 0 \ No newline at end of file +docker rm $imagename \ No newline at end of file