11FROM ubuntu:24.04 AS base
22
3- # Relocate toolchains so non-root developers can access and write to them when mapping UIDs
3+ # Relocate toolchains so non-root developers can access and write to them when
4+ # mapping UIDs.
45ENV RUSTUP_HOME=/opt/rustup \
56 CARGO_HOME=/opt/cargo \
67 ELAN_HOME=/opt/elan \
78 PATH="/opt/cargo/bin:/opt/elan/bin:${PATH}"
89
9- # Install build dependencies, Rust, and Lean
1010RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git curl build-essential pkg-config libssl-dev && \
1111 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path && \
1212 rm -rf /var/lib/apt/lists/*
1313
14- # Install elan (Lean toolchain manager)
14+ # Charon strictly requires a specific nightly compiler version to execute.
15+ # FIXME: Extract this version string dynamically from `src/setup.rs` in the future.
16+ RUN rustup toolchain install --no-self-update nightly-2026-02-07 --profile minimal
17+
18+ # Install elan (Lean toolchain manager).
1519RUN curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --no-modify-path
1620
1721# Prepare a globally writable cache directory to hold both the integration test
@@ -21,44 +25,17 @@ RUN curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -
2125RUN mkdir -p /cache && chmod 777 /cache && \
2226 chmod -R a+rwX /opt/rustup /opt/cargo /opt/elan
2327
24- # Direct Hermes tests to write ephemeral integration targets here to leverage overlayfs
28+ # Direct Hermes tests to write ephemeral integration targets here to leverage
29+ # overlayfs.
2530ENV HERMES_INTEGRATION_TARGET_DIR=/cache/hermes_target
2631WORKDIR /workspace
2732
28- # Copy vendored requirements
29- COPY .cargo .cargo
30- COPY vendor vendor
31-
32- ENV __ZEROCOPY_LOCAL_DEV="1"
33+ FROM base AS dev
3334
34- # Copy only the hermes crate logic
35- COPY Cargo.toml Cargo.toml
36- COPY build.rs build.rs
37- COPY src src
38- # Since Cargo.toml explicitly declares [[test]] "integration", this file must exist for Cargo to parse it.
39- COPY tests/integration.rs tests/integration.rs
40- # Copy tools because they are part of the workspace members
35+ COPY testdata testdata
4136COPY tools tools
4237
43- # Download and verify the required versions of Charon and Aeneas.
44- RUN cargo run --bin cargo-hermes setup && \
45- rm -rf /workspace/target /opt/cargo/registry /opt/cargo/git
46-
47- # Charon strictly requires a specific nightly compiler version to execute.
48- # FIXME: Extract this version string dynamically from `src/setup.rs` in the future.
49- RUN rustup toolchain install nightly-2026-02-07 --profile minimal && \
50- chmod -R a+rwX /opt/rustup /opt/cargo /opt/elan
51-
52- # To pre-build Mathlib for local development, we run a fast dummy test. We don't
53- # use this in CI because copying the multiple GB produced in this image is
54- # slower in CI than just re-building from scratch.
55- FROM base AS dev
56- COPY tests/fixtures/syntax_error tests/fixtures/syntax_error
57- RUN cargo test --test integration -- syntax_error && \
58- chmod -R a+rwX /cache
38+ # Download Lean/Elan and pre-build the Mathlib cache and Aeneas standard library.
39+ RUN ./tools/prebuild_lean_libs.sh
5940
60- # Any `/workspace/target` generated here will be shadowed by the host's bind
61- # mount, so removing it is purely to reduce image size slightly before
62- # shadowing. Because of this shadowing, there would be no benefit to keeping
63- # it.
64- RUN rm -rf /workspace/target
41+ RUN chmod -R a+rwX /cache /opt/rustup /opt/cargo /opt/elan
0 commit comments