Skip to content

Commit

Permalink
Build desired target with a buildargument
Browse files Browse the repository at this point in the history
This way we are not diverging in multiple dockerfiles and we can choose between two targets:
- cilium-cli-ci The original target based on ubuntu and the default
- cilium-cli Only contains the cilium cli based on scratch

Fixes: cilium#2755

Signed-off-by: Merijn Keppel <[email protected]>
  • Loading branch information
leppeK committed Aug 22, 2024
1 parent d24e654 commit bddd984
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]"
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="[email protected]"
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:
Expand All @@ -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="[email protected]"
WORKDIR /root/app
ENTRYPOINT []
16 changes: 0 additions & 16 deletions Dockerfile-cli-only

This file was deleted.

0 comments on commit bddd984

Please sign in to comment.