Skip to content

Commit

Permalink
feat: minimize az/gcloud clis
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop authored Jul 14, 2024
1 parent a09a133 commit 0a1c2bd
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM ubuntu:jammy-20240227@sha256:77906da86b60585ce12215807090eb327e7386c8fafb5402369e421f44eff17e
FROM ubuntu:jammy-20240227@sha256:77906da86b60585ce12215807090eb327e7386c8fafb5402369e421f44eff17e as base
WORKDIR /app

ARG TARGETARCH

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y curl unzip ca-certificates zip tzdata wget gnupg2 bzip2 apt-transport-https lsb-release git --no-install-recommends && \
apt-get install -y curl unzip ca-certificates zip tzdata wget gnupg2 bzip2 apt-transport-https lsb-release git python3-crcmod python3-openssl --no-install-recommends && \
apt-get clean

RUN apt-get update && apt-get upgrade -y && \
Expand All @@ -18,6 +18,41 @@ RUN curl -sLS https://get.arkade.dev | sh && \
arkade get kubectl stern jq yq --path /usr/bin && \
chmod +x /usr/bin/kubectl /usr/bin/stern /usr/bin/jq /usr/bin/yq

# Minimalized Google cloud sdk
FROM base as gcloud-installer

ENV GCLOUD_PATH=/opt/google-cloud-sdk
ENV PATH $GCLOUD_PATH/bin:$PATH
ENV CLOUDSDK_PYTHON=/usr/bin/python3
# Download and install cloud sdk. Review the components I install, you may not need them.
RUN GCLOUDCLI_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz" && \
if [ "${TARGETARCH}" = "arm64" ]; then \
GCLOUDCLI_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-arm.tar.gz"; \
fi && \
curl $GCLOUDCLI_URL -o gcloud.tar.gz && \
tar xzf gcloud.tar.gz -C /opt && \
rm gcloud.tar.gz && \
rm -rf $GCLOUD_PATH/platform/bundledpythonunix && \
gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment github_docker_image && \
gcloud components remove -q bq && \
gcloud components install -q beta kubectl-oidc gke-gcloud-auth-plugin && \
rm -rf $(find $GCLOUD_PATH/ -regex ".*/__pycache__") && \
rm -rf $GCLOUD_PATH/.install/.backup && \
rm -rf $GCLOUD_PATH/bin/anthoscli && \
gcloud --version


FROM base as final

ENV PATH /google-cloud-sdk/bin:$PATH
ENV CLOUDSDK_PYTHON=/usr/bin/python3
copy --from=gcloud-installer /opt/google-cloud-sdk /opt/google-cloud-sdk
# This is to be able to update gcloud packages
RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh


# Azure CLI
RUN mkdir -p /etc/apt/keyrings && \
curl -sLS https://packages.microsoft.com/keys/microsoft.asc | \
Expand All @@ -27,20 +62,17 @@ RUN mkdir -p /etc/apt/keyrings && \
cat /etc/apt/sources.list.d/azure-cli.list && \
apt-get update && \
apt-get install -y azure-cli && \
apt-get clean
apt-get clean && \
rm -rf $(find /opt/az -regex ".*/__pycache__") && \
az version

# AWS CLI
RUN AWSCLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
if [ "${TARGETARCH}" = "arm64" ]; then \
AWSCLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip"; \
fi && \
curl "${AWSCLI_URL}" -o "awscliv2.zip" && \
unzip -q awscliv2.zip && ./aws/install -i /aws -b /usr/bin/ && \
rm awscliv2.zip

# GCP CLI
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg && \
apt-get update -y && \
apt-get install google-cloud-sdk google-cloud-cli google-cloud-cli-kubectl-oidc google-cloud-sdk-gke-gcloud-auth-plugin -y && \
apt-get clean
unzip -q awscliv2.zip && ./aws/install -i /opt/aws -b /usr/bin/ && \
rm awscliv2.zip && \
rm -rf ./aws && \
aws --version

0 comments on commit 0a1c2bd

Please sign in to comment.