1# Copyright © 2025 Intel Corporation 2# 3# SPDX-License-Identifier: Apache-2.0 4# 5# When changing this file don't forget to update the tag name in the 6# .github/workflows/docker-image.yaml file if doing multiple per day 7 8FROM ubuntu:24.04 AS dev 9 10ARG TARGETARCH 11ARG RUST_TOOLCHAIN="1.83.0" 12ARG CLH_SRC_DIR="/cloud-hypervisor" 13ARG CLH_BUILD_DIR="$CLH_SRC_DIR/build" 14ARG CARGO_REGISTRY_DIR="$CLH_BUILD_DIR/cargo_registry" 15ARG CARGO_GIT_REGISTRY_DIR="$CLH_BUILD_DIR/cargo_git_registry" 16 17ENV CARGO_HOME=/usr/local/rust 18ENV RUSTUP_HOME=$CARGO_HOME 19ENV PATH="$PATH:$CARGO_HOME/bin" 20ENV DEBIAN_FRONTEND=noninteractive 21 22# Install all CI dependencies 23# DL3015 ignored cause not installing openvswitch-switch-dpdk recommended packages breaks ovs_dpdk test 24# hadolint ignore=DL3008,DL3015 25RUN apt-get update \ 26 && apt-get -yq upgrade \ 27 && apt-get install --no-install-recommends -yq \ 28 build-essential \ 29 bc \ 30 curl \ 31 wget \ 32 sudo \ 33 mtools \ 34 musl-tools \ 35 libssl-dev \ 36 pkg-config \ 37 flex \ 38 bison \ 39 libelf-dev \ 40 qemu-utils \ 41 libglib2.0-dev \ 42 libpixman-1-dev \ 43 libseccomp-dev \ 44 libcap-ng-dev \ 45 socat \ 46 dosfstools \ 47 cpio \ 48 python3 \ 49 python3-setuptools \ 50 ntfs-3g \ 51 uuid-dev \ 52 iperf3 \ 53 zip \ 54 git-core \ 55 dnsmasq \ 56 dmsetup \ 57 ca-certificates \ 58 unzip \ 59 iproute2 \ 60 dbus \ 61 && apt-get install openvswitch-switch-dpdk -yq \ 62 && apt-get clean \ 63 && rm -rf /var/lib/apt/lists/* /var/log/*log /var/log/apt/* /var/lib/dpkg/*-old /var/cache/debconf/*-old 64 65RUN update-alternatives --set ovs-vswitchd /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk 66 67# hadolint ignore=DL3008 68RUN if [ "$TARGETARCH" = "amd64" ]; then \ 69 apt-get update \ 70 && apt-get -yq upgrade \ 71 && apt-get install --no-install-recommends -yq swtpm \ 72 && apt-get clean \ 73 && rm -rf /var/lib/apt/lists/* /var/log/*log /var/log/apt/* /var/lib/dpkg/*-old /var/cache/debconf/*-old; fi 74 75# hadolint ignore=DL3008 76RUN if [ "$TARGETARCH" = "arm64" ]; then \ 77 # On AArch64, `setcap` binary should be installed via `libcap2-bin`. 78 # The `setcap` binary is used in integration tests. 79 # `libguestfs-tools` is used for modifying cloud image kernel, and it requires 80 # kernel (any version) image in `/boot` and modules in `/lib/modules`. 81 apt-get update \ 82 && apt-get -yq upgrade \ 83 && apt-get install --no-install-recommends -yq \ 84 libcap2-bin \ 85 libguestfs-tools \ 86 linux-image-generic \ 87 autotools-dev \ 88 autoconf \ 89 automake \ 90 perl \ 91 texinfo \ 92 && apt-get clean \ 93 && rm -rf /var/lib/apt/lists/* /var/log/*log /var/log/apt/* /var/lib/dpkg/*-old /var/cache/debconf/*-old; fi 94 95# Fix the libssl-dev install 96# hadolint ignore=SC2155 97RUN export ARCH="$(uname -m)" \ 98 && cp /usr/include/"$ARCH"-linux-gnu/openssl/opensslconf.h /usr/include/openssl/ 99ENV X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu/ 100ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu/ 101ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu/ 102ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu/ 103ENV OPENSSL_INCLUDE_DIR=/usr/include/ 104 105# Install the rust toolchain 106# hadolint ignore=DL4006,SC2155 107RUN export ARCH="$(uname -m)" \ 108 && nohup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain "$RUST_TOOLCHAIN" \ 109 && rustup target add "$ARCH"-unknown-linux-musl --toolchain "$RUST_TOOLCHAIN" \ 110 && if [ "$TARGETARCH" = "amd64" ]; then \ 111 rustup toolchain add --profile minimal --force-non-host \ 112 $RUST_TOOLCHAIN-x86_64-unknown-linux-musl; fi \ 113 && if [ "$TARGETARCH" = "amd64" ]; then rustup component add rustfmt; fi \ 114 && if [ "$TARGETARCH" = "amd64" ]; then rustup component add clippy; fi \ 115 && rm -rf "$CARGO_HOME/registry" \ 116 && ln -s "$CARGO_REGISTRY_DIR" "$CARGO_HOME/registry" \ 117 && rm -rf "$CARGO_HOME/git" \ 118 && ln -s "$CARGO_GIT_REGISTRY_DIR" "$CARGO_HOME/git" 119 120# Set the rust environment 121# hadolint ignore=SC2016 122RUN echo 'source $CARGO_HOME/env' >> "$HOME"/.bashrc \ 123 && mkdir "$HOME"/.cargo \ 124 && ln -s $CARGO_HOME/env "$HOME"/.cargo/env 125 126# Allow pip to install packages system wide 127# hadolint ignore=DL3003,SC2046 128RUN rm /usr/lib/python3.12/EXTERNALLY-MANAGED \ 129 && git clone https://github.com/spdk/spdk \ 130 && cd spdk \ 131 && git checkout ef8bcce58f3f02b79c0619a297e4f17e81e62b24 \ 132 && git submodule update --init \ 133 && apt-get update \ 134 && ./scripts/pkgdep.sh \ 135 && apt-get clean \ 136 && ./configure --with-vfio-user \ 137 && if [ "$TARGETARCH" = "amd64" ]; then \ 138 make -j $(nproc) TARGET_ARCHITECTURE=skylake; \ 139 elif [ "$TARGETARCH" = "arm64" ]; then \ 140 make -j $(nproc) TARGET_ARCHITECTURE="armv8.2-a" DPDKBUILD_FLAGS="-Dplatform=generic"; \ 141 else \ 142 echo "Unsupported architecture: ${TARGETARCH}" && exit 1; \ 143 fi \ 144 && rm -rf /usr/local/bin/spdk-nvme \ 145 && mkdir /usr/local/bin/spdk-nvme \ 146 && cp -f ./build/bin/nvmf_tgt /usr/local/bin/spdk-nvme \ 147 && cp -f ./scripts/rpc.py /usr/local/bin/spdk-nvme \ 148 && cp -rf ./python/spdk/ /usr/local/bin/spdk-nvme \ 149 && cp -rf ./python /usr/local/bin \ 150 && cd .. && rm -rf spdk 151 152# install ethr tool for performance tests 153RUN if [ "$TARGETARCH" = "amd64" ]; then \ 154 wget -nv https://github.com/microsoft/ethr/releases/latest/download/ethr_linux.zip \ 155 && unzip ethr_linux.zip \ 156 && cp ethr /usr/local/bin \ 157 && rm ethr_linux.zip; fi 158