# Lean image for the goldbach-spectral-bridge `build` check (checks/build.py). # # Build with a checkout of the project's main as the context, not this folder: # git clone /tmp/goldbach-main # git -C /tmp/goldbach-main checkout # docker build -f docker/lean.Dockerfile -t shoal-goldbach-lean:c55db645 /tmp/goldbach-main # # The project is the folder formalization/ of subfish-zhou/conditional-goldbach-lean at c55db645, without the # generated reports (upstream.json), with this project's lakefile.toml on top: it adds the upstream's own Comparator # project (verification/independent-audit/comparator-project/TexAuditComparator) and the open statements (Open.lean) # as libraries of the one package. Cloning upstream would give neither, so the image is built from the project's own # tree: COPY puts it in /opt/proof. The check runs with --network none: it copies a commit's tree to a scratch # directory, gives it /opt/proof/.lake, and runs lake build and `lake comparator --config comparator.json`. Nothing is # downloaded at check time. # # Every pin is a full commit hash in an ARG below, checked once the dependencies are fetched. FROM ubuntu:24.04 # --- Pins ------------------------------------------------------------------- # subfish-zhou/conditional-goldbach-lean, and its formalization/lean-toolchain at that commit. ARG UPSTREAM_COMMIT=c55db645f3b4aed00374fe4aa1fcee2428c88c4b ARG TOOLCHAIN=leanprover/lean4:v4.35.0 # From lake-manifest.json at that commit. ARG MATHLIB_COMMIT=56a005855ea17e0b0958f73ec801ae140b0a1679 ARG GOLDBACH_COMMIT=24490c2ab7787238f816d771c9176411dcbda503 ARG LEANARCHITECT_COMMIT=9f3bb53916b9d6fa05b7777389e1844f82b1c9a6 # Comparator: Lean v4.35.0 ships it as `lake comparator` (sandboxed with bubblewrap), with its exporter, nanoda_bin and # leanchecker beside it; the upstream's own audit ran exactly that (verification/independent-audit/comparator-manifest.json). # --- System packages -------------------------------------------------------- # python3 and curl are what Mathlib's cache tool uses; bubblewrap is the sandbox `lake comparator` runs in. ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates curl git python3 build-essential zstd bubblewrap \ && rm -rf /var/lib/apt/lists/* # The check may run as another user than the one that built; let git (and Lake, which calls git in each package) # read every repository in the image. RUN git config --system --add safe.directory '*' # --- Lean ------------------------------------------------------------------- ENV ELAN_HOME=/opt/elan ENV PATH=/usr/local/bin:/opt/elan/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin RUN curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh \ | sh -s -- -y --no-modify-path --default-toolchain none RUN elan toolchain install "${TOOLCHAIN}" \ && elan default "${TOOLCHAIN}" # --- The project ------------------------------------------------------------ # The context is a checkout of the project's main: its tree goes in whole, as the check's commits will be. COPY . /opt/proof WORKDIR /opt/proof RUN rm -rf .git .lake \ && test "$(cat lean-toolchain)" = "${TOOLCHAIN}" \ && grep -q "${UPSTREAM_COMMIT}" docker/lean.Dockerfile # Mathlib's cache, then the dependencies at their pins, then a full build of the default targets (the library, the # Comparator project and the open statements), so a pull request's build recompiles only what it changed. RUN lake exe cache get \ && test "$(git -C .lake/packages/mathlib rev-parse HEAD)" = "${MATHLIB_COMMIT}" \ && test "$(git -C .lake/packages/goldbach rev-parse HEAD)" = "${GOLDBACH_COMMIT}" \ && test "$(git -C .lake/packages/LeanArchitect rev-parse HEAD)" = "${LEANARCHITECT_COMMIT}" \ && rm -rf /root/.cache/mathlib RUN lake build # --- Comparator's second kernel --------------------------------------------- RUN ln -s "$(elan which --toolchain "${TOOLCHAIN}" nanoda_bin)" /usr/local/bin/nanoda_bin \ && ln -s "$(elan which --toolchain "${TOOLCHAIN}" leanchecker)" /usr/local/bin/leanchecker \ && lake comparator --help >/dev/null RUN for t in bwrap nanoda_bin leanchecker lake lean; do \ command -v "$t" >/dev/null || { echo "missing: $t"; exit 1; }; \ done ENV PROOF_BASE=/opt/proof WORKDIR /opt/proof CMD ["/bin/bash"]