forked from bpfman/bpfman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Containerfile.bpfman
56 lines (45 loc) · 2.5 KB
/
Containerfile.bpfman
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
55
56
# We do not use --platform feature to auto fill this ARG because of incompatibility between podman and docker
ARG BUILDPLATFORM=linux/amd64
FROM --platform=$BUILDPLATFORM rust:1 as bpfman-build
ARG BUILDPLATFORM
# The following ARGs are set internally by docker/build-push-action in github actions
ARG TARGETARCH=amd64
ARG TARGETOS=linux
ARG TARGETPLATFORM=linux/amd64
RUN echo "TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} BUILDPLATFORM=${BUILDPLATFORM} TARGETPLATFORM=${TARGETPLATFORM}"
RUN apt-get update
WORKDIR /usr/src/bpfman
COPY ./ /usr/src/bpfman
# Compile bpfman cli, bpfman-ns, and bpfman-rpc binaries
RUN mkdir -p bin/
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
cargo build --release --target x86_64-unknown-linux-gnu && \
cp target/x86_64-unknown-linux-gnu/release/bpfman bin/. && \
cp target/x86_64-unknown-linux-gnu/release/bpfman-ns bin/. && \
cp target/x86_64-unknown-linux-gnu/release/bpfman-rpc bin/.; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
apt-get install -y gcc-aarch64-linux-gnu && \
rustup target add aarch64-unknown-linux-gnu && \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc cargo build --release --target aarch64-unknown-linux-gnu && \
cp target/aarch64-unknown-linux-gnu/release/bpfman bin/. && \
cp target/aarch64-unknown-linux-gnu/release/bpfman-ns bin/. && \
cp target/aarch64-unknown-linux-gnu/release/bpfman-rpc bin/.; \
elif [ "$TARGETPLATFORM" = "linux/ppc64le" ]; then \
rustup target add powerpc64le-unknown-linux-gnu && \
cargo build --release --target powerpc64le-unknown-linux-gnu && \
cp target/powerpc64le-unknown-linux-gnu/release/bpfman bin/. && \
cp target/powerpc64le-unknown-linux-gnu/release/bpfman-ns bin/. && \
cp target/powerpc64le-unknown-linux-gnu/release/bpfman-rpc bin/.; \
elif [ "$TARGETPLATFORM" = "linux/s390x" ]; then \
rustup target add s390x-unknown-linux-gnu && \
cargo build --release --target s390x-unknown-linux-gnu && \
cp target/s390x-unknown-linux-gnu/release/bpfman bin/. && \
cp target/s390x-unknown-linux-gnu/release/bpfman-ns bin/. && \
cp target/s390x-unknown-linux-gnu/release/bpfman-rpc bin/.; \
fi
FROM --platform=$TARGETPLATFORM redhat/ubi9-minimal
ARG TARGETPLATFORM
COPY --from=bpfman-build /usr/src/bpfman/bin/bpfman .
COPY --from=bpfman-build /usr/src/bpfman/bin/bpfman-ns .
COPY --from=bpfman-build /usr/src/bpfman/bin/bpfman-rpc .
ENTRYPOINT ["./bpfman-rpc", "--timeout=0"]