Skip to content

Commit

Permalink
Merge pull request #1 from docker/onbuild-ing
Browse files Browse the repository at this point in the history
Onbuild ing
  • Loading branch information
Jim Van Fleet committed Aug 12, 2016
2 parents aa7b5b5 + b036068 commit eedbc34
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ RUN yum -y install \
&& rm /etc/httpd/conf.d/userdir.conf \
&& rm /etc/httpd/conf.d/welcome.conf

ONBUILD COPY ./certs/ /etc/httpd/certs/
ONBUILD COPY ./conf/ /etc/httpd/conf.d/

COPY httpd-foreground /usr/local/bin/

Expand Down
20 changes: 18 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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'
}
2 changes: 1 addition & 1 deletion bin/ci-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
docker run -d --name=$imagename -p 80:80 -p 443:443 $maintainer/$imagename
3 changes: 1 addition & 2 deletions bin/ci-stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ source common.bash .

echo "Cleaning up Docker image($maintainer/$imagename)"
docker stop $imagename >> /dev/null
docker rm $imagename
exit 0
docker rm $imagename
4 changes: 4 additions & 0 deletions tests/image.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit eedbc34

Please sign in to comment.