Skip to content

Commit

Permalink
Refactor Dockerfile to use native docker features to target the speci…
Browse files Browse the repository at this point in the history
…fic image

Signed-off-by: Marco Franssen <[email protected]>
  • Loading branch information
marcofranssen committed Oct 29, 2024
1 parent 6994eb4 commit 18a08a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
include:
- name: cilium-cli
dockerfile: ./Dockerfile
platforms: linux/amd64

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
Expand Down Expand Up @@ -62,8 +64,9 @@ jobs:
with:
context: .
file: ${{ matrix.dockerfile }}
target: ${{ matrix.name }}
platforms: ${{ matrix.platforms }}
push: true
platforms: linux/amd64
tags: |
quay.io/${{ github.repository_owner }}/${{ matrix.name }}-ci:latest
quay.io/${{ github.repository_owner }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}
Expand All @@ -84,8 +87,9 @@ jobs:
with:
context: .
file: ${{ matrix.dockerfile }}
target: ${{ matrix.name }}
platforms: ${{ matrix.platforms }}
push: true
platforms: linux/amd64
tags: |
quay.io/${{ github.repository_owner }}/${{ matrix.name }}-ci:${{ steps.tag.outputs.tag }}
Expand Down
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +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.23.2-alpine3.19@sha256:f6392ffebb028fed5ffe743ddb9716e38402c978779edd66474bb5d05f5e65e4 AS builder
WORKDIR /go/src/github.com/cilium/cilium-cli
RUN apk add --no-cache curl git make ca-certificates
COPY . .
RUN make

# cilium-cli is from scratch only including cilium binaries
FROM scratch AS cilium-cli
ENTRYPOINT ["cilium"]
LABEL maintainer="[email protected]"
COPY --from=builder --chown=root:root --chmod=755 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/github.com/cilium/cilium-cli/cilium /usr/local/bin/cilium

# cilium-cli-ci is based on ubuntu with cloud CLIs
FROM ubuntu:24.04@sha256:99c35190e22d294cdace2783ac55effc69d32896daaa265f0bbedbcde4fbe3e5 AS cilium-cli-ci
ENTRYPOINT []
LABEL maintainer="[email protected]"
COPY --from=builder /go/src/github.com/cilium/cilium-cli/cilium /usr/local/bin/cilium

# Install cloud CLIs. Based on these instructions:
Expand All @@ -40,6 +39,4 @@ RUN apt-get update -y \
&& rm -r ./aws awscliv2.zip \
&& curl -sL https://aka.ms/InstallAzureCLIDeb | bash

FROM ${FINAL_CONTAINER}
LABEL maintainer="[email protected]"
WORKDIR /root/app

0 comments on commit 18a08a4

Please sign in to comment.