forked from iqiyi/dpvs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
167 lines (147 loc) · 6.41 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Important Notes:
#
# Two local dependencies should be ready before build container image with the Dockerfile.
# - MLNX_OFED: Please download it from the official website
# `https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/`
# to the local fileserver indicated by the ARG `MLNX_OFED`.
# We cannot download it in the Dockerfile automatically for the authentication
# restriction of the website.
# - RPM_PKGCONFIG: The `pkg-config` tool of v0.29.2 is required to build DPVS.
# However, the default installation version on centos7 is v0.27.1. You need to
# download it or build the v0.29.2 RPM from source and put it to the the local
# fileserver indicated by the ARG `RPM_PKGCONFIG`. Alternatively, building a
# binary `pkg-config` and installing it in the local binary path is also ok.
#
# No kernel dependencies of dpdk/dpvs or network driver are built and installed.
# You should ensure the host has installed the drivers before running a dpvs
# container on it.
#
ARG BASE_IMAGE=centos:centos7.9.2009
###### `builder` stage builds the docker image for DPVS devel environments ######
FROM $BASE_IMAGE as builder
# replace it with the address of your own file server
ARG FILE_SERVER=127.0.0.1
LABEL maintainer="IQiYi/QLB team"
LABEL email="[email protected]"
LABEL project="https://github.com/iqiyi/dpvs"
LABEL image_maker="docker build --target builder -t github.com/iqiyi/dpvs-builder:{version} ."
# download the tarball from https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/
# FIXME: remove thefile server dependency
ARG MLNX_OFED=http://$FILE_SERVER/deploy/MLNX_OFED/MLNX_OFED_LINUX-5.6-2.0.9.0-rhel7.9-x86_64.tgz
# the pkgconfig default installed version is 0.27.1 on centos7, update it to 0.29.2
# the 0.29.2 rpm is built from source based on the rpm spec file of 0.27.1.
# FIXME: remove the file server dependency
ARG RPM_PKGCONFIG=http://$FILE_SERVER/deploy/rpms/centos7/pkgconfig-0.29.2-1.el7.x86_64.rpm
# golang install files
ARG GO_PACKAGE=https://go.dev/dl/go1.20.4.linux-amd64.tar.gz
# go-swagger binary
ARG GO_SWAGGER_BIN=https://github.com/go-swagger/go-swagger/releases/download/v0.30.4/swagger_darwin_amd64
ENV PKG_CONFIG_PATH=/dpvs/dpdk/dpdklib/lib64/pkgconfig
ENV PATH=$PATH:/usr/local/go/bin
COPY . /dpvs/
WORKDIR /dpvs
RUN set -x \
&& yum install -y epel-release \
&& yum install -y tcl tk iproute wget vim patch meson python36 emacs-filesystem \
gcc make lsof libnl3 ethtool libpcap pciutils numactl-libs numactl-devel \
openssl-devel automake popt-devel ninja-build meson libnl3-devel cgdb git \
&& mkdir deps \
&& rpm -Uvh $RPM_PKGCONFIG \
&& wget $GO_PACKAGE -P deps \
&& tar -C /usr/local -xzf deps/go*.gz \
&& curl -L -o /usr/local/bin/swagger $GO_SWAGGER_BIN \
&& chmod 544 /usr/local/bin/swagger \
&& wget $MLNX_OFED -P deps \
&& tar xf deps/$(basename $MLNX_OFED) -C deps \
&& pushd deps/$(basename $MLNX_OFED | sed 's/.tgz//') \
&& ./mlnxofedinstall --user-space-only --upstream-libs \
--dpdk --without-fw-update --force \
&& popd \
&& sed -i 's/Denable_kmods=true/Denable_kmods=false/' scripts/dpdk-build.sh \
&& ./scripts/dpdk-build.sh \
&& sed -i 's/CONFIG_DPVS_AGENT=n/CONFIG_DPVS_AGENT=y/' config.mk \
&& make -j && make install \
&& rm -rf deps && yum clean all
RUN set -x \
&& mkdir libraries \
&& ldd bin/dpvs | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries \
&& ldd bin/ipvsadm | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries \
&& ldd bin/dpip | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries \
&& ldd bin/keepalived | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries
ENTRYPOINT ["/bin/bash"]
###### `runner` stage builds the docker image for DPVS product environments ######
#
# docker run --name dpvs \
# -d --privileged --network host \
# -v /dev:/dev \
# -v /sys:/sys \
# -v /lib/modules:/lib/modules \
# -v {dpvs-directory}:/dpvs \
# github.com/iqiyi/dpvs:{version} \
# -c /dpvs/dpvs.conf -p /dpvs/dpvs.pid -x /dpvs/dpvs.ipc \
# -- -a {nic-pci-bus-id}
#
# docker run --name ipvsadm \
# --rm --network none \
# -v {dpvs-directory}:/dpvs \
# -e DPVS_IPC_FILE=/dpvs/dpvs.ipc \
# --entrypoint=/usr/bin/ipvsadm \
# github.com/iqiyi/dpvs:{version} \
# ...
#
# docker run --name dpip \
# --rm --network none \
# -v {dpvs-directory}:/dpvs \
# -e DPVS_IPC_FILE=/dpvs/dpvs.ipc \
# --entrypoint=/usr/bin/dpip \
# github.com/iqiyi/dpvs:{version} \
# ...
#
# docker run --name keepalived \
# -d --privileged --network host \
# --cap-add=NET_ADMIN --cap-add=NET_BROADCAST --cap-add=NET_RAW \
# -v {dpvs-directory}:/dpvs \
# -e DPVS_IPC_FILE=/dpvs/dpvs.ipc \
# --entrypoint=/usr/bin/keepalived github.com/iqiyi/dpvs:{version} \
# -D -n -f /dpvs/keepalived.conf \
# --log-console --log-facility=6 \
# --pid=/dpvs/keepalived.pid \
# --vrrp_pid=/dpvs/vrrp.pid \
# --checkers_pid=/dpvs/checkers.pid
#
# docker run --name dpvs-agent \
# -d --network host \
# -v {dpvs-directory}:/dpvs \
# --entrypoint=/usr/bin/dpvs-agent \
# github.com/iqiyi/dpvs:{version} \
# --log-dir=/dpvs/logs/dpvs-agent \
# --ipc-sockopt-path=/dpvs/dpvs.ipc\
# --host=0.0.0.0 --port=6601
#
# docker run --name healthcheck \
# -d --network host \
# -v {dpvs-directory}:/dpvs \
# --entrypoint=/usr/bin/healthcheck \
# github.com/iqiyi/dpvs:{version} \
# -log_dir=/dpvs/logs/healthcheck \
# -lb_iface_addr=localhost:6601
#
FROM $BASE_IMAGE as runner
LABEL maintainer="IQiYi/QLB team"
LABEL email="[email protected]"
LABEL project="https://github.com/iqiyi/dpvs"
LABEL image_maker="docker build --target runner -t github.com/iqiyi/dpvs:{version} ."
RUN set -x \
&& yum install -y iproute wget ncat nmap tcpdump socat \
&& yum clean all
COPY --from=builder /dpvs/bin/ /usr/bin
COPY --from=builder /dpvs/libraries /usr/lib64
# Other available entrypoint are:
# * /usr/bin/keepalived
# * /usr/bin/dpvs-agent
# * /usr/bin/healthcheck
# * /usr/bin/ipvsadm
# * /usr/bin/dpip
# * /bin/bash
# use `docker run --entrypoint ...` to override the default entrypoint.
ENTRYPOINT ["/usr/bin/dpvs"]