From 63fab6a47a42fc28ae11522cc38502380570d8bc Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Mon, 12 Sep 2016 15:45:11 -0400 Subject: [PATCH 1/5] Adding autoexec support --- Dockerfile | 11 ++++++++++- README.md | 6 +++++- container_files/bin/firstrun.sh | 6 ++++++ container_files/bin/onbuild.sh | 6 ++++++ tests/base.bats | 16 ++++++++++++++++ 5 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 container_files/bin/firstrun.sh create mode 100755 container_files/bin/onbuild.sh diff --git a/Dockerfile b/Dockerfile index 99fed6b..b840c3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,13 +25,22 @@ RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime \ RUN yum -y install --setopt=tsflags=nodocs epel-release && \ yum -y install net-tools wget curl tar unzip mlocate logrotate strace telnet man unzip vim wget rsyslog cron && \ yum clean all && \ - mkdir -p /opt/tier + mkdir -p \ + /opt/autoexec/bin \ + /opt/autoexec/onbuild \ + /opt/autoexec/firstrun \ + /opt/bin \ + /opt/etc \ + /opt/tier \ # Install Trusted Certificates RUN update-ca-trust force-enable ADD ./cert/InCommon.crt /etc/pki/ca-trust/source/anchors/ RUN update-ca-trust extract +ADD container_files/bin/firstrun.sh /opt/autoexec/bin/firstrun.sh +ADD container_files/bin/onbuild.sh /opt/autoexec/bin/onbuild.sh + # Set default environment variables. ENV HOME /opt/tier diff --git a/README.md b/README.md index 99032bb..5cbde40 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,8 @@ Internet2 managed CentOS 7 base image ## purpose -This container allows I2/TIER to insulate itself against upstream changes from CentOS managed images that may be unwanted. It can also be used to trigger global changes (e.g. a new InCommon.crt) when appropriate. \ No newline at end of file +This container allows I2/TIER to insulate itself against upstream changes from CentOS managed images that may be unwanted. It can also be used to trigger global changes (e.g. a new InCommon.crt) when appropriate. + +## autorun + +You are encouraged to include /opt/autorun/bin/onbuild.sh when closing your Dockerfiles, and to include /opt/autorun/bin/firstrun.sh in your CMD entrypoints. \ No newline at end of file diff --git a/container_files/bin/firstrun.sh b/container_files/bin/firstrun.sh new file mode 100755 index 0000000..491f2b9 --- /dev/null +++ b/container_files/bin/firstrun.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for file in /opt/autoexec/firstrun/* +do + cmd "$file" >> /opt/etc/autoexec.firstrun.log +done \ No newline at end of file diff --git a/container_files/bin/onbuild.sh b/container_files/bin/onbuild.sh new file mode 100755 index 0000000..f193cde --- /dev/null +++ b/container_files/bin/onbuild.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for file in /opt/autoexec/build/* +do + cmd "$file" >> /opt/etc/autoexec.build.log +done \ No newline at end of file diff --git a/tests/base.bats b/tests/base.bats index 7ebaccf..a5d301d 100644 --- a/tests/base.bats +++ b/tests/base.bats @@ -14,3 +14,19 @@ load ../common [ "$status" -eq 0 ] [[ ${output} == *"302"* || ${output} == *"200"* ]] } + +@test "Onbuild support script" { + docker run -i $maintainer/$imagename find /opt/autoexec/bin/onbuild.sh +} + +@test "Onbuild support home" { + docker run -i $maintainer/$imagename find /opt/autoexec/onbuild +} + +@test "Firstrun support bin" { + docker run -i $maintainer/$imagename find /opt/autoexec/bin/firstrun.sh +} + +@test "Firstrun support home" { + docker run -i $maintainer/$imagename find /opt/autoexec/firstrun +} \ No newline at end of file From 8ba087b6ae5c0688fdae17baabec3bf978bd6b9e Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Mon, 12 Sep 2016 15:48:10 -0400 Subject: [PATCH 2/5] Specific about where we can test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7c11b45..dda7869 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -node { +node('docker') { stage 'Checkout' checkout scm From e7662ae875d4f8c0c03da861a081804e632e0381 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Mon, 12 Sep 2016 16:56:23 -0400 Subject: [PATCH 3/5] Fixing script directory name --- container_files/bin/onbuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container_files/bin/onbuild.sh b/container_files/bin/onbuild.sh index f193cde..378e312 100755 --- a/container_files/bin/onbuild.sh +++ b/container_files/bin/onbuild.sh @@ -1,6 +1,6 @@ #!/bin/bash -for file in /opt/autoexec/build/* +for file in /opt/autoexec/onbuild/* do cmd "$file" >> /opt/etc/autoexec.build.log done \ No newline at end of file From e9adedc1baa88e4d0b253178e23c4f6071083674 Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Tue, 13 Sep 2016 11:05:41 -0400 Subject: [PATCH 4/5] Updating bin file content --- Dockerfile | 3 ++- container_files/bin/firstrun.sh | 2 +- container_files/bin/onbuild.sh | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index b840c3d..85dc7e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,8 @@ RUN yum -y install --setopt=tsflags=nodocs epel-release && \ /opt/autoexec/firstrun \ /opt/bin \ /opt/etc \ - /opt/tier \ + /opt/log \ + /opt/tier # Install Trusted Certificates RUN update-ca-trust force-enable diff --git a/container_files/bin/firstrun.sh b/container_files/bin/firstrun.sh index 491f2b9..97f9d92 100755 --- a/container_files/bin/firstrun.sh +++ b/container_files/bin/firstrun.sh @@ -2,5 +2,5 @@ for file in /opt/autoexec/firstrun/* do - cmd "$file" >> /opt/etc/autoexec.firstrun.log + exec "$file" >> /opt/log/autoexec.firstrun.log done \ No newline at end of file diff --git a/container_files/bin/onbuild.sh b/container_files/bin/onbuild.sh index 378e312..07d014a 100755 --- a/container_files/bin/onbuild.sh +++ b/container_files/bin/onbuild.sh @@ -2,5 +2,5 @@ for file in /opt/autoexec/onbuild/* do - cmd "$file" >> /opt/etc/autoexec.build.log + exec "$file" >> /opt/log/autoexec.build.log done \ No newline at end of file From 8e84e96b3cc39eb7a4d34ba3572ea13408a12bce Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Tue, 13 Sep 2016 11:14:37 -0400 Subject: [PATCH 5/5] Ensuring autoexec bin scripts can terminate successfully --- Dockerfile | 2 ++ container_files/bin/stub.sh | 3 +++ tests/base.bats | 8 ++++++++ 3 files changed, 13 insertions(+) create mode 100755 container_files/bin/stub.sh diff --git a/Dockerfile b/Dockerfile index 85dc7e7..1854a3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,6 +41,8 @@ RUN update-ca-trust extract ADD container_files/bin/firstrun.sh /opt/autoexec/bin/firstrun.sh ADD container_files/bin/onbuild.sh /opt/autoexec/bin/onbuild.sh +ADD container_files/bin/stub.sh /opt/autoexec/firstrun/stub.sh +ADD container_files/bin/stub.sh /opt/autoexec/onbuild/stub.sh # Set default environment variables. ENV HOME /opt/tier diff --git a/container_files/bin/stub.sh b/container_files/bin/stub.sh new file mode 100755 index 0000000..08ba7a6 --- /dev/null +++ b/container_files/bin/stub.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo 'test' \ No newline at end of file diff --git a/tests/base.bats b/tests/base.bats index a5d301d..1777cce 100644 --- a/tests/base.bats +++ b/tests/base.bats @@ -29,4 +29,12 @@ load ../common @test "Firstrun support home" { docker run -i $maintainer/$imagename find /opt/autoexec/firstrun +} + +@test "Onbuild terminates correctly" { + docker run -i $maintainer/$imagename /opt/autoexec/bin/onbuild.sh +} + +@test "First run terminates correctly" { + docker run -i $maintainer/$imagename /opt/autoexec/bin/firstrun.sh } \ No newline at end of file