Skip to content

Onbuild ing #1

Merged
3 commits merged into from
Aug 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}