• 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 install-deps with some additonal
8# logic to cache cargo data in CI runs.
9#
10# Note, if you are using docker, you will probably be using "Dockerfile.user".
11
12# Build catapult dashboard upload tool in a builder container
13FROM docker.io/golang:bullseye AS gobuilder
14WORKDIR /root/
15RUN git clone https://fuchsia.googlesource.com/infra/infra
16WORKDIR /root/infra/cmd/catapult
17RUN go build
18
19FROM docker.io/debian:testing-slim
20
21ENV RUSTUP_HOME=/usr/local/rustup \
22    CARGO_HOME=/usr/local/cargo \
23    PATH=/workspace/tools:/usr/local/cargo/bin:$PATH
24
25# Install pipx applications globally in /usr/local/bin
26ENV PIPX_HOME=/usr/local/pipx \
27    PIPX_BIN_DIR=/usr/local/bin
28
29# Use a dedicated target directory so we do not write into the source directory.
30RUN mkdir -p /scratch/cargo_target \
31    && mkdir /cache
32
33# Prevent the container from writing __pycache__ files into the src.
34ENV PYTHONDONTWRITEBYTECODE=1
35ENV CARGO_TARGET_DIR=/scratch/cargo_target
36
37# Add foreign architectures for cross-compilation.
38RUN dpkg --add-architecture arm64 \
39    && dpkg --add-architecture armhf
40
41# Allow APT to cache packages between docker image builds
42RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
43
44# Install dependencies (APT and cargo packages are cached between image builds for faster iterative builds).
45COPY --chmod=555 tools/install-deps tools/install-aarch64-deps tools/install-armhf-deps tools/install-mingw64-deps tools/setup-wine64 rust-toolchain /tools/
46RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
47    --mount=type=cache,target=/var/lib/apt,sharing=private \
48    --mount=type=cache,target=/scratch/cargo_target,sharing=private \
49    cd /tools \
50    && apt-get update \
51    && apt-get install --yes sudo \
52    && ./install-deps \
53    && ./install-aarch64-deps \
54    && ./install-armhf-deps \
55    && ./install-mingw64-deps
56
57# Add wine64 to PATH, as debian removed alternative entry to wine64
58ENV PATH=/usr/lib/wine:$PATH
59
60# Install an older version of binutils-mingw-w64-x86-64. The latest version is crashing when
61# linking crosvm. See b/265995780
62RUN wget https://snapshot.debian.org/archive/debian/20230101T091029Z/pool/main/b/binutils-mingw-w64/binutils-mingw-w64-x86-64_2.38.90.20220713-2%2B9%2Bb1_amd64.deb \
63    && dpkg -i binutils-mingw-w64-x86-64_2.38.90.20220713-2+9+b1_amd64.deb \
64    && rm binutils-mingw-w64-x86-64_2.38.90.20220713-2+9+b1_amd64.deb
65
66# Setup wine for root user
67RUN /tools/setup-wine64
68
69# Install global config.toml for cross-compilation
70COPY --chmod=555 .cargo/config.debian.toml /.cargo/config.toml
71
72# Install catapult dashboard upload tool
73COPY --from=gobuilder /root/infra/cmd/catapult/catapult /tools/
74
75# Cache CARGO_HOME between container runs in CI.
76VOLUME /cache
77ENV CROSVM_CACHE_DIR=/cache
78ENV CARGO_HOME=/cache/cargo_home
79
80VOLUME /workspace
81WORKDIR /workspace
82