Skip to content

Instantly share code, notes, and snippets.

@nitrocode
Last active March 29, 2023 15:39
Show Gist options
  • Save nitrocode/62505b0623cd9bf27e4b39a3f98412f5 to your computer and use it in GitHub Desktop.
Save nitrocode/62505b0623cd9bf27e4b39a3f98412f5 to your computer and use it in GitHub Desktop.
Atlantis with awscli v2

Atlantis with awscli v2

Commands

Download the Dockerfile

wget https://gist.githubusercontent.com/nitrocode/62505b0623cd9bf27e4b39a3f98412f5/raw/Dockerfile

Build the container

ATLANTIS_VERSION=0.19.8
docker build -t atlantis-awscli2:${ATLANTIS_VERSION} --build-arg ATLANTIS_VERSION=${ATLANTIS_VERSION} .

Verify CLI versions match

$ docker run --rm -it --entrypoint aws atlantis-awscli2:${ATLANTIS_VERSION} --version
aws-cli/2.7.32 Python/3.10.7 Linux/5.10.104-linuxkit exe/aarch64.alpine.3 prompt/off
$ docker run --rm -it atlantis-awscli2:${ATLANTIS_VERSION} version
atlantis 0.19.8

References

# source: https://gist.github.com/nitrocode/62505b0623cd9bf27e4b39a3f98412f5
# https://github.com/runatlantis/atlantis/tags
ARG ATLANTIS_VERSION=0.19.8
# https://github.com/aws/aws-cli/tags
ARG AWS_CLI_VERSION=2.7.32
# https://hub.docker.com/_/python/tags?page=1&name=alpine
ARG PYTHON_ALPINE_VERSION=3.10.7-alpine3.16
FROM python:${PYTHON_ALPINE_VERSION} as builder
ARG AWS_CLI_VERSION
RUN apk add --no-cache \
git \
unzip \
groff \
build-base \
libffi-dev \
cmake \
&& git clone \
--single-branch \
--depth 1 \
-b ${AWS_CLI_VERSION} \
https://github.com/aws/aws-cli.git
WORKDIR /aws-cli
RUN python -m venv venv \
&& . venv/bin/activate \
&& scripts/installers/make-exe \
&& unzip -q dist/awscli-exe.zip \
&& aws/install --bin-dir /aws-cli-bin \
&& /aws-cli-bin/aws --version
# reduce image size: remove autocomplete and examples
RUN rm -rf \
/usr/local/aws-cli/v2/current/dist/aws_completer \
/usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \
/usr/local/aws-cli/v2/current/dist/awscli/examples \
&& find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data \
-name examples-1.json \
-delete
# build the final image
FROM ghcr.io/runatlantis/atlantis:v${ATLANTIS_VERSION}
COPY --from=builder /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=builder /aws-cli-bin/ /usr/local/bin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment