#!/bin/sh # Build the Lean image of the `build` check, on the machine whose runner will use it. # # sh docker/build.sh [] # # MIRRORS=cn take apt and seven of the Lean packages from the mirrors a host in Beijing can reach (lean.Dockerfile's ARGs) # CPUSET=32-63 the cores the build may use (Docker's classic builder honours it; the default is all of them) # # The tag is the one the project's rules name for the `build` check (scienceslack.json) unless given. One # `docker build` of lean.Dockerfile with the checkout as its context: the tools and the toolchain, the dependencies # with Mathlib's cache (a layer that stays while lakefile.toml, lake-manifest.json and lean-toolchain stay), then the # tree and its build. set -eu main=$(cd "$1" && pwd) tag=${2:-$(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["checks"]["build"]["image"])' "$main/scienceslack.json")} if [ -e "$main/.lake" ]; then echo "$main holds .lake: build from a clean checkout" >&2; exit 2; fi cpus=${CPUSET:+--cpuset-cpus $CPUSET} mirrors= if [ "${MIRRORS:-}" = cn ]; then mirrors="--build-arg APT_MIRROR=http://mirrors.aliyun.com/ubuntu --build-arg GIT_MIRROR=https://mirror.sjtu.edu.cn/git/lean4-packages" fi # (the classic builder: BuildKit ignores --cpuset-cpus; the host's network: through Docker's bridge downloads crawl) DOCKER_BUILDKIT=0 docker build --network host $cpus $mirrors -f "$main/docker/lean.Dockerfile" -t "$tag" "$main" docker image inspect --format "$tag {{.Id}} {{.Size}} bytes" "$tag"