Files
atlantis/testing/Dockerfile
Jeppe Fihl-Pearson 124eb6b4a8 Use GitHub Actions cache when building Docker images (#2737)
* Use GitHub Actions cache when building Docker images

This firstly removes the `pull: true` option from all
`build-push-action` invocations, as it was assumed it caused Docker to
pull the existing image first before building the new one, where as it
instead makes sure the base image is up to date prior to starting the
build.

Instead the `cache-from` and `cache-to` options are added which cause
the action to store and retrieve caches for each layer from GitHub
Actions' cache system as documented at
https://docs.docker.com/build/ci/github-actions/examples/#cache-backend-api.

* Pin exact Go version in testing image

This matches what is done for the production image.
2022-12-04 21:16:57 -06:00

32 lines
1.7 KiB
Docker

FROM golang:1.19.3
RUN apt-get update && apt-get --no-install-recommends -y install unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Terraform
ENV TERRAFORM_VERSION=1.3.6
RUN case $(uname -m) in x86_64|amd64) ARCH="amd64" ;; aarch64|arm64|armv7l) ARCH="arm64" ;; esac && \
wget -nv -O terraform.zip https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_${ARCH}.zip && \
mkdir -p /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \
unzip terraform.zip -d /usr/local/bin/tf/versions/${TERRAFORM_VERSION} && \
ln -s /usr/local/bin/tf/versions/${TERRAFORM_VERSION}/terraform /usr/local/bin/terraform && \
rm terraform.zip
# Install conftest
ENV CONFTEST_VERSION=0.35.0
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN case $(uname -m) in x86_64|amd64) ARCH="x86_64" ;; aarch64|arm64|armv7l) ARCH="arm64" ;; esac && \
curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/conftest_${CONFTEST_VERSION}_Linux_${ARCH}.tar.gz && \
curl -LOs https://github.com/open-policy-agent/conftest/releases/download/v${CONFTEST_VERSION}/checksums.txt && \
sed -n "/conftest_${CONFTEST_VERSION}_Linux_${ARCH}.tar.gz/p" checksums.txt | sha256sum -c && \
mkdir -p /usr/local/bin/cft/versions/${CONFTEST_VERSION} && \
tar -C /usr/local/bin/cft/versions/${CONFTEST_VERSION} -xzf conftest_${CONFTEST_VERSION}_Linux_${ARCH}.tar.gz && \
ln -s /usr/local/bin/cft/versions/${CONFTEST_VERSION}/conftest /usr/local/bin/conftest${CONFTEST_VERSION} && \
rm conftest_${CONFTEST_VERSION}_Linux_${ARCH}.tar.gz && \
rm checksums.txt
RUN useradd -u 1001 -m atlantis
USER atlantis