forked from omec-project/upf
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
151 lines (127 loc) · 4.03 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
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
# SPDX-License-Identifier: Apache-2.0
# Copyright 2020-present Open Networking Foundation
# Copyright 2019 Intel Corporation
# Multi-stage Dockerfile
# Stage bess-deps: fetch BESS dependencies
FROM ghcr.io/omec-project/upf-epc/bess_build AS bess-deps
# BESS pre-reqs
WORKDIR /bess
ARG BESS_COMMIT=dpdk-2011-focal
RUN curl -L https://github.com/NetSys/bess/tarball/${BESS_COMMIT} | \
tar xz -C . --strip-components=1
COPY patches/bess patches
RUN cat patches/* | patch -p1
RUN cp -a protobuf /protobuf
# Stage bess-build: builds bess with its dependencies
FROM bess-deps AS bess-build
ARG CPU=native
RUN apt-get update && \
apt-get -y install --no-install-recommends \
ca-certificates \
libelf-dev
ARG MAKEFLAGS
ENV PKG_CONFIG_PATH=/usr/lib64/pkgconfig
# linux ver should match target machine's kernel
WORKDIR /libbpf
ARG LIBBPF_VER=v0.3
RUN curl -L https://github.com/libbpf/libbpf/tarball/${LIBBPF_VER} | \
tar xz -C . --strip-components=1 && \
cp include/uapi/linux/if_xdp.h /usr/include/linux && \
cd src && \
make install && \
ldconfig
WORKDIR /bess
# Patch BESS, patch and build DPDK
COPY patches/dpdk/* deps/
RUN ./build.py dpdk
# Plugins
RUN mkdir -p plugins
## SequentialUpdate
RUN mv sample_plugin plugins
## Network Token
ARG ENABLE_NTF
ARG NTF_COMMIT=master
COPY install_ntf.sh .
RUN ./install_ntf.sh
# Build and copy artifacts
COPY core/ core/
COPY build_bess.sh .
RUN ./build_bess.sh && \
cp bin/bessd /bin && \
mkdir -p /bin/modules && \
cp core/modules/*.so /bin/modules && \
mkdir -p /opt/bess && \
cp -r bessctl pybess /opt/bess && \
cp -r core/pb /pb
# Stage bess: creates the runtime image of BESS
FROM python:3.9.9-slim AS bess
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
libgraph-easy-perl \
iproute2 \
iptables \
iputils-ping \
tcpdump && \
rm -rf /var/lib/apt/lists/* && \
pip install --no-cache-dir \
flask \
grpcio \
iptools \
mitogen \
protobuf \
psutil \
pyroute2 \
scapy && \
apt-get --purge remove -y \
gcc
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
ENV PYTHONPATH="/opt/bess"
WORKDIR /opt/bess/bessctl
ENTRYPOINT ["bessd", "-f"]
# Stage build bess golang pb
FROM golang AS protoc-gen
RUN go get github.com/golang/protobuf/protoc-gen-go
FROM bess-deps AS go-pb
COPY --from=protoc-gen /go/bin/protoc-gen-go /bin
RUN mkdir /bess_pb && \
protoc -I /usr/include -I /protobuf/ \
/protobuf/*.proto /protobuf/ports/*.proto \
--go_opt=paths=source_relative --go_out=plugins=grpc:/bess_pb
FROM bess-deps AS py-pb
RUN pip install grpcio-tools==1.26
RUN mkdir /bess_pb && \
python -m grpc_tools.protoc -I /usr/include -I /protobuf/ \
/protobuf/*.proto /protobuf/ports/*.proto \
--python_out=plugins=grpc:/bess_pb \
--grpc_python_out=/bess_pb
FROM golang AS pfcpiface-build
WORKDIR /pfcpiface
COPY go.mod /pfcpiface/go.mod
COPY go.sum /pfcpiface/go.sum
RUN go mod download
COPY . /pfcpiface
RUN CGO_ENABLED=0 go build -o /bin/pfcpiface ./pfcpiface
# Stage pfcpiface: runtime image of pfcpiface toward SMF/SPGW-C
FROM alpine AS pfcpiface
COPY conf /opt/bess/bessctl/conf
COPY conf/p4/bin/p4info.bin conf/p4/bin/p4info.txt conf/p4/bin/bmv2.json /bin/
COPY --from=pfcpiface-build /bin/pfcpiface /bin
ENTRYPOINT [ "/bin/pfcpiface" ]
# Stage pb: dummy stage for collecting protobufs
FROM scratch AS pb
COPY --from=bess-deps /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-deps /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 /bess