-
Notifications
You must be signed in to change notification settings - Fork 32
/
Dockerfile-cni-plugin
54 lines (50 loc) · 1.91 KB
/
Dockerfile-cni-plugin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# syntax=docker/dockerfile:1.4
# Cross compile from native platform to target arch
FROM --platform=$BUILDPLATFORM golang:1.23-alpine as go
WORKDIR /build
COPY --link go.mod go.sum ./
COPY --link ./cni-plugin ./cni-plugin
COPY --link ./proxy-init ./proxy-init
COPY --link ./pkg ./pkg
RUN go mod download
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GO111MODULE=on \
go build -o /go/bin/linkerd-cni -mod=readonly -ldflags "-s -w" -v ./cni-plugin/
FROM --platform=$BUILDPLATFORM ghcr.io/linkerd/dev:v43-rust-musl as cni-repair-controller
WORKDIR /build
COPY --link justfile justfile-rust .
COPY --link Cargo.toml Cargo.lock .
COPY --link validator validator
COPY --link cni-repair-controller cni-repair-controller
RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo fetch
ARG TARGETARCH
# Enable tokio runtime metrics
ENV RUSTFLAGS="--cfg tokio_unstable"
RUN --mount=type=cache,target=target \
--mount=type=cache,target=/usr/local/cargo/registry \
target=$(case "$TARGETARCH" in \
amd64) echo x86_64-unknown-linux-musl ;; \
arm64) echo aarch64-unknown-linux-musl ;; \
arm) echo armv7-unknown-linux-musleabihf ;; \
*) echo "unsupported architecture: $TARGETARCH" >&2; exit 1 ;; \
esac) && \
just cni-repair-controller arch="$TARGETARCH" profile=release build && \
mv "target/$target/release/linkerd-cni-repair-controller" .
FROM --platform=$TARGETPLATFORM alpine:3.20.3 as runtime
WORKDIR /linkerd
RUN apk add \
# For inotifywait
inotify-tools \
# For pgrep
procps \
bash \
jq
COPY --from=go /go/bin/linkerd-cni /opt/cni/bin/
COPY --from=cni-repair-controller /build/linkerd-cni-repair-controller /usr/lib/linkerd/
COPY LICENSE .
COPY cni-plugin/deployment/scripts/install-cni.sh .
COPY cni-plugin/deployment/linkerd-cni.conf.default .
COPY cni-plugin/deployment/scripts/filter.jq .
ENV PATH=/linkerd:/opt/cni/bin:$PATH
CMD ["install-cni.sh"]