DevOps Corner Indonesia - AWS Cli v2 Container Image (Alpine 3.17
& Python 3.10.10
)
Image name | Size |
---|---|
devopscorner/aws-cli:alpine-3.16 |
|
devopscorner/aws-cli:alpine3.16-2.11.0 |
|
devopscorner/aws-cli:alpine3.16-python3.10.10-2.11.0 |
$ export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
$ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
$ export AWS_DEFAULT_REGION=ap-southeast-1
## To set for all sessions
C:\> setx AWS_ACCESS_KEY_ID AKIAIOSFODNN7EXAMPLE
C:\> setx AWS_SECRET_ACCESS_KEY wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
C:\> setx AWS_DEFAULT_REGION ap-southeast-1
## To set for current session only
C:\> set AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
C:\> set AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
C:\> set AWS_DEFAULT_REGION=ap-southeast-1
PS C:\> $Env:AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
PS C:\> $Env:AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
PS C:\> $Env:AWS_DEFAULT_REGION="ap-southeast-1"
ARG ALPINE_VERSION=3.17
ARG AWS_CLI_VERSION=2.11.0
ENV CICD_VERSION="1.23"
ARG BUILD_DATE
ARG BUILD_VERSION
ARG GIT_COMMIT
ARG GIT_URL
ARG ALPINE_VERSION=3.17
### Builder ###
FROM python:3.10.10-alpine${ALPINE_VERSION} as builder
ARG AWS_CLI_VERSION=2.11.0
RUN apk add --no-cache git unzip groff build-base libffi-dev cmake
RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION:-2.11.0} 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.17"
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" \
cicd-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/