From 6c18ae0940ab8e2315fcf905e5d7f184869c6eed Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 17 Jun 2026 09:45:36 +0200 Subject: [PATCH 1/3] Scaffold for cargo build images --- cargo/Dockerfile.cargo | 58 +++++++++++++++++++++++++++++++++++ cargo/builds_rust.json | 20 ++++++++++++ cargo/builds_rust.schema.json | 42 +++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 cargo/Dockerfile.cargo create mode 100644 cargo/builds_rust.json create mode 100644 cargo/builds_rust.schema.json diff --git a/cargo/Dockerfile.cargo b/cargo/Dockerfile.cargo new file mode 100644 index 0000000..1c18f72 --- /dev/null +++ b/cargo/Dockerfile.cargo @@ -0,0 +1,58 @@ +# Dockerfile.cargo — reproducible-build image for wasms built with PLAIN `cargo build` +# (the ~2,600 on-chain wasms with rsver/rssdkver but NO cliver were built without the +# stellar cli; the SDK macros still emit contractspecv0/contractenvmetav0 + rsver/ +# rssdkver, but no cliver and no wasm-opt). +# +# SEP-0058 use: this image IS the `bldimg`; `bldopt` is the FULL argv appended to the +# entrypoint (so a verifier just runs `docker run -v src:/source `). +# The entrypoint is the bare tool `cargo`, so `bldopt` leads with the `build` +# subcommand — mirroring the stellar path, whose bldimg entrypoint is bare `stellar` +# and whose bldopt leads with `contract build`. Verifier flow: +# docker run -v :/source build --release --target= -p --manifest-path +FROM rust@${RUST_IMAGE_DIGEST} +SHELL ["/bin/bash", "-eo", "pipefail", "-c"] +ARG RUST_VERSION +ARG RUST_BASE_SUFFIX +ARG RUST_IMAGE_DIGEST +ARG BUILD_DATE +ARG SOURCE_REPO + +# RUSTUP_TOOLCHAIN is baked in so an in-source `rust-toolchain.toml` in a +# consumer's contract can't silently swap our pinned toolchain at build +# time. Required by SEP-58 "self-contained build environment". Consumers can +# still override with `-e RUSTUP_TOOLCHAIN=...` if they know what they're +# doing. +ENV DEBIAN_FRONTEND=noninteractive \ + RUSTUP_TOOLCHAIN=${RUST_VERSION} + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + libdbus-1-3 \ + libssl3 \ + libudev1 \ + && rm -rf /var/lib/apt/lists/* +RUN rustup target add wasm32-unknown-unknown \ + && (rustup target add wasm32v1-none || true) + +RUN useradd --create-home --home-dir /stellar --uid 1000 --shell /bin/bash stellar \ + && mkdir -p /source /config /data \ + && chown stellar:stellar /source /config /data + +ENV CARGO_HOME=/stellar/.cargo \ + HOME=/stellar +USER stellar +WORKDIR /source + +ENTRYPOINT ["cargo"] +CMD [] + +LABEL org.opencontainers.image.title="cargo" \ + org.opencontainers.image.description="Cargo build image (SEP-58-compatible image for Stellar smart contracts)." \ + org.opencontainers.image.source="https://github.com/${SOURCE_REPO}" \ + org.opencontainers.image.url="https://github.com/${SOURCE_REPO}" \ + org.opencontainers.image.documentation="https://github.com/${SOURCE_REPO}" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.created="${BUILD_DATE}" \ + org.opencontainers.image.base.name="docker.io/library/rust:${RUST_VERSION}-${RUST_BASE_SUFFIX}" \ + org.opencontainers.image.base.digest="${RUST_IMAGE_DIGEST}" diff --git a/cargo/builds_rust.json b/cargo/builds_rust.json new file mode 100644 index 0000000..058bdc0 --- /dev/null +++ b/cargo/builds_rust.json @@ -0,0 +1,20 @@ +{ + "$comment": "Source of truth for which rust versions we publish. Each entry is a fully-qualified rust base pin '@' (e.g. 1.94.0-slim-trixie@sha256:...)", + "$schema": "./builds_rust.schema.json", + "default_distro": "trixie", + "rust_versions": [ + "1.85.0-slim-bookworm@sha256:1829c432be4a592f3021501334d3fcca24f238432b13306a4e62669dec538e52", + "1.86.0-slim-bookworm@sha256:57d415bbd61ce11e2d5f73de068103c7bd9f3188dc132c97cef4a8f62989e944", + "1.87.0-slim-bookworm@sha256:437507c3e719e4f968033b88d851ffa9f5aceeb2dcc2482cc6cb7647811a55eb", + "1.88.0-slim-trixie@sha256:9a7159329166b45f453351a077367f501aa3e98378f7e327530e7966a139d05f", + "1.89.0-slim-trixie@sha256:8cffb8fe4e8a95cf0d6a2060375e5a28aff4c752155aa9f1f9193530769bdf66", + "1.90.0-slim-trixie@sha256:7fa728f3678acf5980d5db70960cf8491aff9411976789086676bdf0c19db39e", + "1.91.1-slim-trixie@sha256:f75071363e7f4771769d4cf81b1b7b290e607f4d4459e8731f6abdcee9982dc8", + "1.92.0-slim-trixie@sha256:bf3368a992915f128293ac76917ab6e561e4dda883273c8f5c9f6f8ea37a378e", + "1.93.0-slim-trixie@sha256:760ad1d638d70ebbd0c61e06210e1289cbe45ff6425e3ea6e01241de3e14d08e", + "1.93.1-slim-trixie@sha256:c0a38f5662afdb298898da1d70b909af4bda4e0acff2dc52aea6360a9b9c6956", + "1.94.0-slim-trixie@sha256:f7bf1c266d9e48c8d724733fd97ba60464c44b743eb4f46f935577d3242d81d0", + "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", + "1.96.0-slim-trixie@sha256:26abcef3d79b8d890c4ceb17093154573e1f6479cf6dd7c1450043b8458350f6" + ] +} diff --git a/cargo/builds_rust.schema.json b/cargo/builds_rust.schema.json new file mode 100644 index 0000000..4238f8e --- /dev/null +++ b/cargo/builds_rust.schema.json @@ -0,0 +1,42 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "definitions": { + "rust_pin": { + "description": "A fully-qualified rust base pin: the composite rust base key (rust toolchain version + upstream rust:- tail, e.g. 1.94.0-slim-trixie) joined to the pinned multi-arch index digest with '@'. Example: 1.94.0-slim-trixie@sha256:<64 hex>.", + "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+-[a-z][a-z0-9-]*@sha256:[0-9a-f]{64}$", + "type": "string" + }, + }, + "properties": { + "$comment": { + "type": "string" + }, + "$schema": { + "type": "string" + }, + "default_distro": { + "description": "Debian codename used to compose the upstream rust image suffix (slim-). Drives the picker in scripts/release-prepare.sh and the : / :latest alias derivation.", + "enum": [ + "bookworm", + "trixie" + ], + "type": "string" + }, + "rust_versions": { + "description": "Append-only list of fully-qualified rust base pins (@) this stellar-cli release was ever built against. Refreshes append the picker's freshly-resolved pins; previously-published pins are retained so the file stays consistent with the immutable tags in the registry. The same label may appear more than once with distinct digests (e.g. a rebuilt base) \u2014 each pin is its own immutable image.", + "items": { + "$ref": "#/definitions/rust_pin" + }, + "minItems": 1, + "type": "array", + "uniqueItems": true + } + }, + "required": [ + "rust_versions", + "default_distro" + ], + "title": "stellar-cli-docker builds_rust.json", + "type": "object" +} From 4b2948da5aff238c60b4d22db9296e7179021420 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 17 Jun 2026 10:31:00 +0200 Subject: [PATCH 2/3] Added cargo build_all publish script --- cargo/Dockerfile.cargo | 3 + cargo/build_all.py | 166 +++++++++++++++++++++++++++++++++++++++++ cargo/builds_rust.json | 2 + 3 files changed, 171 insertions(+) create mode 100755 cargo/build_all.py diff --git a/cargo/Dockerfile.cargo b/cargo/Dockerfile.cargo index 1c18f72..15d87c1 100644 --- a/cargo/Dockerfile.cargo +++ b/cargo/Dockerfile.cargo @@ -9,6 +9,9 @@ # subcommand — mirroring the stellar path, whose bldimg entrypoint is bare `stellar` # and whose bldopt leads with `contract build`. Verifier flow: # docker run -v :/source build --release --target= -p --manifest-path +# Declared before FROM so it is in scope for the pinned base reference; the +# build stage re-declares it below to use it again in the LABELs. +ARG RUST_IMAGE_DIGEST FROM rust@${RUST_IMAGE_DIGEST} SHELL ["/bin/bash", "-eo", "pipefail", "-c"] ARG RUST_VERSION diff --git a/cargo/build_all.py b/cargo/build_all.py new file mode 100755 index 0000000..597e4f7 --- /dev/null +++ b/cargo/build_all.py @@ -0,0 +1,166 @@ +#!/usr/bin/env -S uv run python +"""Build and publish the cargo build image for every rust version in builds_rust.json. + +This is the cargo analogue of scripts/build_all.py, but radically simpler: +there is no (cli x rust) matrix here, just a flat list of rust base pins. For +each pin we build cargo/Dockerfile.cargo on top of the pinned `rust: