Skip to content

Commit

Permalink
Create a base image without gcloud and save one gb
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvolkmann committed Oct 25, 2024
1 parent 5743286 commit a0015bc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ jobs:
[ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "tag=${GITHUB_REF##*/}" >> $GITHUB_ENV || true
[ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true
- name: Build and push image
uses: docker/build-push-action@v5
- name: Build and push base image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.tag }}
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.tag }}-base
target: base

- name: Build and push gcloud image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ env.tag }}-gcloud
target: gcloud
32 changes: 18 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM python:3.11-slim
FROM python:3.11-slim AS base

ENV VERSION_CT=0.9.0 \
VERSION_HELM=3.12.3 \
CLOUD_SDK_VERSION=465.0.0

ENV PATH /google-cloud-sdk/bin:$PATH
VERSION_HELM=3.12.3

RUN set -x \
&& apt-get update \
Expand All @@ -17,15 +14,6 @@ RUN set -x \
openssh-client \
rsync \
&& rm -rf /var/lib/apt/lists/* \
&& curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& tar xzf google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& rm google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& 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 install gke-gcloud-auth-plugin \
&& rm -rf /google-cloud-sdk/.install/.backup \
&& gcloud --version \
&& curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash -s -- --version "v${VERSION_HELM}" \
&& helm plugin install https://github.com/databus23/helm-diff \
&& python3 -m pip install --disable-pip-version-check --no-cache-dir \
Expand All @@ -46,3 +34,19 @@ RUN set -x \
COPY ansible.cfg /etc/ansible/ansible.cfg

ENTRYPOINT []

FROM base AS gcloud

ENV CLOUD_SDK_VERSION=465.0.0

ENV PATH=/google-cloud-sdk/bin:$PATH

RUN curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& tar xzf google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& rm google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& 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 install gke-gcloud-auth-plugin \
&& rm -rf /google-cloud-sdk/.install/.backup \
&& gcloud --version \

0 comments on commit a0015bc

Please sign in to comment.