diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index bbd5865985..3d91745b2c 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -67,7 +67,9 @@ jobs: context: . file: ${{ matrix.dockerfile }} push: true - platforms: linux/amd64 + platforms: ${{ matrix.platforms }} + build-args: | + FINAL_CONTAINER=${{ matrix.name }} tags: | quay.io/${{ github.repository_owner }}/${{ matrix.name }}:latest quay.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ steps.tag.outputs.tag }} @@ -90,6 +92,8 @@ jobs: file: ${{ matrix.dockerfile }} push: true platforms: ${{ matrix.platforms }} + build-args: | + FINAL_CONTAINER=${{ matrix.name }} tags: | quay.io/${{ github.repository_owner }}/${{ matrix.name }}:${{ steps.tag.outputs.tag }} diff --git a/Dockerfile b/Dockerfile index 19c1a8becd..27e96b3a43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,15 +3,23 @@ # Copyright Authors of Cilium # SPDX-License-Identifier: Apache-2.0 +# FINAL_CONTAINER specifies the source for the output +# cilium-cli-ci (default) is based on ubuntu with cloud CLIs +# cilium-cli is from scratch only including cilium binaries +ARG FINAL_CONTAINER="cilium-cli-ci" + FROM docker.io/library/golang:1.22.6-alpine3.19@sha256:1bad39361dd21f2f881ce10ff810e40e5be3eba89a0b61e762e05ec42f9bbaf2 AS builder WORKDIR /go/src/github.com/cilium/cilium-cli RUN apk add --no-cache git make ca-certificates COPY . . RUN make -FROM ubuntu:24.04@sha256:8a37d68f4f73ebf3d4efafbcf66379bf3728902a8038616808f04e34a9ab63ee +FROM scratch AS cilium-cli +LABEL maintainer="maintainer@cilium.io" +COPY --from=builder /go/src/github.com/cilium/cilium-cli/cilium /usr/local/bin/cilium + +FROM ubuntu:24.04@sha256:8a37d68f4f73ebf3d4efafbcf66379bf3728902a8038616808f04e34a9ab63ee AS cilium-cli-ci LABEL maintainer="maintainer@cilium.io" -WORKDIR /root/app COPY --from=builder /go/src/github.com/cilium/cilium-cli/cilium /usr/local/bin/cilium # Install cloud CLIs. Based on these instructions: @@ -31,4 +39,8 @@ RUN apt-get update -y \ && rm -r ./aws awscliv2.zip \ && curl -sL https://aka.ms/InstallAzureCLIDeb | bash +# Select the layer to provide the final container image from +FROM ${FINAL_CONTAINER} +LABEL maintainer="maintainer@cilium.io" +WORKDIR /root/app ENTRYPOINT [] diff --git a/Dockerfile-cli-only b/Dockerfile-cli-only deleted file mode 100644 index f8a46bdc8c..0000000000 --- a/Dockerfile-cli-only +++ /dev/null @@ -1,16 +0,0 @@ -# syntax=docker/dockerfile:1.9@sha256:fe40cf4e92cd0c467be2cfc30657a680ae2398318afd50b0c80585784c604f28 - -# Copyright Authors of Cilium -# SPDX-License-Identifier: Apache-2.0 - -FROM docker.io/library/golang:1.22.6-alpine3.19@sha256:1bad39361dd21f2f881ce10ff810e40e5be3eba89a0b61e762e05ec42f9bbaf2 AS builder -WORKDIR /go/src/github.com/cilium/cilium-cli -RUN apk add --no-cache git make ca-certificates -COPY . . -RUN make - -FROM scratch -LABEL maintainer="maintainer@cilium.io" -COPY --from=builder /go/src/github.com/cilium/cilium-cli/cilium /usr/local/bin/cilium -ENTRYPOINT [] -