# Lean image `lean.Dockerfile` builds the image the birch-swinnerton-dyer build check runs in. Tag: ``` shoal-bsd-lean:9cb92e9a ``` `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/bsd-main sh /tmp/bsd-main/docker/build.sh /tmp/bsd-main # tag: the one scienceslack.json names MIRRORS=cn CPUSET=64-127 sh /tmp/bsd-main/docker/build.sh /tmp/bsd-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, plausible and LeanSearchClient still come from github.com, each tried ten times. The build needs the network (GitHub, the Lean release, Mathlib's cache). 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:05a29805926e444badb3922d8898a1d7098fe79083bbd0102774fbd68e70edcd`, 3.2 GB, 15 minutes, of which the project's build was 4.5 minutes. Both checks passed on main with the runner's flags: `build` in 143 s at 4 CPUs, 1.7 GB of memory, of which Comparator (exports of 138 MB and 275 MB, Lean's kernel and nanoda) took 91 s. ## 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): b-mehta/EllipticCurveRank at its pinned commit without `.github` (`upstream.json`'s `drop`), with this project's files on top, and what has been merged since; `.lake` fully built (Mathlib and its dependencies from the cache, then every library of `lakefile.toml`: ECCompute, Curves, Statement, Solution 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`, and runs `lake build`, `lake env lean 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`. The image puts the toolchain's `nanoda_bin` and `leanchecker` on `PATH`. Measured 2026-12-01 with the same pins on a 256-core machine: `lake exe cache get` then `lake build ECCompute Curves` took 1 min 38 s (101 CPU-minutes; the curve files take up to about a minute each, every one reducing its certificate in the kernel); `Statement`, `Solution` and `Challenge` add under a minute; `PrintAxioms.lean` reports `propext`, `Classical.choice` and `Quot.sound` for all 480 theorems. Comparator itself was not run there (no `bwrap` on that machine). ## 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 Mathlib's checkout against them, and fails otherwise. | ARG | Value | Source | | --- | --- | --- | | `UPSTREAM_COMMIT` | `9cb92e9a7ddf28666d89cb221a89fb35de75b4d3` | b-mehta/EllipticCurveRank, `upstream.json` | | `TOOLCHAIN` | `leanprover/lean4:v4.36.0` | upstream `lean-toolchain` | | `LEAN_SHA256` | `2b7ab1ed8b92d2e6abfaf41344823b510064dbc9c0260cac73eb496ab2dea6eb` | the digest GitHub lists for `lean-4.36.0-linux.tar.zst` | | `MATHLIB_COMMIT` | `fc4f59e577feb1a4956671bc04ac18aaaf8cd842` | upstream `lake-manifest.json` (`lakefile.toml` asks for tag `v4.36.0`) | ## 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 (a new Lean release or Mathlib pin): 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. New curves (piece S-2) are such a change: a rebuild makes their `build` faster, not possible.