crosvm/tools/impl/dev_container/Dockerfile
Dennis Kempin 365c8f9201 dev_container: Allow cargo home to be cached between runs
This Allows Luci builders to cache cargo home between builds. So we
do not have to download so many third party crates with each build.

CARGO_HOME is specifically intended to be cached in CI systems.

BUG=b:233230027
TEST=CROSVM_CONTAINER_CACHE=/tmp/test ./tools/dev_container --clean
cargo build

Change-Id: I11580c5ed3151519ece4a651cb22d059c7c3eb87
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739368
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-07 17:49:47 +00:00

53 lines
1.7 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.
ARG RUST_VERSION
FROM docker.io/rust:${RUST_VERSION}-slim-bullseye
# Use a dedicated target directory so we do not write into the source directory.
RUN mkdir -p /scratch/cargo_target
ENV CARGO_TARGET_DIR=/scratch/cargo_target
# Prevent the container from writing root-owned __pycache__ files into the src.
ENV PYTHONDONTWRITEBYTECODE=1
# Add foreign architectures for cross-compilation.
RUN dpkg --add-architecture arm64 \
&& dpkg --add-architecture armhf
# Install dependencies for native builds.
COPY tools/install-deps /tools/
COPY tools/install-docs-deps /tools/
RUN apt-get update \
&& apt-get install --yes sudo \
&& /tools/install-deps \
# Clear apt cache to save space in layer.
&& rm -rf /var/lib/apt/lists/* \
# Delete build artifacts from 'cargo install' to save space in layer.
&& rm -rf /scratch/cargo_target/*
# Prepare wine64
RUN ln -sf /usr/bin/wine64-stable /usr/bin/wine64 \
&& wine64 wineboot
# Install cross-compilation dependencies.
COPY tools/install-aarch64-deps tools/install-armhf-deps /tools/
RUN apt-get update \
&& /tools/install-aarch64-deps \
&& /tools/install-armhf-deps \
# Clear apt cache to save space in layer.
&& rm -rf /var/lib/apt/lists/*
# Prebuild aarch64 VM image for faster startup.
COPY tools/aarch64vm /tools/
COPY /tools/impl/testvm.py /tools/impl/
COPY /tools/impl/testvm/version /tools/impl/testvm/
RUN /tools/aarch64vm build
# Cache CARGO_HOME between container runs in CI.
VOLUME /cache
ENV CARGO_HOME=/cache/cargo_home
VOLUME /workspace
WORKDIR /workspace