From a27b112b6df18118148aaa1e7595df665733d67e Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Mon, 18 Jul 2016 13:16:08 -0400 Subject: [PATCH] Tests and scripts to support building IDP image --- Dockerfile | 20 ++++++++++++++++++++ Jenkinsfile | 26 ++++++++++++++++++++++++++ README.md | 15 +++++++++++++++ bin/build.sh | 6 ++++++ bin/destroy.sh | 6 ++++++ bin/rerun.sh | 3 +++ bin/retry.sh | 5 +++++ bin/run.sh | 5 +++++ bin/test.sh | 3 +++ common.bash | 5 +++++ tests/shibboleth-idp.bats | 13 +++++++++++++ 11 files changed, 107 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile create mode 100644 README.md create mode 100755 bin/build.sh create mode 100755 bin/destroy.sh create mode 100755 bin/rerun.sh create mode 100755 bin/retry.sh create mode 100755 bin/run.sh create mode 100755 bin/test.sh create mode 100644 common.bash create mode 100644 tests/shibboleth-idp.bats diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..88cd1aa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM bigfleet/centos7base + +# Establish a default value for critical variables +# These values are not used by bin scripts or the pipeline. +# Those values are set in common.bash +ARG registry=docker.io +ARG maintainer=tier +ARG imagename=shibboleth_idp +ARG version=3.2.1 + +ENV VERSION=$version + +MAINTAINER $maintainer +LABEL Vendor="Internet2" +LABEL ImageType="Shibboleth IDP Release" +LABEL ImageName=$imagename +LABEL ImageOS=centos7 +LABEL Version=$VERSION + +CMD echo $VERSION \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..e7c9559 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,26 @@ +node { + + env.DOCKERHUB_ACCOUNT = "bigfleet" + env.VERSION_TAG = "3.2.1" // latest version of the release + env.BUILD_TAG = "testing" // default tag to push for to the registry + + stage 'Checkout' + + checkout scm + + stage 'Base' + + sh './build_image.sh' + + stage 'Tests' + + sh '/usr/local/bin/bats tests/shibboleth-idp.bats' + + stage 'Push' + if(env.BRANCH_NAME == "master") + docker.withRegistry('https://registry.hub.docker.com/', 'dockerhub-bigfleet') { + def baseImg = docker.build('bigfleet/centos7base') + baseImg.push('latest') + } + +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3dca5f --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Shibboleth IDP Container Images + +This repository creates and distributes Shibboleth IDP images to Dockerhub. + +## Supported Images + +### Release image + +These images track official releases of the software. The `master` branch produces these images, and the build pipeline distributes the results to Dockerhub. + +## Development + +### Configuration + +To alter project configuration details (e.g. which version of the Shibboleth IDP software is the latest), refer to common.bash-- a file referenced by many places. \ No newline at end of file diff --git a/bin/build.sh b/bin/build.sh new file mode 100755 index 0000000..190c975 --- /dev/null +++ b/bin/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +source common.bash . + +echo "Building new Docker image($maintainer/$imagename)" +docker build --rm -t $maintainer/$imagename --build-arg maintainer=$maintainer --build-arg imagename=$imagename --build-arg version=$version . \ No newline at end of file diff --git a/bin/destroy.sh b/bin/destroy.sh new file mode 100755 index 0000000..b282a47 --- /dev/null +++ b/bin/destroy.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +source common.bash . + +docker rm $(docker ps -a | grep $maintainer/$imagename | awk '{print $1}') +docker rmi $maintainer/$imagename diff --git a/bin/rerun.sh b/bin/rerun.sh new file mode 100755 index 0000000..da1dff6 --- /dev/null +++ b/bin/rerun.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +source bin/destroy.sh && source bin/build.sh && source bin/run.sh \ No newline at end of file diff --git a/bin/retry.sh b/bin/retry.sh new file mode 100755 index 0000000..59406e2 --- /dev/null +++ b/bin/retry.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source common.bash . + +docker rm $(docker ps -a | grep $maintainer/$imagename | awk '{print $1}') diff --git a/bin/run.sh b/bin/run.sh new file mode 100755 index 0000000..3509fb8 --- /dev/null +++ b/bin/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source common.bash . + +docker run $maintainer/$imagename \ No newline at end of file diff --git a/bin/test.sh b/bin/test.sh new file mode 100755 index 0000000..6d4b8be --- /dev/null +++ b/bin/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +bats tests \ No newline at end of file diff --git a/common.bash b/common.bash new file mode 100644 index 0000000..54621fe --- /dev/null +++ b/common.bash @@ -0,0 +1,5 @@ +registry="docker.io" +maintainer="bigfleet" +basename="shibboleth_idp" +imagename="shibboleth_idp" +version="3.2.1" \ No newline at end of file diff --git a/tests/shibboleth-idp.bats b/tests/shibboleth-idp.bats new file mode 100644 index 0000000..8274927 --- /dev/null +++ b/tests/shibboleth-idp.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats + +load ../common + +@test "file reading" { + result="$(echo $maintainer)" + [ "$result" = 'bigfleet' ] +} + +@test "container output" { + result="$(docker run bigfleet/shibboleth_idp)" + [ "$result" = '3.2.1' ] +} \ No newline at end of file