From 4ea67bd12bf12fe2aa5a1cf2776287d4b7fc3eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Thu, 1 Dec 2016 15:06:30 +0100 Subject: [PATCH 01/15] Distribute docker contianer to run ATH --- Jenkinsfile | 24 +++++++++++ README.md | 1 + docs/DOCKER.md | 18 +++++++++ docs/FIXTURES.md | 12 ------ src/main/resources/ath-container/Dockerfile | 44 +++++++++++++++++++++ 5 files changed, 87 insertions(+), 12 deletions(-) create mode 100644 Jenkinsfile create mode 100644 docs/DOCKER.md create mode 100644 src/main/resources/ath-container/Dockerfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000..ef8aaacf19 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,24 @@ +// For ci.jenkins.io +// https://github.com/jenkins-infra/documentation/blob/master/ci.adoc + +def mavenName = 'mvn' +def jdkName = 'jdk8' + +node('highram&&docker') { + withEnv([ + "JAVA_HOME=${tool jdkName}", + "PATH+MAVEN=${tool mavenName}/bin:${env.JAVA_HOME}/bin" + ]) { + changelog scm + + sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' + docker.image('jenkins/ath').inside { + sh ''' + eval $(./vnc.sh) + ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B + ''' + } + + junit 'target/surefire-reports/TEST-*.xml' + } +} diff --git a/README.md b/README.md index d2a0bb6d13..c07c4b9d7e 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ it's own sandboxed workspace. * [Obtaining a report of plugins that were exercised](docs/EXERCISEDPLUGINSREPORTER.md) * [Managing the versions of Jenkins and plugins](docs/SUT-VERSIONS.md) * [Investigation](docs/INVESTIGATION.md) +* [Running tests in container](docs/DOCKER.md) * Selecting tests based on plugins they cover (TODO) ### Writing tests diff --git a/docs/DOCKER.md b/docs/DOCKER.md new file mode 100644 index 0000000000..f22dd05d69 --- /dev/null +++ b/docs/DOCKER.md @@ -0,0 +1,18 @@ +# Running tests in docker container + +Depending on the CI infrastructure setup one may need to run the ATH itself in a docker container with access to the host docker service, following a strategy similar to the one described in [this article](http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/). When this is needed, the docker fixtures should not be accessed through mapped ports on the docker host, but directly through their container IP and port since they are "sibling" containers to the ATH. To enable this, set the environment variable SHARED_DOCKER_SERVICE=true, and then the functions ipBound(n) and port(n) will just return the container's IP and port where the fixture can be accessed. + +TO-DO: Instead of depending on setting this environment variable, in the future we could try to somehow automatically detect the situation. + +Interactive shell: + + $ docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container + $ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home/ath-user/ath --user ath-user jenkins/ath bash -c 'cd $HOME/ath && bash' + +Jenkinsfile: + + ... // Checkout ATH + sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' + docker.image('jenkins/ath').inside { + ... + } diff --git a/docs/FIXTURES.md b/docs/FIXTURES.md index 9ff1daaed1..2d090a96d5 100644 --- a/docs/FIXTURES.md +++ b/docs/FIXTURES.md @@ -76,15 +76,3 @@ public class TestContainer extends DockerContainer { ``` In this case the docker file must be located at classpath and in `org/ame/fixture/test` instead of the default location. - -## Running the ATH itself as a docker container -Depending on the CI infrastructure setup one may need to run the ATH itself in a docker container with access to the host docker service, -following a strategy similar to the one described in [this article](http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/). - -When this is needed, the docker fixtures should not be accessed through mapped ports on the docker host, but directly -through their container IP and port since they are "sibling" containers to the ATH. - -To enable this, set the environment variable `SHARED_DOCKER_SERVICE=true`, and then the functions ipBound(n) and port(n) -will just return the container's IP and port where the fixture can be accessed. - -TO-DO: Instead of depending on setting this environment variable, in the future we could try to somehow automatically detect the situation. diff --git a/src/main/resources/ath-container/Dockerfile b/src/main/resources/ath-container/Dockerfile new file mode 100644 index 0000000000..2488be0de1 --- /dev/null +++ b/src/main/resources/ath-container/Dockerfile @@ -0,0 +1,44 @@ +# Dockerfile to be used to run ATH itself. +# +# see docs/DOCKER.md for usage +# + +FROM debian:sid +MAINTAINER ogondza@gmail.com + +RUN apt-get -y update && \ + apt-get install -y \ + curl \ + docker.io \ + imagemagick \ + iptables \ + firefox-esr \ + maven \ + openjdk-8-jdk \ + vnc4server + +# Allow injecting uid and git to match directory ownership +ARG uid=1000 +ENV uid $uid +ARG gid=1000 +ENV gid $gid + +# So it is owned by root and has the permissions vncserver seems to require: +RUN mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix/ + +RUN groupadd ath-user -g $gid && \ + useradd ath-user -u $uid -g $gid -m -d /home/ath-user + +# TODO seems this can be picked up from the host, which is unwanted: +ENV XAUTHORITY /home/ath-user/.Xauthority + +USER ath-user +RUN mkdir /home/ath-user/.vnc && (echo ath-user; echo ath-user) | vncpasswd /home/ath-user/.vnc/passwd +# Default content includes x-window-manager, which is not installed, plus other stuff we do not need (vncconfig, x-terminal-emulator, etc.): +RUN touch /home/ath-user/.vnc/xstartup && chmod a+x /home/ath-user/.vnc/xstartup + +# Set SUID and SGID for docker binary so it can communicate with mapped socket its uid:gid we can not control. Alternative +# approach used for this is adding ath-user to the group of /var/run/docker.sock but that require root permission we do not +# have in ENTRYPOINT as the container is started as ath-user. +USER root +RUN chmod ug+s "$(which docker)" From 774160732e545e45ba1efccb1029c6c55ce71553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 7 Dec 2016 21:11:49 +0100 Subject: [PATCH 02/15] Ilustrate container usage --- docs/DOCKER.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/DOCKER.md b/docs/DOCKER.md index f22dd05d69..c4d881d582 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -8,11 +8,13 @@ Interactive shell: $ docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container $ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home/ath-user/ath --user ath-user jenkins/ath bash -c 'cd $HOME/ath && bash' + $ eval $(./vnc.sh > /dev/null) + $ ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B Jenkinsfile: ... // Checkout ATH sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' docker.image('jenkins/ath').inside { - ... + sh 'eval $(./vnc.sh > /dev/null) && ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B' } From bbcb0a39d6e7a73132a0a5baff2f4e827a17af47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Fri, 9 Dec 2016 09:06:13 +0100 Subject: [PATCH 03/15] Update vnc out redirection --- Jenkinsfile | 2 +- docs/DOCKER.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ef8aaacf19..fa3b7138c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ node('highram&&docker') { sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' docker.image('jenkins/ath').inside { sh ''' - eval $(./vnc.sh) + eval $(./vnc.sh > /dev/null 2>&1) ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B ''' } diff --git a/docs/DOCKER.md b/docs/DOCKER.md index c4d881d582..3c85a12bca 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -8,7 +8,7 @@ Interactive shell: $ docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container $ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home/ath-user/ath --user ath-user jenkins/ath bash -c 'cd $HOME/ath && bash' - $ eval $(./vnc.sh > /dev/null) + $ eval $(./vnc.sh > /dev/null 2>&1) $ ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B Jenkinsfile: @@ -16,5 +16,5 @@ Jenkinsfile: ... // Checkout ATH sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' docker.image('jenkins/ath').inside { - sh 'eval $(./vnc.sh > /dev/null) && ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B' + sh 'eval $(./vnc.sh > /dev/null 2>&1) && ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B' } From 9d6105a7a1c1126927cf0525dd2d279ae16ffd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Thu, 15 Dec 2016 15:18:32 +0100 Subject: [PATCH 04/15] Fix vnc output and add containerargs to Jenkinsfile --- Jenkinsfile | 5 +++-- docs/DOCKER.md | 4 ++-- vnc.sh | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fa3b7138c2..5bdd2a4cb1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,9 +12,10 @@ node('highram&&docker') { changelog scm sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' - docker.image('jenkins/ath').inside { + String containerArgs = '-v /var/run/docker.sock:/var/run/docker.sock' + docker.image('jenkins/ath').inside(containerArgs) { sh ''' - eval $(./vnc.sh > /dev/null 2>&1) + eval $(./vnc.sh) ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B ''' } diff --git a/docs/DOCKER.md b/docs/DOCKER.md index 3c85a12bca..e3cce3f30b 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -8,7 +8,7 @@ Interactive shell: $ docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container $ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home/ath-user/ath --user ath-user jenkins/ath bash -c 'cd $HOME/ath && bash' - $ eval $(./vnc.sh > /dev/null 2>&1) + $ eval $(./vnc.sh) $ ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B Jenkinsfile: @@ -16,5 +16,5 @@ Jenkinsfile: ... // Checkout ATH sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' docker.image('jenkins/ath').inside { - sh 'eval $(./vnc.sh > /dev/null 2>&1) && ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B' + sh 'eval $(./vnc.sh) && ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B' } diff --git a/vnc.sh b/vnc.sh index ea76be02d2..62b3aee268 100755 --- a/vnc.sh +++ b/vnc.sh @@ -9,6 +9,8 @@ fi vncserver -kill $display vncserver -geometry 1750x1250 $display > /dev/null -(vncviewer $display || vncviewer localhost$display) > /dev/null & +if command -v vncviewer >/dev/null 2>&1; then + (vncviewer $display || vncviewer localhost$display) > /dev/null & +fi echo export BROWSER_DISPLAY=$display From 69e8dff8890f5dc129b49bdcfa4df8d2f130748e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 4 Jan 2017 14:37:35 +0100 Subject: [PATCH 05/15] Delegate to docker.build step --- Jenkinsfile | 7 ++++++- docs/DOCKER.md | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5bdd2a4cb1..2ce4a81592 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,12 @@ node('highram&&docker') { ]) { changelog scm - sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' + def uid = sh returnStdout: true, script: "id -u | tr -d '\n'" + def gid = sh returnStdout: true, script: "id -g | tr -d '\n'" + + def buildArgs = "--build-arg=uid=${uid} --build-arg=gid=${gid} src/main/resources/ath-container" + docker.build('jenkins/ath', buildArgs) + String containerArgs = '-v /var/run/docker.sock:/var/run/docker.sock' docker.image('jenkins/ath').inside(containerArgs) { sh ''' diff --git a/docs/DOCKER.md b/docs/DOCKER.md index e3cce3f30b..c6be671ed1 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -14,7 +14,10 @@ Interactive shell: Jenkinsfile: ... // Checkout ATH - sh 'docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container' + def uid = sh returnStdout: true, script: "id -u | tr -d '\n'" + def gid = sh returnStdout: true, script: "id -g | tr -d '\n'" + def buildArgs = "--build-arg=uid=${uid} --build-arg=gid=${gid} src/main/resources/ath-container" + docker.build('jenkins/ath', buildArgs) docker.image('jenkins/ath').inside { sh 'eval $(./vnc.sh) && ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B' } From c8326ccc2c11ae5f1feaade77f5c7702c95971b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Thu, 13 Apr 2017 21:46:35 +0200 Subject: [PATCH 06/15] Skip tests explicitly requesting plugins not in update center When ATH is run against downstream update center with plugins missing, the tests will be correctly skipped. This also permits upstream tests for plugins that are not distributed in upstream UC while they are in the downstream one. --- .../acceptance/update_center/UpdateCenterMetadata.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/test/acceptance/update_center/UpdateCenterMetadata.java b/src/main/java/org/jenkinsci/test/acceptance/update_center/UpdateCenterMetadata.java index 1df9d17600..92767bfdc8 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/update_center/UpdateCenterMetadata.java +++ b/src/main/java/org/jenkinsci/test/acceptance/update_center/UpdateCenterMetadata.java @@ -17,6 +17,7 @@ import java.util.Map; import org.jenkinsci.test.acceptance.po.Jenkins; +import org.junit.internal.AssumptionViolatedException; /** * Databinding for Update Center metadata @@ -78,7 +79,11 @@ public List transitiveDependenciesOf(Jenkins jenkins, Collection List set = new ArrayList<>(); for (PluginSpec n : plugins) { PluginMetadata p = this.plugins.get(n.getName()); - if (p==null) throw new IllegalArgumentException("No such plugin " + n.getName()); + if (p==null) { + // The plugin explicitly requested is not available in the configured update center + // Skipping the test since it can happen for both upstream and downstream update centers + throw new AssumptionViolatedException("No such plugin " + n.getName()); + } if (p.requiredCore().isNewerThan(jenkins.getVersion())) { throw new UnableToResolveDependencies(String.format( "Unable to install %s plugin because of core dependency. Required: %s Used: %s", From 8658c141c0fe820008347ed7d1db66a75afcfe0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Fri, 14 Apr 2017 12:34:06 +0200 Subject: [PATCH 07/15] Let's see if highram have docker installed --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2ce4a81592..ded129e9bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ def mavenName = 'mvn' def jdkName = 'jdk8' -node('highram&&docker') { +node('highram') { withEnv([ "JAVA_HOME=${tool jdkName}", "PATH+MAVEN=${tool mavenName}/bin:${env.JAVA_HOME}/bin" From 327c293e107b1f7515fa67f022e96573ec8963de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Fri, 14 Apr 2017 12:41:12 +0200 Subject: [PATCH 08/15] Address some of the Jesse's comments --- Jenkinsfile | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ded129e9bd..532953b23f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,26 +5,21 @@ def mavenName = 'mvn' def jdkName = 'jdk8' node('highram') { - withEnv([ - "JAVA_HOME=${tool jdkName}", - "PATH+MAVEN=${tool mavenName}/bin:${env.JAVA_HOME}/bin" - ]) { - changelog scm + changelog scm - def uid = sh returnStdout: true, script: "id -u | tr -d '\n'" - def gid = sh returnStdout: true, script: "id -g | tr -d '\n'" + def uid = sh returnStdout: true, script: "id -u | tr -d '\n'" + def gid = sh returnStdout: true, script: "id -g | tr -d '\n'" - def buildArgs = "--build-arg=uid=${uid} --build-arg=gid=${gid} src/main/resources/ath-container" - docker.build('jenkins/ath', buildArgs) + def buildArgs = "--build-arg=uid=${uid} --build-arg=gid=${gid} src/main/resources/ath-container" + def image = docker.build('jenkins/ath', buildArgs) - String containerArgs = '-v /var/run/docker.sock:/var/run/docker.sock' - docker.image('jenkins/ath').inside(containerArgs) { - sh ''' - eval $(./vnc.sh) - ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B - ''' - } - - junit 'target/surefire-reports/TEST-*.xml' + String containerArgs = '-v /var/run/docker.sock:/var/run/docker.sock' + image.inside(containerArgs) { + sh ''' + eval $(./vnc.sh) + ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B + ''' } + + junit 'target/surefire-reports/TEST-*.xml' } From f89e31276dc0f60be79d088b74d890e633ab0561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Fri, 14 Apr 2017 12:41:59 +0200 Subject: [PATCH 09/15] highram label does not seem to be present --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 532953b23f..289f0903f3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ def mavenName = 'mvn' def jdkName = 'jdk8' -node('highram') { +node('docker') { changelog scm def uid = sh returnStdout: true, script: "id -u | tr -d '\n'" From 828ea258324c8dcc22305871410347a65d6c2952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Fri, 14 Apr 2017 12:43:21 +0200 Subject: [PATCH 10/15] Silly typo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 289f0903f3..e5e0a0c27d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ def mavenName = 'mvn' def jdkName = 'jdk8' node('docker') { - changelog scm + checkout scm def uid = sh returnStdout: true, script: "id -u | tr -d '\n'" def gid = sh returnStdout: true, script: "id -g | tr -d '\n'" From b2261ba2c61addc02f53d03560e811c37b866373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 19 Apr 2017 10:38:29 +0200 Subject: [PATCH 11/15] Do not duplicate the Jenkins file in documentation --- docs/DOCKER.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/docs/DOCKER.md b/docs/DOCKER.md index c6be671ed1..508f488d6f 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -13,11 +13,4 @@ Interactive shell: Jenkinsfile: - ... // Checkout ATH - def uid = sh returnStdout: true, script: "id -u | tr -d '\n'" - def gid = sh returnStdout: true, script: "id -g | tr -d '\n'" - def buildArgs = "--build-arg=uid=${uid} --build-arg=gid=${gid} src/main/resources/ath-container" - docker.build('jenkins/ath', buildArgs) - docker.image('jenkins/ath').inside { - sh 'eval $(./vnc.sh) && ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B' - } +See the repository `Jenkinsfile` for inspiration. From 197f522d959c17eaa2ec3947ec67c54705c8c89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 19 Apr 2017 11:29:34 +0200 Subject: [PATCH 12/15] Do not waste time installing docker daemon --- src/main/resources/ath-container/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/ath-container/Dockerfile b/src/main/resources/ath-container/Dockerfile index 2488be0de1..ab809f4fd4 100644 --- a/src/main/resources/ath-container/Dockerfile +++ b/src/main/resources/ath-container/Dockerfile @@ -9,7 +9,6 @@ MAINTAINER ogondza@gmail.com RUN apt-get -y update && \ apt-get install -y \ curl \ - docker.io \ imagemagick \ iptables \ firefox-esr \ @@ -17,6 +16,10 @@ RUN apt-get -y update && \ openjdk-8-jdk \ vnc4server +# All we need is a statically linked client library - no need to install daemon deps: https://get.docker.com/builds/ +RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz && \ + tar --strip-components=1 -xvzf docker-17.04.0-ce.tgz -C /usr/local/bin + # Allow injecting uid and git to match directory ownership ARG uid=1000 ENV uid $uid From da824c4eb6438dbe37e43d83ddebce59a3de492e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Wed, 19 Apr 2017 12:18:43 +0200 Subject: [PATCH 13/15] Expose VNC port and avoid xauth warning --- docs/DOCKER.md | 2 +- src/main/resources/ath-container/Dockerfile | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/DOCKER.md b/docs/DOCKER.md index 508f488d6f..7d567480c7 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -7,7 +7,7 @@ TO-DO: Instead of depending on setting this environment variable, in the future Interactive shell: $ docker build --build-arg=uid=$(id -u) --build-arg=gid=$(id -g) -t jenkins/ath src/main/resources/ath-container - $ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home/ath-user/ath --user ath-user jenkins/ath bash -c 'cd $HOME/ath && bash' + $ docker run -it --rm -P -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/home/ath-user/ath --user ath-user jenkins/ath bash -c 'cd $HOME/ath && bash' $ eval $(./vnc.sh) $ ./run.sh firefox latest -Dmaven.test.failure.ignore=true -DforkCount=1 -B diff --git a/src/main/resources/ath-container/Dockerfile b/src/main/resources/ath-container/Dockerfile index ab809f4fd4..91d31dc7f8 100644 --- a/src/main/resources/ath-container/Dockerfile +++ b/src/main/resources/ath-container/Dockerfile @@ -1,9 +1,9 @@ # Dockerfile to be used to run ATH itself. # # see docs/DOCKER.md for usage -# -FROM debian:sid + +FROM debian:stretch MAINTAINER ogondza@gmail.com RUN apt-get -y update && \ @@ -26,6 +26,8 @@ ENV uid $uid ARG gid=1000 ENV gid $gid +EXPOSE 5942 + # So it is owned by root and has the permissions vncserver seems to require: RUN mkdir /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix/ @@ -39,6 +41,8 @@ USER ath-user RUN mkdir /home/ath-user/.vnc && (echo ath-user; echo ath-user) | vncpasswd /home/ath-user/.vnc/passwd # Default content includes x-window-manager, which is not installed, plus other stuff we do not need (vncconfig, x-terminal-emulator, etc.): RUN touch /home/ath-user/.vnc/xstartup && chmod a+x /home/ath-user/.vnc/xstartup +# Prevent xauth to complain in a confusing way +RUN touch /home/ath-user/.Xauthority # Set SUID and SGID for docker binary so it can communicate with mapped socket its uid:gid we can not control. Alternative # approach used for this is adding ath-user to the group of /var/run/docker.sock but that require root permission we do not From cc60e6685214a0a0210e3e94b54d86372dce83e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Fri, 21 Apr 2017 09:22:22 +0200 Subject: [PATCH 14/15] Add unzip and git into ATH container --- src/main/resources/ath-container/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/ath-container/Dockerfile b/src/main/resources/ath-container/Dockerfile index 91d31dc7f8..cedefe72ac 100644 --- a/src/main/resources/ath-container/Dockerfile +++ b/src/main/resources/ath-container/Dockerfile @@ -9,11 +9,13 @@ MAINTAINER ogondza@gmail.com RUN apt-get -y update && \ apt-get install -y \ curl \ + git \ imagemagick \ iptables \ firefox-esr \ maven \ openjdk-8-jdk \ + unzip \ vnc4server # All we need is a statically linked client library - no need to install daemon deps: https://get.docker.com/builds/ From 46ef7eac0fcc6f0af54f1eb30a31f5171ef0ce01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Fri, 21 Apr 2017 11:28:35 +0200 Subject: [PATCH 15/15] Avoid random failures of `apt-get update` --- src/main/resources/ath-container/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/ath-container/Dockerfile b/src/main/resources/ath-container/Dockerfile index cedefe72ac..a05cecd5c3 100644 --- a/src/main/resources/ath-container/Dockerfile +++ b/src/main/resources/ath-container/Dockerfile @@ -6,7 +6,8 @@ FROM debian:stretch MAINTAINER ogondza@gmail.com -RUN apt-get -y update && \ +RUN apt-get clean && \ + apt-get -y update && \ apt-get install -y \ curl \ git \