Skip to content

Instantly share code, notes, and snippets.

@zeroc0d3
Created December 8, 2022 23:03
Show Gist options
  • Save zeroc0d3/17d6b2fcec9d35bd0c552f6036b76339 to your computer and use it in GitHub Desktop.
Save zeroc0d3/17d6b2fcec9d35bd0c552f6036b76339 to your computer and use it in GitHub Desktop.
Dockerfile for AWSCli v2.x (Alpine 3.16)
ARG BUILD_DATE
ARG BUILD_VERSION
ARG GIT_COMMIT
ARG GIT_URL
ARG ALPINE_VERSION=3.16
### Builder ###
FROM python:3.10.5-alpine${ALPINE_VERSION} as builder
ARG AWS_CLI_VERSION=2.9.1
RUN apk add --no-cache git unzip groff build-base libffi-dev cmake
RUN 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
RUN . venv/bin/activate
RUN scripts/installers/make-exe
RUN unzip -q dist/awscli-exe.zip
RUN aws/install --bin-dir /aws-cli-bin
RUN /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
RUN find /usr/local/aws-cli/v2/current/dist/awscli/data -name completions-1*.json -delete
RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete
### Binary ###
FROM alpine:${ALPINE_VERSION}
ENV VENDOR="DevOpsCornerId"
ENV AUTHOR="DevOpsCorner.id <[email protected]>"
ENV IMG_NAME="awscli-alpine"
ENV IMG_VERSION="3.16"
ENV IMG_DESC="Docker Image AWS CLI Alpine"
ENV IMG_ARCH="amd64/x86_64"
ENV CICD_VERSION="1.23"
LABEL maintainer="$AUTHOR" \
architecture="$IMG_ARCH" \
alpine-version="$ALPINE_VERSION" \
aws-cli-version="$CICD_VERSION" \
org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.name="$IMG_NAME" \
org.label-schema.description="$IMG_DESC" \
org.label-schema.vcs-ref="$GIT_COMMIT" \
org.label-schema.vcs-url="$GIT_URL" \
org.label-schema.vendor="$VENDOR" \
org.label-schema.version="$BUILD_VERSION" \
org.label-schema.schema-version="$IMG_VERSION" \
org.opencontainers.image.authors="$AUTHOR" \
org.opencontainers.image.description="$IMG_DESC" \
org.opencontainers.image.vendor="$VENDOR" \
org.opencontainers.image.version="$IMG_VERSION" \
org.opencontainers.image.revision="$GIT_COMMIT" \
org.opencontainers.image.created="$BUILD_DATE" \
fr.hbis.docker.base.build-date="$BUILD_DATE" \
fr.hbis.docker.base.name="$IMG_NAME" \
fr.hbis.docker.base.vendor="$VENDOR" \
fr.hbis.docker.base.version="$BUILD_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