Repository: DataBiosphere/toil

Issue:
docker/Dockerfile.py contains errror in arm check ; not under test?
Credit to @mhpopescu 

https://github.com/DataBiosphere/toil/blob/b084951c38b00e7457a0a80073229748c6114233/docker/Dockerfile.py#L144

`[$TARGETARCH = amd64]` should be `[ $TARGETARCH = amd64 ]`; otherwise the test always fails and the arm64 route is always picked

As for testing, [`py36_appliance_build`](https://github.com/DataBiosphere/toil/blob/master/.gitlab-ci.yml#L108) calls `make push_docker` which does call `docker/Dockerfile.py` but the result is not checked

┆Issue is synchronized with this [Jira Task](https://ucsc-cgl.atlassian.net/browse/TOIL-1105)
┆friendlyId: TOIL-1105



Discussion:
Proof:

```
docker pull quay.io/ucsc_cgl/toil:5.6.0a1-b084951c38b00e7457a0a80073229748c6114233-py3.6
$ docker run quay.io/ucsc_cgl/toil:5.6.0a1-b084951c38b00e7457a0a80073229748c6114233-py3.6 /usr/local/bin/docker
standard_init_linux.go:228: exec user process caused: exec format error
```

Which can be turned into a test
So the net result of this is that we ship an ARM `docker` binary in the Toil appliance, which will cause trouble for anyone using Docker-in-Docker to e.g. run CWL workflows, right? And we never catch it because we run the CWL conformance tests (and all our CWL tests) either single-machine in our Kubernetes-based Gitlab runners, or against our Kubernetes cluster, and those all make CWL use Singularity. And when we run stuff on Mesos clusters, if we ever use Docker, we do it as sibling containers via a connection to the host daemon that gets mounted in, and the Python API.

Maybe the right test here is to add invoking the Docker binary to the Dockerfile step that adds it? Or will that just always pass because to even do the ARM builds we set up `binfmt-misc`?

Resolving patch:
diff --git a/docker/Dockerfile.py b/docker/Dockerfile.py
--- a/docker/Dockerfile.py
+++ b/docker/Dockerfile.py
@@ -75,6 +75,7 @@ def heredoc(s):
 motd = ''.join(l + '\\n\\\n' for l in motd.splitlines())
 
 print(heredoc('''
+    # We can't use a newwe Ubuntu until we no longer need Mesos
     FROM ubuntu:16.04
 
     ARG TARGETARCH
@@ -97,20 +98,17 @@ def heredoc(s):
         apt-get clean && \
         rm -rf /var/lib/apt/lists/*
 
-    RUN wget -q https://dl.google.com/go/go1.13.3.linux-$TARGETARCH.tar.gz && \
-        tar xf go1.13.3.linux-$TARGETARCH.tar.gz && \
-        rm go1.13.3.linux-$TARGETARCH.tar.gz && \
-        mv go/bin/* /usr/bin/ && \
-        mv go /usr/local/
-
-    # Build Singularity
+    # Install Singularity from a newer Debian.
+    # The dependencies it thinks it needs aren't really needed and aren't
+    # available here.
     RUN wget https://debian.osuosl.org/debian/pool/main/s/singularity-container/$(curl -sSL 'https://debian.osuosl.org/debian/pool/main/s/singularity-container/' | grep -o "singularity-container_3[^\\"]*$(if [ $TARGETARCH = amd64 ] ; then echo amd64 ; else echo arm64 ; fi).deb" | head -n1) && \
         (dpkg -i singularity-container_3*.deb || true) && \
         dpkg --force-depends --configure -a && \
         sed -i 's/containernetworking-plugins, //' /var/lib/dpkg/status && \
         sed -i 's!bind path = /etc/localtime!#bind path = /etc/localtime!g' /etc/singularity/singularity.conf && \
         mkdir -p /usr/local/libexec/toil && \
-        mv /usr/bin/singularity /usr/local/libexec/toil/singularity-real
+        mv /usr/bin/singularity /usr/local/libexec/toil/singularity-real \
+        && /usr/local/libexec/toil/singularity-real version
 
     RUN mkdir /root/.ssh && \
         chmod 700 /root/.ssh
@@ -141,9 +139,10 @@ def heredoc(s):
         && ln -s /home/s3am/bin/s3am /usr/local/bin/
 
     # Install statically linked version of docker client
-    RUN curl https://download.docker.com/linux/static/stable/$(if [$TARGETARCH = amd64] ; then echo x86_64 ; else echo aarch64 ; fi)/docker-18.06.1-ce.tgz \
+    RUN curl https://download.docker.com/linux/static/stable/$(if [ $TARGETARCH = amd64 ] ; then echo x86_64 ; else echo aarch64 ; fi)/docker-18.06.1-ce.tgz \
         | tar -xvzf - --transform='s,[^/]*/,,g' -C /usr/local/bin/ \
-        && chmod u+x /usr/local/bin/docker
+        && chmod u+x /usr/local/bin/docker \
+        && /usr/local/bin/docker -v
 
     # Fix for Mesos interface dependency missing on ubuntu
     RUN {pip} install protobuf==3.0.0


Test patch: