diff --git a/Dockerfile b/Dockerfile index e110912..a71e161 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,16 @@ -FROM bigfleet/shibboleth_idp +FROM bigfleet/shibboleth_idp:master ARG maintainer=tier ARG imagename=shibboleth_idp ARG version=3.2.1 ENV VERSION=$version +ENV JAVA_OPTS=-Xmx1500m -XX:MaxPermSize=128m -RUN chown -R root:root /opt/shibboleth/shibboleth-identity-provider-$version +RUN chown -R root:root /opt/shibboleth/shibboleth-identity-provider-$version && \ + rm -rf /usr/local/tomcat/webapps/* && \ + ANT_OPTS="-Didp.target.dir=/opt/shibboleth/current" /opt/shibboleth/current/bin/build.sh && \ + ln -s /opt/shibboleth/current /opt/shibboleth-idp && \ + ln -s /opt/shibboleth-idp/war/idp.war $CATALINA_HOME/webapps/ROOT.war EXPOSE 8080 CMD ["catalina.sh", "run"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 15e20f8..cff36c8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -node { +node('docker') { stage 'Checkout' @@ -36,10 +36,18 @@ node { } sh 'bin/rebuild.sh' + + stage 'Start container' + + sh 'bin/ci-run.sh && sleep 60' stage 'Tests' sh 'bin/test.sh' + // should build a finally construct here + stage 'Stop container' + + sh 'bin/ci-stop.sh' } diff --git a/bin/ci-run.sh b/bin/ci-run.sh new file mode 100755 index 0000000..755e216 --- /dev/null +++ b/bin/ci-run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# This file will run a container in the background +source common.bash . + +docker run -d --name=$imagename -p 8080:8080 $maintainer/$imagename \ No newline at end of file diff --git a/bin/ci-stop.sh b/bin/ci-stop.sh new file mode 100755 index 0000000..2ac6a32 --- /dev/null +++ b/bin/ci-stop.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# This file will run a container in the background +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 diff --git a/tests/image.bats b/tests/image.bats index 81a7bee..e3d24d2 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -21,3 +21,8 @@ load ../common result="$(docker run -i $maintainer/$imagename stat -c '%U' /opt/shibboleth/current/logs)" [ "$result" != 'UNKNOWN' ] } + +@test "Other Tomcat webapps removed" { + result="$(docker run -i $maintainer/$imagename find /usr/local/tomcat/webapps -type d -print0)" + [ "$result" == '/usr/local/tomcat/webapps' ] +} diff --git a/tests/running.bats b/tests/running.bats index 00c9e23..d1c9b16 100644 --- a/tests/running.bats +++ b/tests/running.bats @@ -2,14 +2,18 @@ load ../common -setup() { - bin/start.sh -} +# These tests assume the pipeline will start and stop the container. @test "Leaves running process" { result="$(docker ps | grep $imagename)" [ "$result" != '' ] } -teardown() { - bin/stop.sh + +@test "Exposes running Tomcat service" { + result="$(docker exec -i $imagename curl http://localhost:8080/)" + [ "$result" != '' ] +} + +@test "Service is Shibboleth" { + docker exec -i $imagename curl -silent http://localhost:8080/ | grep 'Shibboleth' }