forked from edgecomllc/eupf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
32 lines (24 loc) · 1.06 KB
/
Dockerfile
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
FROM golang:1.22.7-bullseye as builder
WORKDIR /app
# Install dependencies for ebpf compilation
RUN apt update \
&& apt install --no-install-recommends -y clang llvm gcc-multilib libbpf-dev \
&& rm -rf /var/lib/apt/lists/*
RUN go install github.com/swaggo/swag/cmd/[email protected]
COPY go.mod go.sum ./
COPY cmd cmd
ARG BPF_ENABLE_LOG "0"
ARG BPF_ENABLE_ROUTE_CACHE "0"
RUN BPF_CFLAGS="" \
&& if [ "$BPF_ENABLE_LOG" = "1" ]; then BPF_CFLAGS="$BPF_CFLAGS -DENABLE_LOG"; fi \
&& if [ "$BPF_ENABLE_ROUTE_CACHE" = "1" ]; then BPF_CFLAGS="$BPF_CFLAGS -DENABLE_ROUTE_CACHE"; fi \
&& BPF_CFLAGS=$BPF_CFLAGS go generate -v ./cmd/...
RUN CGO_ENABLED=0 go build -v -o bin/eupf ./cmd/
FROM alpine:3.18.5 AS runtime
LABEL org.opencontainers.image.source="https://github.com/edgecomllc/eupf"
COPY --from=builder /app/bin/ /app/bin/
COPY --from=builder /app/cmd/docs/swagger.* /app/
COPY --from=builder /app/cmd/ebpf/zeroentrypoint_bpf.o /app/
COPY ./entrypoint.sh /app/bin/entrypoint.sh
# CMD is overridden if arguments are passed.
ENTRYPOINT [ "sh", "/app/bin/entrypoint.sh" ]