Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: add xdp deps in Dockerfile #636

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ For legacy way of running multiple containers without MTL Manager, please add th

#### 3.2.1 Run with docker command

For DPDK backend, pass the VFIO devices:
For DPDK PMD backend, pass the VFIO devices:

```bash
docker run -it \
Expand All @@ -49,7 +49,7 @@ docker run -it \
mtl:latest
```

For kernel / AF_XDP backend (new dockerfile WIP), pass the host network interfaces:
For AF_XDP backend, pass the host network interfaces:

```bash
docker run -it \
Expand All @@ -58,20 +58,25 @@ docker run -it \
--cap-add SYS_NICE \
--cap-add NET_ADMIN \
--cap-add NET_RAW \
--cap-add CAP_BPF \
-v /var/run/imtl:/var/run/imtl \
--ulimit memlock=-1 \
mtl:latest
```

Explanation of `docker run` arguments:

| Argument | Description |
| --- | --- |
| `--net host` | For AF_XDP backend to access NICs |
| `-v /var/run/imtl:/var/run/imtl` | For connection with MTL Manager |
| `--device /dev/vfio` | Access the VFIO device |
| `--cap-add SYS_NICE` | For set_mempolicy |
| `--cap-add IPC_LOCK` | For DMA mapping |
| `--device /dev/vfio` | For DPDK eal to access the VFIO devices |
| `--ulimit memlock=-1` | For AF_XDP backend to create UMEM |
| `--cap-add SYS_NICE` | For DPDK eal to set NUMA memory policy |
| `--cap-add IPC_LOCK` | For DPDK PMD to do DMA mapping |
| `--cap-add NET_ADMIN` | For kernel NIC configuration |
| `--cap-add NET_RAW` | For AF_XDP socket |
| `--cap-add NET_RAW` | For AF_XDP backend to create socket |
| `--cap-add CAP_BPF` | For AF_XDP backend to update xsks_map |
| `--cap-add SYS_TIME` | For systime adjustment if `--phc2sys` enabled |

#### 3.2.2 Specify VFIO devices for container
Expand Down Expand Up @@ -110,20 +115,12 @@ docker-compose run imtl
# docker compose run imtl
```

### 3.3 Switch to the root user inside a Docker container

On the docker bash shell:

```bash
sudo -s
```

## 4. Run RxTXApp

```bash
cd Media-Transport-Library/
# Run below command to generate a fake yuv file or follow "#### 3.3 Prepare source files:" in [run guide](../doc/run.md)
# dd if=/dev/urandom of=test.yuv count=2160 bs=4800
# Edit and Run the loop json file
# Edit and Run the loop json file.
# For DPDK PMD backend, need to run with sudo.
./build/app/RxTxApp --config_file tests/script/loop_json/1080p60_1v.json
```
75 changes: 37 additions & 38 deletions docker/ubuntu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2023 Intel Corporation

FROM ubuntu@sha256:dfd64a3b4296d8c9b62aa3309984f8620b98d87e47492599ee20739e8eb54fbf
# Ubuntu 22.04
FROM ubuntu@sha256:149d67e29f765f4db62aa52161009e99e389544e25a8f43c8c89d4a445a7ca37

LABEL maintainer="[email protected]"
LABEL maintainer="[email protected],[email protected]"

ENV MTL_REPO=Media-Transport-Library
ENV DPDK_REPO=dpdk
ENV DPDK_VER=23.11
ENV IMTL_USER=imtl
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig

# Install dependencies and debug tools
RUN apt-get update -y && \
apt-get install -y git gcc meson python3 python3-pip pkg-config libnuma-dev libjson-c-dev libpcap-dev libgtest-dev libsdl2-dev libsdl2-ttf-dev libssl-dev && \
apt-get install -y make m4 clang llvm zlib1g-dev libelf-dev libcap-ng-dev && \
apt-get install -y sudo vim htop libcap2-bin && \
pip install pyelftools ninja && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Add user: imtl
RUN adduser $IMTL_USER && \
usermod -G sudo $IMTL_USER && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

RUN apt-get update -y

# Install dependencies
RUN apt-get install -y git gcc meson python3 python3-pip pkg-config libnuma-dev libjson-c-dev libpcap-dev libgtest-dev libsdl2-dev libsdl2-ttf-dev libssl-dev

RUN pip install pyelftools ninja

RUN apt-get install -y sudo

# some misc tools
RUN apt-get install -y vim htop

RUN apt clean all

# user: imtl
RUN adduser $IMTL_USER
RUN usermod -G sudo $IMTL_USER
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER $IMTL_USER

WORKDIR /home/$IMTL_USER/

RUN git config --global user.email "[email protected]" && \
git config --global user.name "Your Name"

RUN git clone https://github.com/OpenVisualCloud/$MTL_REPO.git

RUN git clone https://github.com/DPDK/$DPDK_REPO.git && \
# Clone and build DPDK before bpf and xdp
RUN git clone https://github.com/OpenVisualCloud/$MTL_REPO.git && \
git clone https://github.com/DPDK/$DPDK_REPO.git && \
cd $DPDK_REPO && \
git checkout v$DPDK_VER && \
git switch -c v$DPDK_VER

# build dpdk
RUN cd $DPDK_REPO && \
git am ../Media-Transport-Library/patches/dpdk/$DPDK_VER/*.patch && \
meson build && \
git switch -c v$DPDK_VER && \
git config --global user.email "[email protected]" && \
git config --global user.name "Your Name" && \
git am ../$MTL_REPO/patches/dpdk/$DPDK_VER/*.patch && \
meson setup build && \
ninja -C build && \
sudo ninja -C build install && \
cd ..
sudo ninja -C build install

# Clone and build the xdp-tools project
RUN git clone --recurse-submodules https://github.com/xdp-project/xdp-tools.git && \
cd xdp-tools && ./configure && make && sudo make install && \
cd lib/libbpf/src && sudo make install

# Build IMTL
RUN cd $MTL_REPO && ./build.sh && \
sudo setcap 'cap_net_admin+ep cap_net_raw+ep' ./build/app/RxTxApp

# build mtl
RUN cd $MTL_REPO && \
./build.sh && \
cd ..
WORKDIR /home/$IMTL_USER/$MTL_REPO

CMD ["/bin/bash"]
17 changes: 10 additions & 7 deletions manager/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# First stage: build environment
FROM ubuntu:22.04 AS build-env
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2023 Intel Corporation

# Build stage, ubuntu 22.04
FROM ubuntu@sha256:149d67e29f765f4db62aa52161009e99e389544e25a8f43c8c89d4a445a7ca37 as builder

LABEL maintainer="[email protected]"

Expand All @@ -18,18 +21,18 @@ RUN git clone --recurse-submodules https://github.com/xdp-project/xdp-tools.git
RUN git clone https://github.com/OpenVisualCloud/Media-Transport-Library.git && \
cd Media-Transport-Library/manager && meson setup build && meson compile -C build

# Second stage: runtime environment
FROM ubuntu:22.04
# Runtime stage, ubuntu 22.04
FROM ubuntu@sha256:149d67e29f765f4db62aa52161009e99e389544e25a8f43c8c89d4a445a7ca37

# Install runtime dependencies
RUN apt-get update -y && \
apt-get install -y ethtool libelf-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Copy the necessary binaries and libraries from the build-env
COPY --from=build-env /usr/local /usr/local
COPY --from=build-env /Media-Transport-Library/manager/build /app
# Copy the necessary binaries and libraries from the builder
COPY --from=builder /usr/local /usr/local
COPY --from=builder /Media-Transport-Library/manager/build /app

WORKDIR /app

Expand Down