diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ff1a1f..d54c2b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,14 +39,12 @@ jobs: ./scripts/build_image.py \ --stellar-cli-version "${{ steps.pair.outputs.cli }}" \ --rust-version "${{ steps.pair.outputs.rust }}" \ - --rust-image-digest "${{ steps.pair.outputs.digest }}" - name: smoke test run: | ./scripts/smoke_test_image.py \ --image "${{ steps.pair.outputs.image }}" \ --stellar-cli-version "${{ steps.pair.outputs.cli }}" \ --rust-version "${{ steps.pair.outputs.rust }}" \ - --rust-image-digest "${{ steps.pair.outputs.digest }}" - name: wasm reproducibility run: | ./scripts/repro_test.py \ diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5996a76..12618a7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -109,6 +109,7 @@ jobs: RUST_VERSION=${{ matrix.rust_version }} RUST_BASE_SUFFIX=${{ matrix.rust_base_suffix }} RUST_IMAGE_DIGEST=${{ matrix.rust_image_digest }} + CLI_RUST_IMAGE_DIGEST=${{ matrix.cli_rust_image_digest }} STELLAR_CLI_REV=${{ matrix.stellar_cli_ref }} STELLAR_CLI_VERSION=${{ matrix.stellar_cli_version }} BUILD_DATE=${{ steps.meta.outputs.build_date }} diff --git a/Dockerfile b/Dockerfile index 5aa1320..2b45554 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,12 +15,17 @@ ARG RUST_VERSION ARG RUST_BASE_SUFFIX ARG RUST_IMAGE_DIGEST +# Falls back to RUST_IMAGE_DIGEST so direct `docker build` usage keeps working +# without supplying CLI_RUST_IMAGE_DIGEST. The build scripts and CI always set +# it explicitly (from cli_rust_version) so the builder stage can diverge from +# the final stage's base image. +ARG CLI_RUST_IMAGE_DIGEST=${RUST_IMAGE_DIGEST} ARG STELLAR_CLI_REV ARG STELLAR_CLI_VERSION ARG BUILD_DATE ARG SOURCE_REPO -FROM rust@${RUST_IMAGE_DIGEST} AS builder +FROM rust@${CLI_RUST_IMAGE_DIGEST} AS builder ARG STELLAR_CLI_REV ARG STELLAR_CLI_VERSION SHELL ["/bin/bash", "-eo", "pipefail", "-c"] diff --git a/README.md b/README.md index b29c5b4..4dc20e6 100644 --- a/README.md +++ b/README.md @@ -102,10 +102,12 @@ compare the resulting WASM sha256. ./scripts/validate_json.py # Build a local image for a declared (cli, rust base) pair. The rust base is -# given as the label plus its pinned digest (copy the pin from builds.json). +# given as the label; the digest is resolved from builds.json automatically. ./scripts/build_image.py --stellar-cli-version 26.0.0 \ - --rust-version 1.94.0-slim-trixie \ - --rust-image-digest sha256:f7bf1c266d9e48c8d724733fd97ba60464c44b743eb4f46f935577d3242d81d0 + --rust-version 1.94.0-slim-trixie + +# Only when a label carries more than one digest in builds.json do you need +# --rust-image-digest to say which pin to build. # Smoke-test the built image. docker run --rm stellar-cli:26.0.0-rust1.94.0-slim-trixie --version diff --git a/RELEASE.md b/RELEASE.md index a3a5890..7764bc6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -102,11 +102,11 @@ The script prints the chosen release tag as its final stdout line. Commit and pu ```sh ./scripts/validate_json.py -# --rust-version is the label; --rust-image-digest is the pin's digest from -# builds.json (it pins the FROM and is cross-checked against the image's +# --rust-version is the label; build_image.py resolves its pinned digest from +# builds.json (the digest pins the FROM and is cross-checked against the image's # org.opencontainers.image.base.digest label). The built tag is label-only. -./scripts/build_image.py --stellar-cli-version 26.1.0 --rust-version 1.95.0-slim-trixie \ - --rust-image-digest sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0 +# Pass --rust-image-digest only when one label carries multiple digests. +./scripts/build_image.py --stellar-cli-version 26.1.0 --rust-version 1.95.0-slim-trixie ./scripts/smoke_test_image.py --image stellar-cli:26.1.0-rust1.95.0-slim-trixie \ --stellar-cli-version 26.1.0 --rust-version 1.95.0-slim-trixie \ --rust-image-digest sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0 diff --git a/builds.json b/builds.json index b3ff10e..38dd78f 100644 --- a/builds.json +++ b/builds.json @@ -4,24 +4,148 @@ "default_distro": "trixie", "stellar_cli_versions": [ { + "cli_rust_version": "1.90.0-slim-bookworm@sha256:64232e656c058f4468e8d024e990acff04f0fd5a5c0a88a574dc37773d7325c9", + "ref": "8c559e832fd969aa469784b66e70891fadf94f0a", + "rust_versions": [ + "1.88.0-slim-trixie@sha256:9a7159329166b45f453351a077367f501aa3e98378f7e327530e7966a139d05f", + "1.90.0-slim-trixie@sha256:7fa728f3678acf5980d5db70960cf8491aff9411976789086676bdf0c19db39e", + "1.91.1-slim-trixie@sha256:f75071363e7f4771769d4cf81b1b7b290e607f4d4459e8731f6abdcee9982dc8", + "1.92.0-slim-trixie@sha256:bf3368a992915f128293ac76917ab6e561e4dda883273c8f5c9f6f8ea37a378e", + "1.94.0-slim-trixie@sha256:f7bf1c266d9e48c8d724733fd97ba60464c44b743eb4f46f935577d3242d81d0" + ], + "version": "23.2.0" + }, + { + "cli_rust_version": "1.90.0-slim-bookworm@sha256:64232e656c058f4468e8d024e990acff04f0fd5a5c0a88a574dc37773d7325c9", + "ref": "496ac35be7a7d8d923fcde9bbbc650ee593d1f6f", + "rust_versions": [ + "1.85.0-slim-bookworm@sha256:1829c432be4a592f3021501334d3fcca24f238432b13306a4e62669dec538e52", + "1.86.0-slim-bookworm@sha256:57d415bbd61ce11e2d5f73de068103c7bd9f3188dc132c97cef4a8f62989e944", + "1.87.0-slim-bookworm@sha256:437507c3e719e4f968033b88d851ffa9f5aceeb2dcc2482cc6cb7647811a55eb", + "1.89.0-slim-trixie@sha256:8cffb8fe4e8a95cf0d6a2060375e5a28aff4c752155aa9f1f9193530769bdf66", + "1.90.0-slim-trixie@sha256:7fa728f3678acf5980d5db70960cf8491aff9411976789086676bdf0c19db39e", + "1.91.1-slim-trixie@sha256:f75071363e7f4771769d4cf81b1b7b290e607f4d4459e8731f6abdcee9982dc8", + "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0" + ], + "version": "23.2.1" + }, + { + "cli_rust_version": "1.90.0-slim-bookworm@sha256:64232e656c058f4468e8d024e990acff04f0fd5a5c0a88a574dc37773d7325c9", + "ref": "08473ac20016c369067ce0dbca91d9595e72d6d4", + "rust_versions": [ + "1.85.0-slim-bookworm@sha256:1829c432be4a592f3021501334d3fcca24f238432b13306a4e62669dec538e52", + "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.1-slim-trixie@sha256:c0a38f5662afdb298898da1d70b909af4bda4e0acff2dc52aea6360a9b9c6956" + ], + "version": "23.3.0" + }, + { + "cli_rust_version": "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", + "ref": "fc6745f3d4e90d1ef68d14d0ae947404768fa5c0", + "rust_versions": [ + "1.85.0-slim-bookworm@sha256:1829c432be4a592f3021501334d3fcca24f238432b13306a4e62669dec538e52", + "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.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0" + ], + "version": "23.4.0" + }, + { + "cli_rust_version": "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", + "ref": "a152ec2488c25136808ad28277c24b3a0765ffd4", + "rust_versions": [ + "1.85.0-slim-bookworm@sha256:1829c432be4a592f3021501334d3fcca24f238432b13306a4e62669dec538e52", + "1.86.0-slim-bookworm@sha256:57d415bbd61ce11e2d5f73de068103c7bd9f3188dc132c97cef4a8f62989e944", + "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" + ], + "version": "23.4.1" + }, + { + "cli_rust_version": "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", + "ref": "a64925e9391c3d3b3ef8e53dc60c23db9e6a82e4", + "rust_versions": [ + "1.87.0-slim-bookworm@sha256:437507c3e719e4f968033b88d851ffa9f5aceeb2dcc2482cc6cb7647811a55eb", + "1.90.0-slim-trixie@sha256:7fa728f3678acf5980d5db70960cf8491aff9411976789086676bdf0c19db39e", + "1.92.0-slim-trixie@sha256:bf3368a992915f128293ac76917ab6e561e4dda883273c8f5c9f6f8ea37a378e", + "1.93.0-slim-trixie@sha256:760ad1d638d70ebbd0c61e06210e1289cbe45ff6425e3ea6e01241de3e14d08e", + "1.93.1-slim-trixie@sha256:c0a38f5662afdb298898da1d70b909af4bda4e0acff2dc52aea6360a9b9c6956" + ], + "version": "25.0.0" + }, + { + "cli_rust_version": "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", "ref": "a048a57a75762458b487052e0021ea704a926bee", "rust_versions": [ - "1.90.0-slim-bookworm@sha256:64232e656c058f4468e8d024e990acff04f0fd5a5c0a88a574dc37773d7325c9" + "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.94.1-slim-trixie@sha256:cf09adf8c3ebaba10779e5c23ff7fe4df4cccdab8a91f199b0c142c53fef3e1a", + "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", + "1.96.0-slim-trixie@sha256:26abcef3d79b8d890c4ceb17093154573e1f6479cf6dd7c1450043b8458350f6" ], "version": "25.1.0" }, { + "cli_rust_version": "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", + "ref": "28484880988199233a7e8e87c97cb12dac323cb3", + "rust_versions": [ + "1.86.0-slim-bookworm@sha256:57d415bbd61ce11e2d5f73de068103c7bd9f3188dc132c97cef4a8f62989e944", + "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.94.1-slim-trixie@sha256:cf09adf8c3ebaba10779e5c23ff7fe4df4cccdab8a91f199b0c142c53fef3e1a", + "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0" + ], + "version": "25.2.0" + }, + { + "cli_rust_version": "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", "ref": "60f7458e7ecffddf2f2d91dc6d0d2db4fab03ecc", "rust_versions": [ + "1.85.0-slim-bookworm@sha256:1829c432be4a592f3021501334d3fcca24f238432b13306a4e62669dec538e52", + "1.88.0-slim-trixie@sha256:9a7159329166b45f453351a077367f501aa3e98378f7e327530e7966a139d05f", + "1.90.0-slim-trixie@sha256:7fa728f3678acf5980d5db70960cf8491aff9411976789086676bdf0c19db39e", + "1.92.0-slim-trixie@sha256:bf3368a992915f128293ac76917ab6e561e4dda883273c8f5c9f6f8ea37a378e", "1.93.0-slim-trixie@sha256:760ad1d638d70ebbd0c61e06210e1289cbe45ff6425e3ea6e01241de3e14d08e", - "1.94.0-slim-trixie@sha256:f7bf1c266d9e48c8d724733fd97ba60464c44b743eb4f46f935577d3242d81d0" + "1.93.1-slim-trixie@sha256:c0a38f5662afdb298898da1d70b909af4bda4e0acff2dc52aea6360a9b9c6956", + "1.94.0-slim-trixie@sha256:f7bf1c266d9e48c8d724733fd97ba60464c44b743eb4f46f935577d3242d81d0", + "1.94.1-slim-trixie@sha256:cf09adf8c3ebaba10779e5c23ff7fe4df4cccdab8a91f199b0c142c53fef3e1a", + "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0" ], "version": "26.0.0" }, { + "cli_rust_version": "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", "ref": "1228cff8022b804659750b94b315932b0e0f3f6a", "rust_versions": [ - "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0" + "1.89.0-slim-trixie@sha256:8cffb8fe4e8a95cf0d6a2060375e5a28aff4c752155aa9f1f9193530769bdf66", + "1.95.0-slim-trixie@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0", + "1.96.0-slim-trixie@sha256:26abcef3d79b8d890c4ceb17093154573e1f6479cf6dd7c1450043b8458350f6" ], "version": "26.1.0" } diff --git a/builds.schema.json b/builds.schema.json index 05b116c..2b7585d 100644 --- a/builds.schema.json +++ b/builds.schema.json @@ -40,12 +40,16 @@ "items": { "additionalProperties": false, "properties": { + "cli_rust_version": { + "$ref": "#/definitions/rust_pin", + "description": "Fully-qualified rust base pin (@) to build this stellar-cli release - not the same as the rustc used to compile contracts" + }, "ref": { "$ref": "#/definitions/git_sha", "description": "Upstream stellar/stellar-cli git commit SHA for this release. Source of truth; version is metadata." }, "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) — each pin is its own immutable image.", + "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" }, diff --git a/scripts/build_image.py b/scripts/build_image.py index 5057a46..74bebbe 100755 --- a/scripts/build_image.py +++ b/scripts/build_image.py @@ -17,7 +17,7 @@ def build_parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) parser.add_argument("--stellar-cli-version", required=True, metavar="V") parser.add_argument("--rust-version", required=True, metavar="KEY") - parser.add_argument("--rust-image-digest", required=True, metavar="DIGEST") + parser.add_argument("--rust-image-digest", default=None, metavar="DIGEST") parser.add_argument("--platform", default="", metavar="P") parser.add_argument("--tag", default="", metavar="REF") parser.add_argument("--source-repo", default="stellar/stellar-cli-docker", metavar="SLUG") @@ -29,13 +29,15 @@ def main(argv: list[str] | None = None) -> int: common.preflight_checks(["buildx"]) data = builds.load() - rust_digest = args.rust_image_digest try: - builds.assert_pair_declared( - data, args.stellar_cli_version, f"{args.rust_version}@{rust_digest}" + rust_digest = builds.resolve_rust_digest( + data, args.stellar_cli_version, args.rust_version, args.rust_image_digest ) stellar_ref = builds.stellar_cli_ref(data, args.stellar_cli_version) parsed = rust_keys.parse(args.rust_version) + entry = builds.find_cli(data, args.stellar_cli_version) + cli_rust_pin = entry.get("cli_rust_version") if entry else None + cli_rust_digest = builds.digest_of(cli_rust_pin) if cli_rust_pin else rust_digest except ValueError as exc: common.die(str(exc)) @@ -48,6 +50,7 @@ def main(argv: list[str] | None = None) -> int: common.log(f"building {tag}") common.log(f" stellar-cli {args.stellar_cli_version} ({stellar_ref})") common.log(f" rust {args.rust_version} ({rust_digest})") + common.log(f" cli-build rust ({cli_rust_digest})") common.log(f" base rust:{parsed.version}-{parsed.suffix}") common.log(f" platform {args.platform or ''}") @@ -63,6 +66,8 @@ def main(argv: list[str] | None = None) -> int: "--build-arg", f"RUST_IMAGE_DIGEST={rust_digest}", "--build-arg", + f"CLI_RUST_IMAGE_DIGEST={cli_rust_digest}", + "--build-arg", f"STELLAR_CLI_REV={stellar_ref}", "--build-arg", f"STELLAR_CLI_VERSION={args.stellar_cli_version}", diff --git a/scripts/lib/builds.py b/scripts/lib/builds.py index 3d169a6..4ff0d76 100644 --- a/scripts/lib/builds.py +++ b/scripts/lib/builds.py @@ -81,6 +81,35 @@ def assert_pair_declared(data: dict[str, Any], cli: str, rust_pin: str) -> None: ) +def resolve_rust_digest( + data: dict[str, Any], cli: str, label: str, digest: str | None = None +) -> str: + """Resolve the pinned base digest for a (cli, rust label) pair. + + When `digest` is given, assert the exact `