diff --git a/Dockerfile b/Dockerfile index bd92e4be1..0c1b4f184 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.23 as builder +FROM --platform=$BUILDPLATFORM golang:1.23 AS builder WORKDIR /workspace # Copy the Go Modules manifests @@ -28,25 +28,25 @@ ARG TARGETARCH RUN mkdir bin -FROM builder as apiserver-builder +FROM builder AS apiserver-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/ironcore-apiserver ./cmd/ironcore-apiserver -FROM builder as manager-builder +FROM builder AS manager-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/ironcore-controller-manager ./cmd/ironcore-controller-manager -FROM builder as machinepoollet-builder +FROM builder AS machinepoollet-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/machinepoollet ./poollet/machinepoollet/cmd/machinepoollet/main.go -FROM builder as machinebroker-builder +FROM builder AS machinebroker-builder # TODO: Remove irictl-machine once debug containers are more broadly available. RUN --mount=type=cache,target=/root/.cache/go-build \ @@ -54,20 +54,20 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/machinebroker ./broker/machinebroker/cmd/machinebroker/main.go && \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/irictl-machine ./irictl-machine/cmd/irictl-machine/main.go -FROM builder as irictl-machine-builder +FROM builder AS irictl-machine-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/irictl-machine ./irictl-machine/cmd/irictl-machine/main.go -FROM builder as volumepoollet-builder +FROM builder AS volumepoollet-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/volumepoollet ./poollet/volumepoollet/cmd/volumepoollet/main.go -FROM builder as volumebroker-builder +FROM builder AS volumebroker-builder # TODO: Remove irictl-volume once debug containers are more broadly available. RUN --mount=type=cache,target=/root/.cache/go-build \ @@ -75,20 +75,20 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/volumebroker ./broker/volumebroker/cmd/volumebroker/main.go && \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/irictl-volume ./irictl-volume/cmd/irictl-volume/main.go -FROM builder as irictl-volume-builder +FROM builder AS irictl-volume-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/irictl-volume ./irictl-volume/cmd/irictl-volume/main.go -FROM builder as bucketpoollet-builder +FROM builder AS bucketpoollet-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/bucketpoollet ./poollet/bucketpoollet/cmd/bucketpoollet/main.go -FROM builder as bucketbroker-builder +FROM builder AS bucketbroker-builder # TODO: Remove irictl-bucket once debug containers are more broadly available. RUN --mount=type=cache,target=/root/.cache/go-build \ @@ -96,7 +96,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/bucketbroker ./broker/bucketbroker/cmd/bucketbroker/main.go && \ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o bin/irictl-bucket ./irictl-bucket/cmd/irictl-bucket/main.go -FROM builder as irictl-bucket-builder +FROM builder AS irictl-bucket-builder RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ @@ -104,21 +104,21 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot as manager +FROM gcr.io/distroless/static:nonroot AS manager WORKDIR / COPY --from=manager-builder /workspace/bin/ironcore-controller-manager . USER 65532:65532 ENTRYPOINT ["/ironcore-controller-manager"] -FROM gcr.io/distroless/static:nonroot as apiserver +FROM gcr.io/distroless/static:nonroot AS apiserver WORKDIR / COPY --from=apiserver-builder /workspace/bin/ironcore-apiserver . USER 65532:65532 ENTRYPOINT ["/ironcore-apiserver"] -FROM gcr.io/distroless/static:nonroot as machinepoollet +FROM gcr.io/distroless/static:nonroot AS machinepoollet WORKDIR / COPY --from=machinepoollet-builder /workspace/bin/machinepoollet . USER 65532:65532 @@ -126,7 +126,7 @@ USER 65532:65532 ENTRYPOINT ["/machinepoollet"] # TODO: Switch to distroless as soon as ephemeral debug containers are more broadly available. -FROM debian:bullseye-slim as machinebroker +FROM debian:bullseye-slim AS machinebroker WORKDIR / COPY --from=machinebroker-builder /workspace/bin/machinebroker . # TODO: Remove irictl-machine as soon as ephemeral debug containers are more broadly available. @@ -135,12 +135,12 @@ USER 65532:65532 ENTRYPOINT ["/machinebroker"] -FROM debian:bullseye-slim as irictl-machine +FROM debian:bullseye-slim AS irictl-machine WORKDIR / COPY --from=irictl-machine-builder /workspace/bin/irictl-machine . USER 65532:65532 -FROM gcr.io/distroless/static:nonroot as volumepoollet +FROM gcr.io/distroless/static:nonroot AS volumepoollet WORKDIR / COPY --from=volumepoollet-builder /workspace/bin/volumepoollet . USER 65532:65532 @@ -148,7 +148,7 @@ USER 65532:65532 ENTRYPOINT ["/volumepoollet"] # TODO: Switch to distroless as soon as ephemeral debug containers are more broadly available. -FROM debian:bullseye-slim as volumebroker +FROM debian:bullseye-slim AS volumebroker WORKDIR / COPY --from=volumebroker-builder /workspace/bin/volumebroker . # TODO: Remove irictl-volume as soon as ephemeral debug containers are more broadly available. @@ -157,12 +157,12 @@ USER 65532:65532 ENTRYPOINT ["/volumebroker"] -FROM debian:bullseye-slim as irictl-volume +FROM debian:bullseye-slim AS irictl-volume WORKDIR / COPY --from=irictl-volume-builder /workspace/bin/irictl-volume . USER 65532:65532 -FROM gcr.io/distroless/static:nonroot as bucketpoollet +FROM gcr.io/distroless/static:nonroot AS bucketpoollet WORKDIR / COPY --from=bucketpoollet-builder /workspace/bin/bucketpoollet . USER 65532:65532 @@ -170,7 +170,7 @@ USER 65532:65532 ENTRYPOINT ["/bucketpoollet"] # TODO: Switch to distroless as soon as ephemeral debug containers are more broadly available. -FROM debian:bullseye-slim as bucketbroker +FROM debian:bullseye-slim AS bucketbroker WORKDIR / COPY --from=bucketbroker-builder /workspace/bin/bucketbroker . # TODO: Remove irictl-bucket as soon as ephemeral debug containers are more broadly available. @@ -179,7 +179,7 @@ USER 65532:65532 ENTRYPOINT ["/bucketbroker"] -FROM debian:bullseye-slim as irictl-bucket +FROM debian:bullseye-slim AS irictl-bucket WORKDIR / COPY --from=irictl-bucket-builder /workspace/bin/irictl-bucket . USER 65532:65532