• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 The ChromiumOS Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5# Development container for crosvm.
6#
7# Provides all dependencies specified in tools/deps/* with some additonal
8# logic to cache cargo data in CI runs.
9#
10# Uses the crosvm_dev_base image built by Dockerfile.base
11#
12# See Makefile for build instructions
13
14# Build catapult dashboard upload tool in a builder container
15FROM docker.io/golang:bullseye AS gobuilder
16WORKDIR /root/
17RUN git clone https://fuchsia.googlesource.com/infra/infra
18WORKDIR /root/infra/cmd/catapult
19RUN go build
20
21ARG BASE_VERSION
22FROM crosvm_dev_base:${BASE_VERSION}
23
24ENV RUSTUP_HOME=/usr/local/rustup \
25    CARGO_HOME=/usr/local/cargo \
26    PATH=/workspace/tools:/usr/local/cargo/bin:$PATH
27
28# Install pipx applications globally in /usr/local/bin
29ENV PIPX_HOME=/usr/local/pipx \
30    PIPX_BIN_DIR=/usr/local/bin
31
32# Use a dedicated target directory so we do not write into the source directory.
33RUN mkdir -p /scratch/cargo_target \
34    && mkdir /cache
35
36# Prevent the container from writing __pycache__ files into the src.
37ENV PYTHONDONTWRITEBYTECODE=1
38ENV CARGO_TARGET_DIR=/scratch/cargo_target
39
40# Allow APT to cache packages between docker image builds
41RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
42
43# Add foreign architectures for cross-compilation.
44RUN dpkg --add-architecture arm64 \
45    && dpkg --add-architecture armhf
46
47# Add wine64 to PATH, as debian removed alternative entry to wine64
48ENV PATH=/usr/lib/wine:$PATH
49
50# Install non-debian dependencies. Debian packages are installed in the base image in Dockefile.base
51COPY --chmod=555 \
52    tools/deps/install-x86_64-other \
53    tools/deps/install-aarch64-other \
54    tools/deps/install-armhf-other \
55    tools/deps/install-mingw64-other \
56    rust-toolchain \
57    /tools/deps/
58RUN cd /tools/deps \
59    && ./install-x86_64-other \
60    && ./install-aarch64-other \
61    && ./install-armhf-other \
62    && ./install-mingw64-other \
63    # We only use the nightly toolchain for rustfmt, remove other parts to save space.
64    && rustup component remove --toolchain nightly rust-std \
65    && rustup component remove --toolchain nightly cargo
66
67# Install global config.toml for cross-compilation
68COPY --chmod=555 .cargo/config.debian.toml /.cargo/config.toml
69
70# Install catapult dashboard upload tool
71COPY --from=gobuilder /root/infra/cmd/catapult/catapult /tools/
72
73# Cache CARGO_HOME between container runs in CI.
74VOLUME /cache
75ENV CROSVM_CACHE_DIR=/cache
76ENV CARGO_HOME=/cache/cargo_home
77
78VOLUME /workspace
79WORKDIR /workspace
80