@@ -17,12 +17,40 @@ WORKDIR /azure-iptables-monitor
1717COPY ./azure-iptables-monitor .
1818RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/iptables-monitor -trimpath -ldflags "-s -w -X main.version=" $VERSION"" -gcflags="-dwarflocationlists=true" .
1919
20+ FROM go AS azure-block-iptables
21+ ARG OS
22+ ARG AZURE_BLOCK_IPTABLES_VERSION
23+ ARG ARCH
24+ WORKDIR /azure-container-networking
25+ COPY ./bpf-prog/azure-block-iptables ./bpf-prog/azure-block-iptables
26+ COPY ./go.mod ./go.sum ./
27+ # Install BPF development dependencies for Azure Linux (mariner)
28+ RUN tdnf install -y llvm clang libbpf-devel gcc binutils glibc
29+ # Set up C include path for BPF
30+ ENV C_INCLUDE_PATH=/usr/include/bpf
31+ # Set up architecture-specific symlinks for cross-compilation support
32+ RUN if [ "$ARCH" = "amd64" ]; then \
33+ ARCH_DIR=x86_64-linux-gnu; \
34+ elif [ "$ARCH" = "arm64" ]; then \
35+ ARCH_DIR=aarch64-linux-gnu; \
36+ fi && \
37+ for dir in /usr/include/"$ARCH_DIR" /*; do \
38+ if [ -d "$dir" ]; then \
39+ ln -sfn "$dir" /usr/include/$(basename "$dir" ); \
40+ elif [ -f "$dir" ]; then \
41+ ln -Tsfn "$dir" /usr/include/$(basename "$dir" ); \
42+ fi \
43+ done || true
44+ RUN GOOS=$OS CGO_ENABLED=0 go generate ./bpf-prog/azure-block-iptables/...
45+ RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-block-iptables -trimpath -ldflags "-s -w -X main.version=" $AZURE_BLOCK_IPTABLES_VERSION"" -gcflags="-dwarflocationlists=true" ./bpf-prog/azure-block-iptables/cmd/azure-block-iptables
46+
2047FROM mariner-core AS iptables
2148RUN tdnf install -y iptables
2249
2350FROM mariner-distroless AS linux
2451COPY --from=iptables /usr/sbin/*tables* /usr/sbin/
2552COPY --from=iptables /usr/lib /usr/lib
2653COPY --from=azure-iptables-monitor /go/bin/iptables-monitor azure-iptables-monitor
54+ COPY --from=azure-block-iptables /go/bin/azure-block-iptables azure-block-iptables
2755
2856ENTRYPOINT ["/azure-iptables-monitor" ]
0 commit comments