|
| 1 | +# Important Notes: |
| 2 | +# |
| 3 | +# Two local dependencies should be ready before build container image with the Dockerfile. |
| 4 | +# - MLNX_OFED: Please download it from the official website |
| 5 | +# `https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/` |
| 6 | +# to the local fileserver indicated by the ARG `MLNX_OFED`. |
| 7 | +# We cannot download it in the Dockerfile automatically for the authentication |
| 8 | +# restriction of the website. |
| 9 | +# - RPM_PKGCONFIG: The `pkg-config` tool of v0.29.2 is required to build DPVS. |
| 10 | +# However, the default installation version on centos7 is v0.27.1. You need to |
| 11 | +# download it or build the v0.29.2 RPM from source and put it to the the local |
| 12 | +# fileserver indicated by the ARG `RPM_PKGCONFIG`. Alternatively, building a |
| 13 | +# binary `pkg-config` and installing it in the local binary path is also ok. |
| 14 | +# |
| 15 | +# No kernel dependencies of dpdk/dpvs or network driver are built and installed. |
| 16 | +# You should ensure the host has installed the drivers before running a dpvs |
| 17 | +# container on it. |
| 18 | +# |
| 19 | + |
| 20 | +ARG BASE_IMAGE=centos:centos7.9.2009 |
| 21 | + |
| 22 | +###### `builder` stage builds the docker image for DPVS devel environments ###### |
| 23 | +FROM $BASE_IMAGE as builder |
| 24 | + |
| 25 | +# replace it with the address of your own file server |
| 26 | +ARG FILE_SERVER=127.0.0.1 |
| 27 | + |
| 28 | +LABEL maintainer="IQiYi/QLB team" |
| 29 | +LABEL email="iig_cloud_qlb@qiyi.com" |
| 30 | +LABEL project="https://github.com/iqiyi/dpvs" |
| 31 | +LABEL image_maker="docker build --target builder -t github.com/iqiyi/dpvs-builder:{version} ." |
| 32 | + |
| 33 | +# download the tarball from https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/ |
| 34 | +# FIXME: remove thefile server dependency |
| 35 | +ARG MLNX_OFED=http://$FILE_SERVER/deploy/MLNX_OFED/MLNX_OFED_LINUX-5.6-2.0.9.0-rhel7.9-x86_64.tgz |
| 36 | + |
| 37 | +# the pkgconfig default installed version is 0.27.1 on centos7, update it to 0.29.2 |
| 38 | +# the 0.29.2 rpm is built from source based on the rpm spec file of 0.27.1. |
| 39 | +# FIXME: remove the file server dependency |
| 40 | +ARG RPM_PKGCONFIG=http://$FILE_SERVER/deploy/rpms/centos7/pkgconfig-0.29.2-1.el7.x86_64.rpm |
| 41 | + |
| 42 | +# golang install files |
| 43 | +ARG GO_PACKAGE=https://go.dev/dl/go1.20.4.linux-amd64.tar.gz |
| 44 | + |
| 45 | +# go-swagger binary |
| 46 | +ARG GO_SWAGGER_BIN=https://github.com/go-swagger/go-swagger/releases/download/v0.30.4/swagger_darwin_amd64 |
| 47 | + |
| 48 | +ENV PKG_CONFIG_PATH=/dpvs/dpdk/dpdklib/lib64/pkgconfig |
| 49 | +ENV PATH=$PATH:/usr/local/go/bin |
| 50 | + |
| 51 | +COPY . /dpvs/ |
| 52 | +WORKDIR /dpvs |
| 53 | + |
| 54 | +RUN set -x \ |
| 55 | + && yum install -y epel-release \ |
| 56 | + && yum install -y tcl tk iproute wget vim patch meson python36 emacs-filesystem \ |
| 57 | + gcc make lsof libnl3 ethtool libpcap pciutils numactl-libs numactl-devel \ |
| 58 | + openssl-devel automake popt-devel ninja-build meson libnl3-devel cgdb git \ |
| 59 | + && mkdir deps \ |
| 60 | + && rpm -Uvh $RPM_PKGCONFIG \ |
| 61 | + && wget $GO_PACKAGE -P deps \ |
| 62 | + && tar -C /usr/local -xzf deps/go*.gz \ |
| 63 | + && curl -L -o /usr/local/bin/swagger $GO_SWAGGER_BIN \ |
| 64 | + && chmod 544 /usr/local/bin/swagger \ |
| 65 | + && wget $MLNX_OFED -P deps \ |
| 66 | + && tar xf deps/$(basename $MLNX_OFED) -C deps \ |
| 67 | + && pushd deps/$(basename $MLNX_OFED | sed 's/.tgz//') \ |
| 68 | + && ./mlnxofedinstall --user-space-only --upstream-libs \ |
| 69 | + --dpdk --without-fw-update --force \ |
| 70 | + && popd \ |
| 71 | + && sed -i 's/Denable_kmods=true/Denable_kmods=false/' scripts/dpdk-build.sh \ |
| 72 | + && ./scripts/dpdk-build.sh \ |
| 73 | + && sed -i 's/CONFIG_DPVS_AGENT=n/CONFIG_DPVS_AGENT=y/' config.mk \ |
| 74 | + && make -j && make install \ |
| 75 | + && rm -rf deps && yum clean all |
| 76 | + |
| 77 | +RUN set -x \ |
| 78 | + && mkdir libraries \ |
| 79 | + && ldd bin/dpvs | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries \ |
| 80 | + && ldd bin/ipvsadm | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries \ |
| 81 | + && ldd bin/dpip | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries \ |
| 82 | + && ldd bin/keepalived | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp '{}' libraries |
| 83 | + |
| 84 | +ENTRYPOINT ["/bin/bash"] |
| 85 | + |
| 86 | + |
| 87 | +###### `runner` stage builds the docker image for DPVS product environments ###### |
| 88 | +# |
| 89 | +# docker run --name dpvs \ |
| 90 | +# -d --privileged --network host \ |
| 91 | +# -v /dev:/dev \ |
| 92 | +# -v /sys:/sys \ |
| 93 | +# -v /lib/modules:/lib/modules \ |
| 94 | +# -v {dpvs-directory}:/dpvs \ |
| 95 | +# github.com/iqiyi/dpvs:{version} \ |
| 96 | +# -c /dpvs/dpvs.conf -p /dpvs/dpvs.pid -x /dpvs/dpvs.ipc \ |
| 97 | +# -- -a {nic-pci-bus-id} |
| 98 | +# |
| 99 | +# docker run --name ipvsadm \ |
| 100 | +# --rm --network none \ |
| 101 | +# -v {dpvs-directory}:/dpvs \ |
| 102 | +# -e DPVS_IPC_FILE=/dpvs/dpvs.ipc \ |
| 103 | +# --entrypoint=/usr/bin/ipvsadm \ |
| 104 | +# github.com/iqiyi/dpvs:{version} \ |
| 105 | +# ... |
| 106 | +# |
| 107 | +# docker run --name dpip \ |
| 108 | +# --rm --network none \ |
| 109 | +# -v {dpvs-directory}:/dpvs \ |
| 110 | +# -e DPVS_IPC_FILE=/dpvs/dpvs.ipc \ |
| 111 | +# --entrypoint=/usr/bin/dpip \ |
| 112 | +# github.com/iqiyi/dpvs:{version} \ |
| 113 | +# ... |
| 114 | +# |
| 115 | +# docker run --name keepalived \ |
| 116 | +# -d --privileged --network host \ |
| 117 | +# --cap-add=NET_ADMIN --cap-add=NET_BROADCAST --cap-add=NET_RAW \ |
| 118 | +# -v {dpvs-directory}:/dpvs \ |
| 119 | +# -e DPVS_IPC_FILE=/dpvs/dpvs.ipc \ |
| 120 | +# --entrypoint=/usr/bin/keepalived github.com/iqiyi/dpvs:{version} \ |
| 121 | +# -D -n -f /dpvs/keepalived.conf \ |
| 122 | +# --log-console --log-facility=6 \ |
| 123 | +# --pid=/dpvs/keepalived.pid \ |
| 124 | +# --vrrp_pid=/dpvs/vrrp.pid \ |
| 125 | +# --checkers_pid=/dpvs/checkers.pid |
| 126 | +# |
| 127 | +# docker run --name dpvs-agent \ |
| 128 | +# -d --network host \ |
| 129 | +# -v {dpvs-directory}:/dpvs \ |
| 130 | +# --entrypoint=/usr/bin/dpvs-agent \ |
| 131 | +# github.com/iqiyi/dpvs:{version} \ |
| 132 | +# --log-dir=/dpvs/logs/dpvs-agent \ |
| 133 | +# --ipc-sockopt-path=/dpvs/dpvs.ipc\ |
| 134 | +# --host=0.0.0.0 --port=6601 |
| 135 | +# |
| 136 | +# docker run --name healthcheck \ |
| 137 | +# -d --network host \ |
| 138 | +# -v {dpvs-directory}:/dpvs \ |
| 139 | +# --entrypoint=/usr/bin/healthcheck \ |
| 140 | +# github.com/iqiyi/dpvs:{version} \ |
| 141 | +# -log_dir=/dpvs/logs/healthcheck \ |
| 142 | +# -lb_iface_addr=localhost:6601 |
| 143 | +# |
| 144 | +FROM $BASE_IMAGE as runner |
| 145 | + |
| 146 | +LABEL maintainer="IQiYi/QLB team" |
| 147 | +LABEL email="iig_cloud_qlb@qiyi.com" |
| 148 | +LABEL project="https://github.com/iqiyi/dpvs" |
| 149 | +LABEL image_maker="docker build --target runner -t github.com/iqiyi/dpvs:{version} ." |
| 150 | + |
| 151 | +RUN set -x \ |
| 152 | + && yum install -y iproute wget ncat nmap tcpdump socat \ |
| 153 | + && yum clean all |
| 154 | + |
| 155 | +COPY --from=builder /dpvs/bin/ /usr/bin |
| 156 | +COPY --from=builder /dpvs/libraries /usr/lib64 |
| 157 | + |
| 158 | +# Other available entrypoint are: |
| 159 | +# * /usr/bin/keepalived |
| 160 | +# * /usr/bin/dpvs-agent |
| 161 | +# * /usr/bin/healthcheck |
| 162 | +# * /usr/bin/ipvsadm |
| 163 | +# * /usr/bin/dpip |
| 164 | +# * /bin/bash |
| 165 | +# use `docker run --entrypoint ...` to override the default entrypoint. |
| 166 | + |
| 167 | +ENTRYPOINT ["/usr/bin/dpvs"] |
0 commit comments