This repository has been archived by the owner on May 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.template
74 lines (59 loc) · 2.77 KB
/
Dockerfile.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# We install each tool (e.g., Terraform, Terragrunt, and the AWS CLI) in a
# separate build stage. This design allows us to install each tool in parallel
# while preventing a change to one layer from blowing away the cache of
# subsequent layers.
# https://docs.docker.com/build/building/multi-stage/
FROM debian:bullseye-slim AS terraform-builder
# These args support multi-platform builds if we decide to produce a linux/arm64
# variant.
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/#93cb
ARG TARGETOS
ARG TARGETARCH
ENV TERRAFORM_VERSION="%%TERRAFORM_VERSION%%"
RUN set -ex \
&& apt-get update && apt-get install -y ca-certificates curl unzip --no-install-recommends \
&& curl "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${TARGETOS}_${TARGETARCH}.zip" -o "terraform.zip" \
&& unzip terraform.zip \
&& mv terraform /usr/local/bin/
FROM debian:bullseye-slim AS terragrunt-builder
ARG TARGETOS
ARG TARGETARCH
ENV TERRAGRUNT_VERSION="%%TERRAGRUNT_VERSION%%"
RUN set -ex \
&& apt-get update && apt-get install -y ca-certificates curl --no-install-recommends \
&& curl -L "https://github.com/gruntwork-io/terragrunt/releases/download/${TERRAGRUNT_VERSION}/terragrunt_${TARGETOS}_${TARGETARCH}" -o "terragrunt" \
&& chmod +x terragrunt \
&& mv terragrunt /usr/local/bin/
FROM debian:bullseye-slim AS awscli2-builder
ARG TARGETOS
ARG TARGETARCH
ENV AWSCLI_VERSION="%%AWSCLI_VERSION%%"
RUN set -ex \
&& apt-get update && apt-get install -y ca-certificates curl unzip --no-install-recommends \
&& curl "https://awscli.amazonaws.com/awscli-exe-${TARGETOS}-$(echo $TARGETARCH | sed s/amd64/x86_64/)-${AWSCLI_VERSION}.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
# The --bin-dir is specified so that we can copy the entire bin directory
# from the installer stage into into /usr/local/bin of the final stage
# without accidentally copying over any other executables that may be
# present in /usr/local/bin of the installer stage.
&& ./aws/install --bin-dir /aws-cli-bin/
FROM debian:bullseye-slim
RUN set -ex \
&& deps=" \
ca-certificates \
groff-base \
less \
git \
openssh-client \
jq \
" \
&& apt-get update && apt-get install -y $deps --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Install Terraform.
COPY --from=terraform-builder /usr/local/bin/terraform /usr/local/bin/terraform
# Install Terragrunt.
COPY --from=terragrunt-builder /usr/local/bin/terragrunt /usr/local/bin/terragrunt
# Install the AWS CLI version 2.
COPY --from=awscli2-builder /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=awscli2-builder /aws-cli-bin/ /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/terraform"]