# Lean image `lean.Dockerfile` builds the image the riemann-hypothesis build check runs in. Tag: ``` shoal-rh-lean:630d1e43 ``` `scienceslack.json` refers to this exact name. ## Build On the machine whose runner will use it, with a checkout of the project's main as the context (not this folder, and not a clone of upstream: the image is the build of our main): ```bash git clone /tmp/rh-main sh /tmp/rh-main/docker/build.sh /tmp/rh-main # tag: the one scienceslack.json names MIRRORS=cn CPUSET=64-127 sh /tmp/rh-main/docker/build.sh /tmp/rh-main # on the Beijing host, on those cores ``` `build.sh` is one `docker build` with the classic builder and the host's network. `MIRRORS=cn` takes apt from Aliyun, the Lean release and seven of the Lean packages (Mathlib among them) from SJTU's mirror; elan, Tau Ceti, plausible and LeanSearchClient still come from github.com, each tried ten times. The build needs the network (GitHub, the Lean release, the Mathlib, Tau Ceti and project caches). Nothing is published: the runner that runs the check must have the image locally. Built on the production host on 2026-12-02 (16 cores, `MIRRORS=cn`): image `sha256:da30feeb683371b767e16bc1eccb85f55e8261b3fc17ccfcc2d6fe2feecc707a`, 5.3 GB, 19 minutes. Upstream's cache had the project's build for `630d1e43`, so `lake build` of the four libraries took 11 s (26,379 jobs; `.lake/build` 2.2 GB). On main, with the runner's flags: the per-push `build` (`"replay": "round"`: build, `sorry` scan, the theorems' axioms as the commit's Lean reports them) 17 s at 4 CPUs, 0.9 GB; the full replay exports 4.7 GB in 4 minutes, nanoda takes about 10 minutes, and Lean's kernel had run 90 minutes and held 62 GB without a verdict when the run was stopped (07:47): it runs once per maintainer round. ## What is in it - `/opt/elan`: elan with the upstream's toolchain installed and set as the default, so `lake` works offline. - `/opt/proof`: the project's main (the context), with `.lake` fully built (dependencies, their oleans, and every library of `lakefile.toml`: Lib, New, Main and Challenge). `PROOF_BASE=/opt/proof`. `.lake/build` belongs to `nobody`, and everything under `/opt` is readable by `nobody`: the check compiles a commit as that user. - On `PATH`: `lake` (with `lake comparator`), `lean`, `nanoda_bin`, `leanchecker`, `bwrap`; also `python3`, `git`, `curl`, `zstd` and a C toolchain. ## How the check uses it The check runs the image with `--network none`. It copies the pushed commit's tree to a writable directory, gives it `/opt/proof/.lake` (or links its `packages`), and runs `lake build`, `lake env lean scripts/PrintAxioms.lean` and `lake comparator --config comparator.json`. Lake then recompiles only what the commit changed. `lake exe cache get` cannot run there, which is why the image does it at build time. The project does not depend on Comparator, and the image builds none: since v4.35.0 Lean ships it as `lake comparator` (sandboxed with bubblewrap), with its exporter and `nanoda_bin`, as the goldbach-spectral-bridge image uses them. The standalone `leanprover/comparator` and `lean4export` are deprecated and have no tag for v4.37.0-rc1. The check runs `lake comparator --config comparator.json`; the image puts the toolchain's `nanoda_bin` and `leanchecker` on `PATH`. The image fetches three caches, as upstream's `lake exe cache get` (`scripts/lake-cache-get.sh`) does: Mathlib's in the dependencies' layer, then Tau Ceti's (`scripts/tauceti-cache-get.py`) and the project's own (`scripts/ci-cache-get.py`; Python 3.11+ and curl 7.71+, which Ubuntu 24.04 has). The project's cache is what upstream's CI published for the `src` tree, `lakefile.toml`, `lake-manifest.json` and toolchain of its own commits: it matches while our main's `src` is byte for byte a commit of upstream's main (at the pin it is: upstream has a record for `630d1e43`), and no longer once we have merged our own changes. Then exit 3 (no record) is accepted and the full `lake build` that follows compiles what the caches did not supply, about 4 CPU-hours from nothing. ## Pins All pins are full hashes in `ARG`s at the top of `lean.Dockerfile`. The build checks the context's `lean-toolchain`, the toolchain file's SHA-256 and the Mathlib and Tau Ceti checkouts against them, and fails otherwise. | ARG | Value | Source | | --- | --- | --- | | `UPSTREAM_COMMIT` | `630d1e43b442cab27717c3ebf94d218dea608374` | leanprover-community/riemann-hypothesis, `upstream.json` | | `TOOLCHAIN` | `leanprover/lean4:v4.37.0-rc1` | upstream `lean-toolchain` | | `LEAN_SHA256` | `2e1bbb832870bb81b7131cb70b13aec2cc7ed9f22e2bdbb236b86076ae20382d` | the digest GitHub lists for `lean-4.37.0-rc1-linux.tar.zst` | | `MATHLIB_COMMIT` | `31ce06eaadf4a200c0e1407c5f10953cf606b8f8` | upstream `lakefile.toml` / `lake-manifest.json` | | `TAUCETI_COMMIT` | `2a9233e5be32675476ae438bef6f6dd4ba93eb64` | upstream `lakefile.toml` / `lake-manifest.json` | ## Rebuild when main moves The image is the build of one commit of main. Rebuild it, under a new tag, whenever main's `lean-toolchain` or `lake-manifest.json` changes (for example a new Lean release, or new Mathlib or Tau Ceti pins): set the pins it moves in `lean.Dockerfile`, build from a checkout of the new main as above, and change the tag in `scienceslack.json` in the same PR. The check refuses a commit whose `lean-toolchain` differs from the image's. Rebuilding after other changes to main is optional: it only makes the checks faster, since less has to be recompiled.