github.com/cilium/cilium@v1.16.2/images/operator/Dockerfile (about) 1 # Copyright Authors of Cilium 2 # SPDX-License-Identifier: Apache-2.0 3 4 ARG BASE_IMAGE=scratch 5 ARG GOLANG_IMAGE=docker.io/library/golang:1.22.7@sha256:4594271250150c1a322ed749abfd218e1a8c6eb1ade90872e325a664412e2037 6 ARG ALPINE_IMAGE=docker.io/library/alpine:3.20.1@sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0 7 ARG CILIUM_BUILDER_IMAGE=quay.io/cilium/cilium-builder:40a6366e1459a87c9bc45c6798c241cab66612c1@sha256:41f50fd628282eec0d506345bed3b42f01050f1e99fd3cfb500575ce358c3549 8 9 # BUILDPLATFORM is an automatic platform ARG enabled by Docker BuildKit. 10 # Represents the plataform where the build is happening, do not mix with 11 # TARGETARCH 12 FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} AS builder 13 14 # TARGETOS is an automatic platform ARG enabled by Docker BuildKit. 15 ARG TARGETOS 16 # TARGETARCH is an automatic platform ARG enabled by Docker BuildKit. 17 ARG TARGETARCH 18 # OPERATOR_VARIANT determines the target cloud provider to build the operator for. 19 ARG OPERATOR_VARIANT 20 # MODIFIERS are extra arguments to be passed to make at build time. 21 ARG MODIFIERS 22 23 WORKDIR /go/src/github.com/cilium/cilium 24 25 RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium \ 26 --mount=type=cache,target=/root/.cache \ 27 --mount=type=cache,target=/go/pkg \ 28 make GOARCH=${TARGETARCH} DESTDIR=/out/${TARGETOS}/${TARGETARCH} ${MODIFIERS} \ 29 build-container-${OPERATOR_VARIANT} install-container-binary-${OPERATOR_VARIANT} 30 31 # licenses-all is a "script" that executes "go run" so its ARCH should be set 32 # to the same ARCH specified in the base image of this Docker stage (BUILDARCH) 33 RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium \ 34 --mount=type=cache,target=/root/.cache \ 35 --mount=type=cache,target=/go/pkg \ 36 make GOARCH=${BUILDARCH} licenses-all && mv LICENSE.all /out/${TARGETOS}/${TARGETARCH} 37 38 # BUILDPLATFORM is an automatic platform ARG enabled by Docker BuildKit. 39 # Represents the plataform where the build is happening, do not mix with 40 # TARGETARCH 41 FROM --platform=${BUILDPLATFORM} ${ALPINE_IMAGE} AS certs 42 RUN apk --update add ca-certificates 43 44 # BUILDPLATFORM is an automatic platform ARG enabled by Docker BuildKit. 45 # Represents the plataform where the build is happening, do not mix with 46 # TARGETARCH 47 FROM --platform=${BUILDPLATFORM} ${GOLANG_IMAGE} AS gops 48 49 # build-gops.sh will build both archs at the same time 50 WORKDIR /go/src/github.com/cilium/cilium/images/runtime 51 RUN apt-get update && apt-get install -y binutils-aarch64-linux-gnu binutils-x86-64-linux-gnu 52 RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium \ 53 --mount=type=cache,target=/root/.cache \ 54 --mount=type=cache,target=/go/pkg \ 55 ./build-gops.sh 56 57 FROM ${BASE_IMAGE} AS release 58 # TARGETOS is an automatic platform ARG enabled by Docker BuildKit. 59 ARG TARGETOS 60 # TARGETARCH is an automatic platform ARG enabled by Docker BuildKit. 61 ARG TARGETARCH 62 ARG OPERATOR_VARIANT 63 LABEL maintainer="maintainer@cilium.io" 64 COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt 65 COPY --from=gops /out/${TARGETOS}/${TARGETARCH}/bin/gops /bin/gops 66 COPY --from=builder /out/${TARGETOS}/${TARGETARCH}/usr/bin/cilium-${OPERATOR_VARIANT} /usr/bin/cilium-${OPERATOR_VARIANT} 67 COPY --from=builder /out/${TARGETOS}/${TARGETARCH}/LICENSE.all /LICENSE.all 68 WORKDIR / 69 ENV GOPS_CONFIG_DIR=/ 70 CMD ["/usr/bin/cilium-${OPERATOR_VARIANT}"] 71 72 FROM --platform=${BUILDPLATFORM} ${CILIUM_BUILDER_IMAGE} AS debug-tools 73 74 # 75 # Cilium Operator debug image. 76 # 77 # Typical image bulids will stop above at the 'release' target, but 78 # developers follow this Dockerfile to the end. Starting from a release 79 # image, install delve debugger and wrap the cilium-operator binary calls 80 # with a script that automatically provisions the debugger on a 81 # dedicated port. 82 FROM release AS debug 83 # TARGETOS is an automatic platform ARG enabled by Docker BuildKit. 84 ARG TARGETOS 85 # TARGETARCH is an automatic platform ARG enabled by Docker BuildKit. 86 ARG TARGETARCH 87 ARG OPERATOR_VARIANT 88 ARG DEBUG_HOLD 89 ENV DEBUG_PORT=2346 90 ENV DEBUG_HOLD=${DEBUG_HOLD} 91 COPY --from=builder /out/${TARGETOS}/${TARGETARCH}/usr/bin/cilium-${OPERATOR_VARIANT} /usr/bin/cilium-${OPERATOR_VARIANT}-bin 92 COPY --from=debug-tools /go/bin/dlv /usr/bin/dlv 93 COPY --from=debug-tools /out/${TARGETOS}/${TARGETARCH}/bin/debug-wrapper /usr/bin/cilium-${OPERATOR_VARIANT}