2021-04-21 09:46:17 +00:00
|
|
|
FROM ubuntu:20.04 as dev
|
2020-01-29 11:48:46 +00:00
|
|
|
|
2020-09-28 11:49:07 +00:00
|
|
|
ARG TARGETARCH
|
2021-09-10 13:34:44 +00:00
|
|
|
ARG RUST_TOOLCHAIN="1.55.0"
|
2020-01-29 11:48:46 +00:00
|
|
|
ARG CLH_SRC_DIR="/cloud-hypervisor"
|
|
|
|
ARG CLH_BUILD_DIR="$CLH_SRC_DIR/build"
|
|
|
|
ARG CARGO_REGISTRY_DIR="$CLH_BUILD_DIR/cargo_registry"
|
|
|
|
ARG CARGO_GIT_REGISTRY_DIR="$CLH_BUILD_DIR/cargo_git_registry"
|
|
|
|
|
|
|
|
ENV CARGO_HOME=/usr/local/rust
|
|
|
|
ENV RUSTUP_HOME=$CARGO_HOME
|
|
|
|
ENV PATH="$PATH:$CARGO_HOME/bin"
|
|
|
|
|
|
|
|
# Install all CI dependencies
|
2020-04-16 02:02:42 +00:00
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get -yq upgrade \
|
|
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq \
|
2020-01-29 11:48:46 +00:00
|
|
|
build-essential \
|
|
|
|
bc \
|
|
|
|
docker.io \
|
|
|
|
curl \
|
|
|
|
wget \
|
|
|
|
sudo \
|
|
|
|
mtools \
|
2020-04-28 13:08:32 +00:00
|
|
|
musl-tools \
|
2020-01-29 11:48:46 +00:00
|
|
|
libssl-dev \
|
|
|
|
pkg-config \
|
|
|
|
flex \
|
|
|
|
bison \
|
|
|
|
libelf-dev \
|
|
|
|
qemu-utils \
|
|
|
|
qemu-system \
|
|
|
|
libglib2.0-dev \
|
|
|
|
libpixman-1-dev \
|
|
|
|
libseccomp-dev \
|
|
|
|
libcap-ng-dev \
|
|
|
|
socat \
|
|
|
|
dosfstools \
|
2020-03-23 18:07:18 +00:00
|
|
|
cpio \
|
2021-04-26 05:51:33 +00:00
|
|
|
python \
|
|
|
|
python3 \
|
2020-09-28 06:30:11 +00:00
|
|
|
python3-setuptools \
|
2021-05-18 10:25:19 +00:00
|
|
|
ntfs-3g \
|
2021-05-27 10:44:14 +00:00
|
|
|
openvswitch-switch-dpdk \
|
2021-04-26 05:51:33 +00:00
|
|
|
python3-distutils \
|
|
|
|
uuid-dev \
|
2020-01-29 11:48:46 +00:00
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2021-05-27 10:44:14 +00:00
|
|
|
RUN update-alternatives --set ovs-vswitchd /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk
|
|
|
|
|
2020-09-28 11:49:07 +00:00
|
|
|
RUN if [ "$TARGETARCH" = "amd64" ]; then \
|
2020-04-16 02:02:42 +00:00
|
|
|
apt-get update \
|
|
|
|
&& apt-get -yq upgrade \
|
|
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq gcc-multilib \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*; fi
|
|
|
|
|
2020-09-28 11:49:07 +00:00
|
|
|
RUN if [ "$TARGETARCH" = "arm64" ]; then \
|
2020-07-01 03:19:18 +00:00
|
|
|
# On AArch64, `setcap` binary should be installed via `libcap2-bin`.
|
|
|
|
# The `setcap` binary is used in integration tests.
|
2021-09-23 00:57:07 +00:00
|
|
|
# `libguestfs-tools` is used for modifying cloud image kernel, and it requires
|
|
|
|
# kernel (any version) image in `/boot` and modules in `/lib/modules`.
|
2020-07-01 03:19:18 +00:00
|
|
|
apt-get update \
|
|
|
|
&& apt-get -yq upgrade \
|
2021-09-23 00:57:07 +00:00
|
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -yq \
|
|
|
|
libcap2-bin \
|
|
|
|
libguestfs-tools \
|
|
|
|
linux-image-5.8.0-63-generic \
|
2020-07-01 03:19:18 +00:00
|
|
|
&& apt-get clean \
|
2021-05-07 13:40:59 +00:00
|
|
|
&& rm -rf /var/lib/apt/lists/*; fi
|
2020-07-01 03:19:18 +00:00
|
|
|
|
2020-04-28 13:08:32 +00:00
|
|
|
# Fix the libssl-dev install
|
2020-09-29 07:06:37 +00:00
|
|
|
RUN export ARCH="$(uname -m)" \
|
|
|
|
&& cp /usr/include/$ARCH-linux-gnu/openssl/opensslconf.h /usr/include/openssl/
|
|
|
|
ENV X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu/
|
|
|
|
ENV X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu/
|
|
|
|
ENV AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu/
|
|
|
|
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR=/usr/lib/aarch64-linux-gnu/
|
2020-04-28 13:08:32 +00:00
|
|
|
ENV OPENSSL_INCLUDE_DIR=/usr/include/
|
|
|
|
|
2020-01-29 11:48:46 +00:00
|
|
|
# Install the rust toolchain
|
2020-09-29 07:06:37 +00:00
|
|
|
RUN export ARCH="$(uname -m)" \
|
|
|
|
&& nohup curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_TOOLCHAIN" \
|
|
|
|
&& rustup target add $ARCH-unknown-linux-musl --toolchain "$RUST_TOOLCHAIN" \
|
2020-09-28 11:49:07 +00:00
|
|
|
&& if [ "$TARGETARCH" = "amd64" ]; then rustup toolchain add $RUST_TOOLCHAIN-x86_64-unknown-linux-musl; fi \
|
|
|
|
&& if [ "$TARGETARCH" = "amd64" ]; then rustup component add rustfmt; fi \
|
|
|
|
&& if [ "$TARGETARCH" = "amd64" ]; then rustup component add clippy; fi \
|
2020-01-29 11:48:46 +00:00
|
|
|
&& cargo install cargo-audit \
|
|
|
|
&& rm -rf "$CARGO_HOME/registry" \
|
|
|
|
&& ln -s "$CARGO_REGISTRY_DIR" "$CARGO_HOME/registry" \
|
|
|
|
&& rm -rf "$CARGO_HOME/git" \
|
|
|
|
&& ln -s "$CARGO_GIT_REGISTRY_DIR" "$CARGO_HOME/git"
|
|
|
|
|
|
|
|
# Set the rust environment
|
|
|
|
RUN echo 'source $CARGO_HOME/env' >> $HOME/.bashrc \
|
|
|
|
&& mkdir $HOME/.cargo \
|
|
|
|
&& ln -s $CARGO_HOME/env $HOME/.cargo/env
|
2021-09-17 15:52:20 +00:00
|
|
|
|
|
|
|
# install virtiofsd
|
|
|
|
RUN git clone --depth 1 https://gitlab.com/virtio-fs/qemu.git -b qemu5.0-virtiofs-dax \
|
|
|
|
&& cd qemu \
|
|
|
|
&& ./configure --prefix=$PWD --target-list=x86_64-softmmu \
|
|
|
|
&& make virtiofsd -j `nproc` \
|
|
|
|
&& cp virtiofsd /usr/local/bin \
|
|
|
|
&& cd .. && rm -rf qemu
|