mirror of
https://github.com/storytold/autocraft.git
synced 2026-11-27 16:49:34 +01:00
65 lines
4.7 KiB
Docker
65 lines
4.7 KiB
Docker
# Toolchain image "rust-stable" for build pods (kubernetes build environments, docs/operations.md "Build pods").
|
|
# The pods cannot build images or install packages, so this image carries what the craft apps' CI gates commonly
|
|
# install: the windowing, GL/Vulkan, GTK, font, audio and D-Bus development packages, plus clippy and rustfmt. A task
|
|
# whose CI gate names a package missing here fails with that package named.
|
|
#
|
|
# Workspace pods (AUTO-27) use the same image: Xvfb and Mesa's software Vulkan (lavapipe) and GL (llvmpipe) to
|
|
# run the app headless, ImageMagick and x11-utils for screenshots, ripgrep for the grep tool, and fallback fonts
|
|
# so every screenshot shows the same glyphs. Mesa is pinned by the image digest, so before and after shots match.
|
|
#
|
|
# Build steps read the CI runners' shared compile cache (sccache, docs/operations.md "Build pods"). sccache keys a
|
|
# compile on the compiler's libraries and version and on its own release, so the Rust release here must be the one
|
|
# the CI gate's `stable` installs (bump it with each stable release) and sccache the release the gate pins.
|
|
#
|
|
# Build pods are offline with a read-only rustup home, so rustup cannot install what a repository's
|
|
# rust-toolchain.toml asks for: its `channel` must be the release here, and its `components` and `targets` must be
|
|
# installed here. The wasm32 target is the one the pipeline repositories' toolchain files add.
|
|
#
|
|
# The last step writes the toolchain file /usr/local/share/autocraft/toolchain.txt: what can change compiled output, namely
|
|
# the Rust release, its components and targets, the sccache release, and the versions of the C toolchain (gcc, g++, cpp,
|
|
# binutils, pkg-config), of the tools build scripts run or load (clang, libclang, llvm, cmake, make, ninja, nasm, yasm,
|
|
# protoc, perl, python3) and of every `-dev` package (headers and .pc files build scripts probe, libc6-dev among them).
|
|
# Warm versions are matched on its sha256 and `rustc -vV` (src/warm/toolchain.ts), so a rebuild that changes none of these
|
|
# keeps every warm cache. So does adding a package that no build script runs, loads or links against, such as Xvfb, Mesa's
|
|
# drivers, ImageMagick, ripgrep or a runtime library without its -dev package; such a package can still change what a test
|
|
# or a screenshot sees, not what is compiled. The image holds no
|
|
# AutoCraft code: pods run AutoCraft's phases from the AutoCraft image and its step scripts come with the pod spec.
|
|
#
|
|
# podman build -f deploy/container/Containerfile.rust-stable -t rust-stable deploy/container
|
|
FROM docker.io/library/rust:1.100.0-bookworm
|
|
|
|
RUN set -eux; \
|
|
apt-get update; \
|
|
apt-get install -y --no-install-recommends \
|
|
pkg-config libx11-dev libxcb1-dev libxkbcommon-dev libwayland-dev libxrandr-dev libxi-dev libxcursor-dev \
|
|
libgl1-mesa-dev libegl1 libvulkan1 mesa-vulkan-drivers libgtk-3-dev libfontconfig1-dev libfreetype-dev \
|
|
libasound2-dev libdbus-1-dev poppler-utils qpdf libxkbcommon-x11-0 libxcb-xkb1 \
|
|
xvfb x11-utils xauth libgl1-mesa-dri imagemagick ripgrep \
|
|
fonts-dejavu-core fonts-noto-core fonts-noto-cjk fonts-noto-color-emoji; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
rustup component add clippy rustfmt; \
|
|
rustup target add wasm32-unknown-unknown; \
|
|
rm -rf "$CARGO_HOME/registry" "$CARGO_HOME/git"; \
|
|
chmod -R a+rX /usr/local/rustup /usr/local/cargo; \
|
|
sccache=0.18.0; \
|
|
case "$(uname -m)" in \
|
|
x86_64) arch=x86_64; sum=45f1447fbe231e3037bde351ef70677dd212216c8d62ae7ca409fecc4d6acc89 ;; \
|
|
aarch64) arch=aarch64; sum=2b3284d5da3b46a47dc4229e75bb7b88ac4aa99c8d754fb7d2f84997e5a4354a ;; \
|
|
*) echo "no sccache build for $(uname -m)" >&2; exit 1 ;; \
|
|
esac; \
|
|
name="sccache-v$sccache-$arch-unknown-linux-musl"; \
|
|
curl -fsSL -o /tmp/sccache.tar.gz "https://github.com/mozilla/sccache/releases/download/v$sccache/$name.tar.gz"; \
|
|
echo "$sum /tmp/sccache.tar.gz" | sha256sum -c -; \
|
|
tar -xzf /tmp/sccache.tar.gz -C /tmp; \
|
|
install -m 0755 "/tmp/$name/sccache" /usr/local/bin/sccache; \
|
|
rm -rf /tmp/sccache.tar.gz "/tmp/$name"; \
|
|
sccache --version; \
|
|
mkdir -p /usr/local/share/autocraft; \
|
|
{ rustc -vV; rustup component list --installed; rustup target list --installed; sccache --version; \
|
|
dpkg-query -W -f '${binary:Package} ${Version}\n' \
|
|
| LC_ALL=C grep -E '^((gcc|g\+\+|cpp|binutils|pkg-config|pkgconf|cmake|protobuf-compiler)(-[^: ]+)?|(clang|libclang|llvm)[^: ]*|make|ninja-build|nasm|yasm|perl|perl-base|python3|python3\.[0-9]+|[^: ]+-dev)(:[a-z0-9]+)? ' | LC_ALL=C sort; } > /usr/local/share/autocraft/toolchain.txt; \
|
|
chmod 0644 /usr/local/share/autocraft/toolchain.txt
|
|
|
|
# The uid build pods run as (the AutoCraft image's); steps write only to their mounts (the checkout, target dir, /cache, /out, /tmp).
|
|
USER 10001:10001
|