Skip to content

Instantly share code, notes, and snippets.

@4c74356b41
Last active February 8, 2021 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4c74356b41/ba9f905ec4c532049aec2549c48b471b to your computer and use it in GitHub Desktop.
Save 4c74356b41/ba9f905ec4c532049aec2549c48b471b to your computer and use it in GitHub Desktop.
helmfile\helm\kubectl\kustomize\azure cli\terraform
# Setup build arguments with default versions
ARG TERRAFORM_VERSION=0.13.2
ARG KUBE_VERSION=v1.18.9
ARG HELM_VERSION=v3.4.0
ARG HELMFILE_VERSION=v0.132.1
ARG AZURE_CLI_VERSION=2.15.1
ARG PYTHON_MAJOR_VERSION=3.7
ARG KUSTOMIZE_VERSION=v3.8.1
# Download Terraform\Kubectl\Helm binaries
FROM debian:buster-slim as binaries
ARG TERRAFORM_VERSION
ARG KUBE_VERSION
ARG HELM_VERSION
RUN apt-get update
RUN apt-get install --no-install-recommends -y curl=7.64.0-4+deb10u1
RUN apt-get install --no-install-recommends -y ca-certificates=20190110
RUN apt-get install --no-install-recommends -y unzip=6.0-23+deb10u1
RUN apt-get install --no-install-recommends -y gnupg=2.2.12-1+deb10u1
RUN apt-get install --no-install-recommends -y wget
RUN curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS
RUN curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
RUN curl -Os https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig
RUN wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl
RUN wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm
COPY hashicorp.asc hashicorp.asc
RUN gpg --import hashicorp.asc
RUN gpg --verify terraform_${TERRAFORM_VERSION}_SHA256SUMS.sig terraform_${TERRAFORM_VERSION}_SHA256SUMS
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN grep terraform_${TERRAFORM_VERSION}_linux_amd64.zip terraform_${TERRAFORM_VERSION}_SHA256SUMS | sha256sum -c -
RUN unzip -j terraform_${TERRAFORM_VERSION}_linux_amd64.zip
# Install az CLI using PIP
FROM debian:buster-slim as azure-cli
ARG AZURE_CLI_VERSION
ARG PYTHON_MAJOR_VERSION
RUN apt-get update
RUN apt-get install -y --no-install-recommends python3=${PYTHON_MAJOR_VERSION}.3-1 python3-dev=${PYTHON_MAJOR_VERSION}.3-1 gcc
RUN apt-get install -y --no-install-recommends python3-pip=18.1-5
RUN pip3 install --upgrade pip
RUN pip3 install setuptools==50.3.2
RUN pip3 install azure-cli==${AZURE_CLI_VERSION}
# Layer to get helmfile stuff
FROM quay.io/roboll/helmfile:${HELMFILE_VERSION} as helmfile
ARG KUSTOMIZE_VERSION
RUN curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz | \
tar zxv && mv kustomize /usr/local/bin
# Build final image
FROM mcr.microsoft.com/powershell:lts-debian-buster-slim
WORKDIR /ci
ENV XDG_DATA_HOME=/home
ARG PYTHON_MAJOR_VERSION
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git=1:2.20.1-2+deb10u3 \
python3=${PYTHON_MAJOR_VERSION}.3-1 \
python3-distutils=${PYTHON_MAJOR_VERSION}.3-1 \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_MAJOR_VERSION} 1
COPY --from=binaries /terraform /usr/local/bin/terraform
COPY --from=binaries /usr/local/bin/helm /usr/local/bin/helm
COPY --from=binaries /usr/local/bin/kubectl /usr/local/bin/kubectl
COPY --from=helmfile /usr/local/bin/helmfile /usr/local/bin
COPY --from=helmfile /usr/local/bin/kustomize /usr/local/bin
COPY --from=helmfile /root/.helm/cache/plugins/ /home/helm/plugins
COPY --from=azure-cli /usr/local/bin/az* /usr/local/bin/
COPY --from=azure-cli /usr/local/lib/python${PYTHON_MAJOR_VERSION}/dist-packages /usr/local/lib/python${PYTHON_MAJOR_VERSION}/dist-packages
COPY --from=azure-cli /usr/lib/python3/dist-packages /usr/lib/python3/dist-packages
RUN chmod +x /usr/local/bin/helmfile /usr/local/bin/helm /usr/local/bin/kubectl /usr/local/bin/kustomize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment