-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathDockerfile
More file actions
200 lines (177 loc) · 7.48 KB
/
Dockerfile
File metadata and controls
200 lines (177 loc) · 7.48 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# SPDX-License-Identifier: Apache-2.0
# Copyright 2020-present Open Networking Foundation
# Copyright 2019-present Intel Corporation
# Stage bess-build: pre-built BESS image (built from bess/env/Dockerfile)
FROM ghcr.io/omec-project/bess_build:260317@sha256:3a98e66e6c99b674635da082df031319ba7c4ab27463e2182b86975a10d7d19c AS bess-build
# Stage bess: creates the runtime image of BESS
FROM ubuntu:24.04@sha256:d1e2e92c075e5ca139d51a140fff46f84315c0fdce203eab2807c7e495eff4f9 AS bess
ENV DEBIAN_FRONTEND=noninteractive
# Build arguments for dynamic labels
ARG VERSION=dev
ARG VCS_URL=unknown
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown
LABEL org.opencontainers.image.source="${VCS_URL}" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.url="${VCS_URL}" \
org.opencontainers.image.title="upf-bess" \
org.opencontainers.image.description="Aether 5G Core UPF-BESS Network Function" \
org.opencontainers.image.authors="Aether SD-Core <[email protected]>" \
org.opencontainers.image.vendor="Aether Project" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.documentation="https://docs.sd-core.aetherproject.org/"
WORKDIR /
COPY requirements.txt .
RUN apt-get update && apt-get install -y \
--no-install-recommends \
python3-pip \
libgraph-easy-perl \
iproute2 \
iptables \
iputils-ping \
tcpdump && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
pip install --no-cache-dir --break-system-packages --ignore-installed --require-hashes -r requirements.txt
COPY --from=bess-build /opt/bess /opt/bess
COPY --from=bess-build /bin/bessd /bin/bessd
COPY --from=bess-build /bin/modules /bin/modules
COPY conf /opt/bess/bessctl/conf
RUN ln -s /opt/bess/bessctl/bessctl /bin
# CNDP and runtime: Install dependencies
RUN apt-get update && apt-get install -y \
--no-install-recommends \
build-essential \
ethtool \
libbpf1 \
libbsd0 \
libc-ares2 \
libelf1 \
libfdt1 \
libgflags2.2 \
libgoogle-glog0v6 \
libgrpc++1.51t64 \
libjson-c5 \
libnl-3-200 \
libnl-cli-3-200 \
libnuma1 \
libpcap0.8 \
libprotobuf32t64 \
libssl3 \
libxdp1 \
pkg-config && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy CNDP binary and libraries
COPY --from=bess-build /usr/bin/cndpfwd /usr/bin/
# NOTE: Copy the entire directory rather than individual library files because:
# - CNDP and DPDK install their runtime libraries into /usr/local/lib/x86_64-linux-gnu/
# - The exact set of required shared objects may change between CNDP/DPDK/BESS releases
# - Maintaining a fragile, version-specific list of libraries is error-prone
# - Image size impact has been evaluated and is acceptable for this component
COPY --from=bess-build /usr/local/lib/x86_64-linux-gnu/ /usr/local/lib/x86_64-linux-gnu/
# Create DPDK plugin directory so that EAL can dlopen bus/mempool/net drivers
# at runtime. bessd passes "-d /opt/bess/lib/dpdk-pmds" to rte_eal_init()
# when this directory exists.
# Needed plugins:
# librte_bus_vdev – vdev bus (required to create AF_PACKET/AF_XDP ports)
# librte_bus_pci – PCI bus (required for DPDK-bound NICs)
# librte_mempool_ring – default "ring_mp_mc" mempool ops
# librte_net_af_packet – AF_PACKET net driver (kernel datapath fallback)
# librte_net_af_xdp – AF_XDP net driver (kernel datapath)
RUN set -e; \
mkdir -p /opt/bess/lib/dpdk-pmds; \
missing_pats=""; \
for pat in librte_mempool_ring librte_bus_vdev librte_bus_pci \
librte_net_af_packet librte_net_af_xdp; do \
found=0; \
for f in /usr/local/lib/x86_64-linux-gnu/"${pat}".so*; do \
if [ -f "$f" ]; then \
ln -sf "$f" /opt/bess/lib/dpdk-pmds/; \
found=1; \
fi; \
done; \
if [ "$found" -eq 0 ]; then \
echo "Required DPDK plugin not found: ${pat}" >&2; \
missing_pats="yes"; \
fi; \
done; \
if [ -n "$missing_pats" ]; then \
echo "One or more required DPDK plugins are missing; failing build." >&2; \
exit 1; \
fi; \
echo "DPDK PMD directory contents:"; \
ls -la /opt/bess/lib/dpdk-pmds/; \
ldconfig
ENV PYTHONPATH="/opt/bess"
WORKDIR /opt/bess/bessctl
ENTRYPOINT ["bessd", "-f"]
# Stage build bess golang pb
FROM golang:1.26.1-bookworm@sha256:4465644228bc2857a954b092167e12aa59c006a3492282a6c820bf4755fd64a4 AS protoc-gen
RUN go install google.golang.org/protobuf/cmd/[email protected] && \
go install google.golang.org/grpc/cmd/[email protected]
FROM bess-build AS go-pb
COPY --from=protoc-gen /go/bin/protoc-gen-go /bin
COPY --from=protoc-gen /go/bin/protoc-gen-go-grpc /bin
RUN mkdir /bess_pb && \
protoc -I /usr/include -I /protobuf/ \
/protobuf/*.proto /protobuf/ports/*.proto \
--go_opt=paths=source_relative --go_out=/bess_pb \
--go-grpc_opt=paths=source_relative --go-grpc_out=/bess_pb
FROM bess-build AS py-pb
WORKDIR /
COPY requirements_pb.txt .
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev && rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir --break-system-packages --ignore-installed --require-hashes -r requirements_pb.txt
RUN mkdir /bess_pb && \
python3 -m grpc_tools.protoc -I /usr/include -I /protobuf/ \
/protobuf/*.proto /protobuf/ports/*.proto \
--python_out=/bess_pb \
--grpc_python_out=/bess_pb
FROM golang:1.26.1-bookworm@sha256:4465644228bc2857a954b092167e12aa59c006a3492282a6c820bf4755fd64a4 AS pfcpiface-build
ARG GOFLAGS
WORKDIR /pfcpiface
COPY go.mod /pfcpiface/go.mod
COPY go.sum /pfcpiface/go.sum
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN if echo "$GOFLAGS" | grep -Eq "-mod=vendor"; then go mod download; fi
COPY . /pfcpiface
RUN go mod tidy && \
CGO_ENABLED=0 go build $GOFLAGS -o /bin/pfcpiface ./cmd/pfcpiface
# Stage pfcpiface: runtime image of pfcpiface toward SMF/SPGW-C
FROM alpine:3.23@sha256:25109184c71bdad752c8312a8623239686a9a2071e8825f20acb8f2198c3f659 AS pfcpiface
# Build arguments for dynamic labels
ARG VERSION=dev
ARG VCS_URL=unknown
ARG VCS_REF=unknown
ARG BUILD_DATE=unknown
LABEL org.opencontainers.image.source="${VCS_URL}" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.url="${VCS_URL}" \
org.opencontainers.image.title="pfcpiface" \
org.opencontainers.image.description="Aether 5G Core PFCPIFACE Network Function" \
org.opencontainers.image.authors="Aether SD-Core <[email protected]>" \
org.opencontainers.image.vendor="Aether Project" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.documentation="https://docs.sd-core.aetherproject.org/"
COPY conf /opt/bess/bessctl/conf
COPY --from=pfcpiface-build /bin/pfcpiface /bin
ENTRYPOINT [ "/bin/pfcpiface" ]
# Stage pb: dummy stage for collecting protobufs
FROM scratch AS pb
COPY --from=bess-build /bess/protobuf /protobuf
COPY --from=go-pb /bess_pb /bess_pb
# Stage ptf-pb: dummy stage for collecting python protobufs
FROM scratch AS ptf-pb
COPY --from=bess-build /bess/protobuf /protobuf
COPY --from=py-pb /bess_pb /bess_pb
# Stage binaries: dummy stage for collecting artifacts
FROM scratch AS artifacts
COPY --from=bess /bin/bessd /
COPY --from=pfcpiface /bin/pfcpiface /
COPY --from=bess-build /bess/protobuf /bess/protobuf
COPY --from=bess-build /pb /bess/pb