|
1 | | -ARG RUNTIME_IMAGE=gcr.io/distroless/cc-debian12 |
2 | 1 | ARG BUILDPLATFORM=linux/amd64 |
| 2 | +ARG RUNTIME_IMAGE="cr.l5d.io/linkerd/proxy-runtime:latest" |
| 3 | +ARG TARGETARCH |
3 | 4 |
|
4 | 5 | # Precompile key slow-to-build dependencies |
5 | 6 | FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS go-deps |
@@ -43,8 +44,33 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -mod=readonly ./pkg/... |
43 | 44 | COPY proxy-identity proxy-identity |
44 | 45 | RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -o /out/proxy-identity -mod=readonly -ldflags "-s -w" ./proxy-identity |
45 | 46 |
|
46 | | -FROM $RUNTIME_IMAGE AS runtime |
| 47 | +## build proxy-init |
| 48 | +FROM --platform=$BUILDPLATFORM ghcr.io/linkerd/dev:v48-go AS proxy-init |
| 49 | +WORKDIR /build |
| 50 | +ARG PROXY_INIT_REPO="linkerd/linkerd2-proxy-init" |
| 51 | +ARG PROXY_INIT_REF="proxy-init/v2.4.3" |
| 52 | +RUN --mount=type=secret,id=github \ |
| 53 | + export GITHUB_TOKEN_FILE=/run/secrets/github; \ |
| 54 | + git init --initial-branch=main . && \ |
| 55 | + git remote add origin https://github.com/${PROXY_INIT_REPO}.git && \ |
| 56 | + git fetch --depth 1 origin ${PROXY_INIT_REF} && \ |
| 57 | + git checkout --detach FETCH_HEAD |
| 58 | +RUN go mod download |
| 59 | +ARG TARGETARCH |
| 60 | +RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GO111MODULE=on \ |
| 61 | + go build -o /out/linkerd2-proxy-init -mod=readonly -ldflags "-s -w" -v ./proxy-init |
| 62 | + |
| 63 | +FROM $RUNTIME_IMAGE-$TARGETARCH AS runtime |
47 | 64 | LABEL org.opencontainers.image.source=https://github.com/linkerd/linkerd2 |
| 65 | + |
| 66 | +COPY --from=proxy-init /out/linkerd2-proxy-init /usr/lib/linkerd/linkerd2-proxy-init |
| 67 | +# Set sys caps for iptables utilities and proxy-init |
| 68 | +USER root |
| 69 | +RUN ["/usr/sbin/setcap", "cap_net_raw,cap_net_admin+eip", "/usr/sbin/xtables-legacy-multi"] |
| 70 | +RUN ["/usr/sbin/setcap", "cap_net_raw,cap_net_admin+eip", "/usr/sbin/xtables-nft-multi"] |
| 71 | +RUN ["/usr/sbin/setcap", "cap_net_raw,cap_net_admin+eip", "/usr/lib/linkerd/linkerd2-proxy-init"] |
| 72 | +USER 65534 |
| 73 | + |
48 | 74 | COPY --from=fetch /build/target/proxy/LICENSE /usr/lib/linkerd/LICENSE |
49 | 75 | COPY --from=fetch /build/proxy-version /usr/lib/linkerd/linkerd2-proxy-version.txt |
50 | 76 | COPY --from=fetch /build/linkerd2-proxy /usr/lib/linkerd/linkerd2-proxy |
|
0 commit comments