crosvm/ci/crosvm_base/Dockerfile
Dennis Kempin aa0717443e Add VM to builders
The VM allows both the x86 and aarch64 builders to run tests which
require access to kernel devices that docker would prevent us
from accessing.
The VM is automatically started in the endpoint script, and the
environment is set up to execute `cargo test` binaries inside the VM.

This allows for convenient interactive usage.
The VM is also integrated into the run_tests scripts, executing tests
that do not require special privileges first, while the VM is still
booting up, then execuing the remaining tests in the VM.

BUG=b:177228167,b:177951276
TEST=These test calls pass:
./ci/builder --vm ./run_tests
./ci/aarch64_builder --vm ./run_tests
./run_tests

Change-Id: I20bf2cd848e944d411b97f1f8356279e312d8583
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2642766
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-02-05 03:01:53 +00:00

73 lines
2.3 KiB
Docker

# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Base image for crosvm_builder and crosvm_aarch64_builder containing basic
# devleopment environment for building rust.
# TODO(b/177078591): Use debian buster and backports (or manual dpkg downloads)
# of outdated libraries. Sid could blow up on us any day.
FROM debian:buster
# Set timezone so apt-get won't try to prompt
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=US/Pacific
# Add bullseye to sources so we can install some newer versions of packages.
RUN echo 'deb http://deb.debian.org/debian bullseye main' > /etc/apt/sources.list.d/testing.list
RUN echo 'APT::Default-Release "stable";' > /etc/apt/apt.conf.d/99_default_stable
RUN apt-get update && apt-get install --yes --no-install-recommends \
ca-certificates \
curl \
g++ \
gcc \
git \
jq \
make \
meson/testing \
nasm \
ninja-build \
openssh-client \
pkg-config \
protobuf-compiler \
python3 \
python3-setuptools \
rsync \
screen \
sudo
# This is a scratch volume for build files. It can be used to allow incremental
# builds between container runs.
VOLUME /workspace/scratch
# This is where the chromiumos source tree will be mounted
VOLUME /workspace/src
# Install the current crosvm rust toolchain via rustup.
COPY rust-toolchain ./
RUN curl https://sh.rustup.rs -sSf | sh -s -- \
-y \
--profile minimal \
-c rustfmt,clippy \
--default-toolchain $(cat rust-toolchain)
ENV PATH="/root/.cargo/bin:${PATH}"
# Point cargo to store data on the scratch volume.
ENV CARGO_TARGET_DIR=/workspace/scratch/cargo_target
ENV CARGO_HOME=/workspace/scratch/cargo_home
# Warms up the cargo registry cache for future cargo runs. Cargo will still
# update the cache using a git pull, but it only needs to download files that
# were changed since this image was built.
RUN cargo install thisiznotarealpackage -q || true
# We are building out of source with a readonly source filesystem. This flag
# tells some build.rs files to not write into the src filesystem.
ENV RUSTFLAGS='--cfg hermetic'
# Environment variables for the run_tests script to enable all tests.
ENV CROSVM_CROS_BUILD=1
# All commands will be executed in the crosvm src directory.
WORKDIR /workspace/src/platform/crosvm