diff --git a/docker-base/Dockerfile b/docker-base/Dockerfile index f05cb3f9a2..e9c0f4394f 100644 --- a/docker-base/Dockerfile +++ b/docker-base/Dockerfile @@ -17,21 +17,35 @@ RUN addgroup atlantis && \ chmod g=u /home/atlantis/ && \ chmod g=u /etc/passwd -# Install dumb-init, gosu and git-lfs. -ENV DUMB_INIT_VERSION=1.2.5 +# Install gosu and git-lfs. ENV GOSU_VERSION=1.14 ENV GIT_LFS_VERSION=3.1.2 -RUN apk add --no-cache ca-certificates gnupg curl git unzip bash openssh libcap openssl && \ - curl -L -s --output /bin/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_x86_64" && \ - chmod +x /bin/dumb-init && \ + +# Automatically populated with the architecture the image is being built for. +ARG TARGETPLATFORM + +# Install packages needed for running Atlantis. +RUN apk add --no-cache ca-certificates curl git unzip bash openssh libcap dumb-init && \ + # Install packages needed for building dependencies. + apk add --no-cache --virtual .build-deps gnupg openssl && \ mkdir -p /tmp/build && \ cd /tmp/build && \ - curl -L -s --output git-lfs.tar.gz "https://github.com/git-lfs/git-lfs/releases/download/v${GIT_LFS_VERSION}/git-lfs-linux-amd64-v${GIT_LFS_VERSION}.tar.gz" && \ + + # git-lfs + curl -L -s --output git-lfs.tar.gz "https://github.com/git-lfs/git-lfs/releases/download/v${GIT_LFS_VERSION}/git-lfs-linux-${TARGETPLATFORM##*/}-v${GIT_LFS_VERSION}.tar.gz" && \ tar -xf git-lfs.tar.gz && \ chmod +x git-lfs && \ mv git-lfs /usr/bin/git-lfs && \ - curl -L -s --output gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" && \ - curl -L -s --output gosu.asc "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc" && \ + git-lfs --version && \ + + # gosu + case ${TARGETPLATFORM} in \ + "linux/amd64") GOSU_ARCH=amd64 ;; \ + "linux/arm64") GOSU_ARCH=arm64 ;; \ + "linux/arm/v7") GOSU_ARCH=armhf ;; \ + esac && \ + curl -L -s --output gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}" && \ + curl -L -s --output gosu.asc "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}.asc" && \ for server in $(shuf -e ipv4.pool.sks-keyservers.net \ hkp://p80.pool.sks-keyservers.net:80 \ keyserver.ubuntu.com \ @@ -42,13 +56,15 @@ RUN apk add --no-cache ca-certificates gnupg curl git unzip bash openssh libcap gpg --batch --verify gosu.asc gosu && \ chmod +x gosu && \ cp gosu /bin && \ - cd /tmp && \ - rm -rf /tmp/build && \ - gpgconf --kill dirmngr && \ - gpgconf --kill gpg-agent && \ - apk del gnupg openssl && \ - rm -rf /root/.gnupg && \ - rm -rf /var/cache/apk/* + gosu --version && \ + + # Cleanup + cd /tmp && \ + rm -rf /tmp/build && \ + gpgconf --kill dirmngr && \ + gpgconf --kill gpg-agent && \ + apk del .build-deps && \ + rm -rf /root/.gnupg # Set up nsswitch.conf for Go's "netgo" implementation # - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275