From faf32111a50d59fa46c254aaf6ec4447be7469fa Mon Sep 17 00:00:00 2001 From: "pithead-developer[bot]" <328836012+pithead-developer[bot]@users.noreply.github.com> Date: Fri, 4 Dec 2026 11:29:28 -0600 Subject: [PATCH 1/2] Build caddy and the Docker socket proxy as pithead images Caddy is rebuilt at its pinned version with golang.org/x/net v0.62.0, and both images raise busybox, busybox-binsh and ssl_client to 1.37.0-r32 or later on top of their pinned upstream bases. Compose, Quadlet, the appliance build, the release scripts, cosign verification, the CI build-and-scan matrix and Dependabot now carry both images. Part of #4676. Co-Authored-By: Claude Opus 5.5 --- .github/dependabot.yml | 8 +-- .github/workflows/ci.yml | 2 +- build/caddy/Dockerfile | 15 +++++ build/socket-proxy/Dockerfile | 4 ++ docker-compose.yml | 28 ++------ docs/dev/appliance-release.md | 4 +- docs/dev/file-budget.tsv | 8 +-- docs/dev/releasing.md | 10 +-- docs/operations.md | 2 +- docs/privacy.md | 3 +- lib/pithead/01-lifecycle.sh | 6 -- lib/pithead/03-release-verify.sh | 12 +--- lib/pithead/35-caddyfile-and-auth-helpers.sh | 17 ++--- lib/pithead/36-quadlet-units.sh | 9 +-- os/KNOWN-ISSUES.md | 2 +- os/build-image.sh | 19 +----- os/quadlet/caddy.container | 2 +- os/quadlet/docker-control.container | 2 +- os/quadlet/docker-proxy.container | 2 +- os/quadlet/local/caddy.container | 2 +- os/quadlet/local/docker-control.container | 2 +- os/quadlet/local/docker-proxy.container | 2 +- os/quadlet/payout/caddy.container | 2 +- os/quadlet/payout/docker-control.container | 2 +- os/quadlet/payout/docker-proxy.container | 2 +- scripts/lint/verify-healthcheck-scripts.sh | 12 +--- scripts/release/bundle.sh | 13 +--- scripts/release/release.sh | 21 +----- scripts/release/resolve-pins.sh | 26 -------- scripts/watch/trivyignore-watch.sh | 56 ++-------------- tests/integration/lib/run-lifecycle.sh | 3 +- .../mini-stack/test-boot-health-proxy.sh | 4 +- .../selftest-lifecycle-gate-wiring.sh | 2 +- .../selftest-lifecycle-restore-health.sh | 2 +- tests/os/image-upgrade-bundle.sh | 2 +- tests/os/selftest-image-upgrade-bundle.sh | 2 +- tests/os/selftest-marker-images.sh | 2 +- tests/os/verify-image-artifact-helpers.sh | 6 +- .../test-appliance-build-compose-source.sh | 5 +- .../stack/appliance/test-appliance-restore.sh | 2 +- tests/stack/dashboard/test-dashboard.sh | 14 +++- tests/stack/lib/verdict-label-determinism.sh | 3 + tests/stack/release/test-release-verify.sh | 50 +++++--------- tests/stack/release/test-release.sh | 8 +-- tests/stack/standalone/test_caddyfile.sh | 12 +--- tests/stack/standalone/test_compose.sh | 23 +------ .../standalone/test_image_permissions.sh | 9 ++- tests/stack/test-render-quadlet.sh | 65 ++++++++++++------- 48 files changed, 178 insertions(+), 331 deletions(-) create mode 100644 build/caddy/Dockerfile create mode 100644 build/socket-proxy/Dockerfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e8b0c8ad7f..a3f6ae61e6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -38,9 +38,11 @@ updates: - package-ecosystem: "docker" directories: - "/dashboard" + - "/build/caddy" - "/build/cosign" - "/build/monero" - "/build/p2pool" + - "/build/socket-proxy" - "/build/tor" - "/build/xmrig-proxy" schedule: @@ -85,10 +87,6 @@ updates: rootfs-tools: patterns: ["*"] - # Third-party image digests pinned directly in docker-compose.yml (Tari node + wallet, - # docker-socket-proxy, caddy) — outside build/*, so the `docker` entry above never sees them, - # and they feed both channels: pulled on the DIY stack, baked into the appliance image (#833). - # The pithead-* image lines interpolate env vars and carry no digest; Dependabot skips them. - package-ecosystem: "docker-compose" directory: "/" schedule: @@ -97,8 +95,6 @@ updates: compose: patterns: ["*"] ignore: - # Same policy as the docker entry: digest + patch within the pinned tag. A Tari or Caddy - # major/minor is a deliberate migration (compose flags, config compatibility), not a CVE fix. - dependency-name: "*" update-types: ["version-update:semver-major", "version-update:semver-minor"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef2643b5a7..16e0705440 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,7 +101,7 @@ jobs: strategy: fail-fast: false matrix: - service: [monero, p2pool, tor, xmrig-proxy, dashboard] + service: [monero, p2pool, tor, xmrig-proxy, caddy, socket-proxy, dashboard] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/build/caddy/Dockerfile b/build/caddy/Dockerfile new file mode 100644 index 0000000000..20b518faed --- /dev/null +++ b/build/caddy/Dockerfile @@ -0,0 +1,15 @@ +FROM caddy:2.11.9-builder-alpine@sha256:86e132d1d6db8850352b2dbc15f82a4cb25363ac305ee41e11405873e5931f37 AS build + +ARG X_NET_VERSION=v0.62.0 +ENV GOPROXY=https://proxy.golang.org GOSUMDB=sum.golang.org +RUN xcaddy build "${CADDY_VERSION}" --replace "golang.org/x/net=golang.org/x/net@${X_NET_VERSION}" --output /usr/bin/caddy \ + && go version -m /usr/bin/caddy > /tmp/modules \ + && grep -Eq "^[[:space:]]+dep[[:space:]]+github.com/caddyserver/caddy/v2[[:space:]]+${CADDY_VERSION}[[:space:]]+h1:" /tmp/modules \ + && grep -Eq "^[[:space:]]+=>[[:space:]]+golang.org/x/net[[:space:]]+${X_NET_VERSION}[[:space:]]+h1:" /tmp/modules + +FROM caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b + +COPY --from=build /usr/bin/caddy /usr/bin/caddy +RUN apk add --no-cache --upgrade "busybox>=1.37.0-r32" "busybox-binsh>=1.37.0-r32" "ssl_client>=1.37.0-r32" libcrypto3 libssl3 \ + && setcap cap_net_bind_service=+ep /usr/bin/caddy \ + && caddy version | grep -q "^${CADDY_VERSION} " diff --git a/build/socket-proxy/Dockerfile b/build/socket-proxy/Dockerfile new file mode 100644 index 0000000000..fc4c169fc4 --- /dev/null +++ b/build/socket-proxy/Dockerfile @@ -0,0 +1,4 @@ +FROM tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 + +RUN apk add --no-cache --upgrade "busybox>=1.37.0-r32" "busybox-binsh>=1.37.0-r32" "ssl_client>=1.37.0-r32" libcrypto3 libssl3 musl musl-utils pcre2 zlib \ + && haproxy -v >/dev/null diff --git a/docker-compose.yml b/docker-compose.yml index 441b81b052..54d35a9dc4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -897,14 +897,10 @@ services: retries: 3 start_period: 60s - # --- Docker Socket Proxy (read-only) --- - # Read-only window onto the Docker API for the dashboard's container stats/logs. - # POST stays off, so this proxy can never write — container control goes through the - # separate, tightly-scoped docker-control proxy below. docker-proxy: - image: tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 + image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-socket-proxy:${STACK_VERSION:-dev} + build: ./build/socket-proxy container_name: docker-proxy - # Memory ceiling (#132 — see monerod). A tiny socket proxy (~13 MiB observed). mem_limit: 128m memswap_limit: 128m restart: unless-stopped @@ -945,19 +941,10 @@ services: retries: 3 start_period: 30s - # --- Docker Control Proxy (start/stop only) --- - # A second, minimal proxy used ONLY to stop/start p2pool + xmrig-proxy — node-down worker - # failover (Issue #31), holding the miner until the nodes finish syncing (Issue #35) — plus - # tor (#424) and monerod after a tor heal (#972). - # With POST=1 but every section (CONTAINERS, EXEC, IMAGES, …) left off, the v0.5.0 ruleset - # allows exactly `POST /containers//{start,stop}` and denies everything else - # (create/kill/exec/reads — and the pause/unpause routes v0.5.0 added, which sit behind their - # own ALLOW_PAUSE/ALLOW_UNPAUSE opt-ins, left off here). Kept separate from the read-only - # proxy above so opening POST here can't widen that proxy's container access. docker-control: - image: tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 + image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-socket-proxy:${STACK_VERSION:-dev} + build: ./build/socket-proxy container_name: docker-control - # Memory ceiling (#132 — see monerod). A tiny socket proxy (~13 MiB observed). mem_limit: 128m memswap_limit: 128m restart: unless-stopped @@ -997,13 +984,10 @@ services: retries: 3 start_period: 30s - # --- Caddy Reverse Proxy --- - # Bridges the local 127.0.0.1 application binding to the LAN - # Serves HTTPS or HTTP depending on configuration caddy: - image: caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b + image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-caddy:${STACK_VERSION:-dev} + build: ./build/caddy container_name: caddy - # Memory ceiling (#132 — see monerod). Reverse proxy + local TLS only (~13 MiB observed). mem_limit: 128m memswap_limit: 128m restart: unless-stopped diff --git a/docs/dev/appliance-release.md b/docs/dev/appliance-release.md index 97c8fb9582..805555dd4e 100644 --- a/docs/dev/appliance-release.md +++ b/docs/dev/appliance-release.md @@ -258,11 +258,11 @@ PITHEAD_REGISTRY= PITHEAD_REGISTRY_CA= PITHEAD_REGISTRY_COSIG ``` **A dev image pulls its services; only the wizard image is baked.** At first boot the appliance -pulls `pithead-:v$(cat VERSION)` for all five first-party services, and while VERSION +pulls `pithead-:v$(cat VERSION)` for all seven first-party services, and while VERSION leads the last release those tags exist nowhere public. Build without `PITHEAD_REGISTRY` and the appliance provisions, publishes dashboard credentials, and then runs ZERO containers — five battery legs report it and each waits up to 25 minutes (#2043). `build-image.sh` refuses such a -build; publish the five images to a registry the builder and the guest can both reach first. +build; publish the seven images to a registry the builder and the guest can both reach first. **A dev image ships the last release's compose file, not the tree's.** Every `image:` in `docker-compose.yml` is pinned by `STACK_VERSION`, and the appliance derives that from its baked diff --git a/docs/dev/file-budget.tsv b/docs/dev/file-budget.tsv index acecffcf31..0732467b20 100644 --- a/docs/dev/file-budget.tsv +++ b/docs/dev/file-budget.tsv @@ -51,16 +51,16 @@ lib/pithead/14-local-miner.sh 414 lib/pithead/21-doctor-stack-checks.sh 413 lib/pithead/28-parse-and-validate-config.sh 464 lib/pithead/33-render-env.sh 481 -lib/pithead/36-quadlet-units.sh 418 +lib/pithead/36-quadlet-units.sh 415 lib/pithead/48-os-update-verbs.sh 404 scripts/build-pithead-selftest.sh 416 scripts/watch/scheduled-run-watch.sh 416 -scripts/watch/trivyignore-watch.sh 599 +scripts/watch/trivyignore-watch.sh 551 tests/integration/e2e.sh 684 tests/integration/fakes/test_contract.py 437 tests/integration/lib.sh 686 tests/integration/lib/live-upgrade-support.sh 413 -tests/integration/lib/run-lifecycle.sh 418 +tests/integration/lib/run-lifecycle.sh 417 tests/integration/lib/wallet-fixture.py 442 tests/integration/selftest/selftest-abort-traps.sh 408 tests/integration/selftest/selftest-e2e-phases.sh 501 @@ -95,7 +95,7 @@ tests/stack/dashboard/test-dashboard.sh 591 tests/stack/doctor/test-doctor.sh 470 tests/stack/firewall/tor-egress-enforcement.sh 444 tests/stack/run.sh 402 -tests/stack/standalone/test_compose.sh 462 +tests/stack/standalone/test_compose.sh 445 tests/stack/test-backup.sh 476 tests/stack/test-cli.sh 410 tests/stack/test-config.sh 705 diff --git a/docs/dev/releasing.md b/docs/dev/releasing.md index 4744e54d5d..a98aa54f9f 100644 --- a/docs/dev/releasing.md +++ b/docs/dev/releasing.md @@ -163,9 +163,9 @@ Images are published to GitHub Container Registry (`ghcr.io/p2pool-starter-stack images pull without a Docker Hub-style rate limit. The stack is multi-container. Every stack image (`pithead-dashboard`, `pithead-p2pool`, -`pithead-xmrig-proxy`, `pithead-monero`, `pithead-tor`) and the appliance rootfs +`pithead-xmrig-proxy`, `pithead-monero`, `pithead-tor`, `pithead-caddy`, `pithead-socket-proxy`) and the appliance rootfs (`pithead-os-rootfs`) is published, all tagged with the single product version. Compose references -one `${STACK_VERSION}` for the five images it runs. `docker compose pull` fetches that set with one +one `${STACK_VERSION}` for the seven images it runs. `docker compose pull` fetches that set with one knob, replacing the "git pull + rebuild" upgrade path. The version is the bundle, not the layers. ## Release process @@ -318,14 +318,14 @@ verdict is printed as a warning and the rehearsal continues, so a preview still the `pithead` shell suite + compose validation) and the [#54](https://github.com/p2pool-starter-stack/pithead/issues/54) integration matrix against the real nodes. Abort the release on any failure. See [Pre-release gate](#pre-release-gate-54). -3. Build: build the five stack images with the pinned upstream versions baked in and OCI labels +3. Build: build the seven stack images with the pinned upstream versions baked in and OCI labels stamped (`org.opencontainers.image.version` = the `VERSION` value, source revision, etc.). The dashboard already reads `PITHEAD_VERSION` / git build-args for its header badge ([#58](https://github.com/p2pool-starter-stack/pithead/issues/58)); a release build must pass `PITHEAD_RELEASE=1` (and `PITHEAD_VERSION` from `VERSION`) so the badge shows the clean `vX.Y.Z` rather than the `dev · branch @ hash` it shows for working-tree builds. Then build the appliance rootfs with that staged dashboard digest baked in. The rootfs builder receives - `PITHEAD_PIN_TAG=$STAGING_TAG` and resolves all five first-party index digests from that tag, + `PITHEAD_PIN_TAG=$STAGING_TAG` and resolves all seven first-party index digests from that tag, while the baked Compose references retain their version tags. Without an override, the builder resolves the version tag; an empty override uses that same default. Its push guard reads the exported rootfs and refuses any artifact carrying the debug SSH key. It records that tar's SHA-256; the @@ -731,7 +731,7 @@ round trip above must pass on it. `pithead` verifies before it changes anything: -- `pithead upgrade` on a release install with `cosign.pub` present verifies all five first-party +- `pithead upgrade` on a release install with `cosign.pub` present verifies all seven first-party images (`cosign verify --key cosign.pub --private-infrastructure`) and aborts on the first failure. Nothing is pulled or restarted. - The dashboard upgrade ([#59](https://github.com/p2pool-starter-stack/pithead/issues/59)) diff --git a/docs/operations.md b/docs/operations.md index c9dfe81fd6..7939c922fe 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -516,7 +516,7 @@ curl -fsSL https://github.com/p2pool-starter-stack/pithead/releases/latest/downl ``` **Source checkout:** pull the latest code, then upgrade. `upgrade` **rebuilds** the first-party -images locally and pulls only the pinned third-party images (Tari, Caddy, the socket proxies) that +images locally and pulls only the pinned third-party images (Tari) that are not on the host. After the build, it recreates any container whose image ID differs from its Compose declaration and fails if the IDs still differ. `setup` and `up` fetch missing third-party images the same way: diff --git a/docs/privacy.md b/docs/privacy.md index d6b0d18e77..29c0242032 100644 --- a/docs/privacy.md +++ b/docs/privacy.md @@ -274,7 +274,8 @@ attacker can't substitute what you receive. |---|---|---| | Source clone / release bundle | `github.com` | install / update (`git checkout vX.Y.Z` or downloading the release bundle) | | Component binaries (monerod / p2pool / xmrig-proxy) | `downloads.getmonero.org`, `github.com` | **image build only** — verified against a published **SHA256** / checksum. A release install *pulls* prebuilt images instead, so it never runs these. | -| Container images | **`ghcr.io`** (the `pithead-*` images, #44), `quay.io` (Tari), Docker Hub (caddy, socket-proxy) | image **pull** on a release install / `pithead upgrade`, or build from source. All pinned by **`@sha256:` digest** (#135). | +| Go modules for the caddy image | `proxy.golang.org`, `sum.golang.org` | **image build only** (`build/caddy`). A release install pulls the prebuilt image. | +| Container images | **`ghcr.io`** (the `pithead-*` images, including `pithead-caddy` and `pithead-socket-proxy`, #44), `quay.io` (Tari), Docker Hub (the base images of a source build) | image **pull** on a release install / `pithead upgrade`, or build from source. All pinned by **`@sha256:` digest** (#135). | Mitigation: run the install/build behind a VPN or with `torsocks`, or pre-pull the images and clone on another machine and copy them over. The downloads are pinned (SHA256 + image digests), so the diff --git a/lib/pithead/01-lifecycle.sh b/lib/pithead/01-lifecycle.sh index 1dead75704..863263beb1 100644 --- a/lib/pithead/01-lifecycle.sh +++ b/lib/pithead/01-lifecycle.sh @@ -194,13 +194,7 @@ compose_up_checked() { [ "${#KEEP_SCOPED_ARGS[@]}" -gt 0 ] || return 0 set -- "${KEEP_SCOPED_ARGS[@]}" fi - # Deactivated-profile containers go BEFORE the up (#795): the old local node must stop before - # p2pool (re)starts against the remote one, not linger beside it. remove_deactivated_profile_containers - # #2654: a source checkout's `never` policy builds the first-party `:dev` images, but the - # digest-pinned third-party ones (tari, caddy, the socket-proxies) have no build context, so - # after `uninstall` or on a fresh host `up` fails on them. Fetch only those that are missing; - # a pinned digest bump is a new ref, so this also covers `upgrade`. An explicit PITHEAD_PULL wins. if [ -z "${PITHEAD_PULL:-}" ] && is_source_checkout; then docker compose pull --policy missing --ignore-buildable || warn "Could not pull the missing third-party images — 'compose up' reports which ones below." diff --git a/lib/pithead/03-release-verify.sh b/lib/pithead/03-release-verify.sh index 51e71c14e7..179af4c671 100644 --- a/lib/pithead/03-release-verify.sh +++ b/lib/pithead/03-release-verify.sh @@ -1,6 +1,3 @@ -# The @sha256 digest the bundled compose pins pithead- to (#461 writes these into the -# released compose). Empty if the image line carries no digest (an un-pinned/dev compose). Mirrors -# the caddy-digest read at bcrypt-hash time (grep straight from docker-compose.yml at cwd). compose_pinned_digest() { grep -oE "pithead-$1:[^[:space:]]*@sha256:[0-9a-f]+" docker-compose.yml | grep -oE 'sha256:[0-9a-f]+' | head -1 @@ -79,20 +76,15 @@ verify_release_images() { fi cosign_available || error "cosign.pub is present but docker is not available to run the verifier — refusing an unverified pull. Install Docker ($DOCS_URL/docs/getting-started.md#1-prerequisites) and re-run '$0'." - # The 5 first-party images, verified by the exact digest compose pins them to (#451/#461). local suffix repo sha image out said cosign_registry_args=() - # A debug build's private-registry CA is program material beside cosign.pub, so the install-dir - # mount already carries it into the container — a relative name, like --key on the same command. if [ -f cosign.registry-ca.crt ]; then cosign_registry_args=(--registry-cacert cosign.registry-ca.crt) elif [ -n "${PITHEAD_REGISTRY:-}" ] && [ "$PITHEAD_REGISTRY" != "ghcr.io/p2pool-starter-stack" ] && [ "$(tr -d ' \t\r\n' <"${PITHEAD_VARIANT_FILE:-/etc/pithead-variant}" 2>/dev/null || true)" = debug ]; then cosign_registry_args=(--allow-http-registry) fi - for suffix in tor monero p2pool xmrig-proxy dashboard; do + for suffix in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do repo="${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-${suffix}" - # #557: plain `sha="$(...)"` aborts under errexit on a no-match grep BEFORE this error() - # fires — `if !` suspends errexit for the assignment so the crafted diagnostic is reachable. if ! sha="$(compose_pinned_digest "$suffix")" || [ -z "$sha" ]; then error "cosign.pub is present but pithead-${suffix} is not digest-pinned in docker-compose.yml — cannot bind verification to the bytes compose pulls; refusing. A signed release bundle pins every first-party image by @sha256." fi @@ -110,7 +102,7 @@ verify_release_images() { error "Signature verification FAILED for $image — the published image does not match the release key; refusing to pull or restart, nothing was changed. cosign said: $said" fi done - log "All 5 release images verify against their pinned digest (cosign.pub)." + log "All release images verify against their pinned digest (cosign.pub)." } reconcile_compose_images() { diff --git a/lib/pithead/35-caddyfile-and-auth-helpers.sh b/lib/pithead/35-caddyfile-and-auth-helpers.sh index e6060403d0..b2cb619b65 100644 --- a/lib/pithead/35-caddyfile-and-auth-helpers.sh +++ b/lib/pithead/35-caddyfile-and-auth-helpers.sh @@ -32,18 +32,13 @@ hmac_sha256_hex() { # } | openssl dgst -sha256 | sed 's/^.*= //' } -# bcrypt-hash a dashboard password with the PINNED Caddy image (read straight from docker-compose.yml -# so it tracks the digest), returned base64-encoded so the raw bcrypt '$' never lands in .env (#8). -# Returns non-zero if Docker / the image isn't available. caddy_hash_password_b64() { - local pw="$1" img hash - img=$(grep -oE 'caddy:[0-9.]+@sha256:[a-f0-9]+' docker-compose.yml | head -1) - [ -n "$img" ] || return 1 - # Fully qualified, because `docker run` here may be podman's shim: docker IMPLIES docker.io - # for a short name, podman's native path refuses one outright — the compose pull worked (the - # compat API keeps docker semantics) while this exact line killed appliance provisioning. - img="docker.io/library/$img" - # Keep the credential hash out of the runtime journal while capturing stdout here. + local pw="$1" img hash digest + digest=$(compose_pinned_digest caddy) || digest="" + img="${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-caddy:${STACK_VERSION:-dev}${digest:+@$digest}" + if is_source_checkout; then + docker image inspect "$img" >/dev/null 2>&1 || docker compose build caddy >/dev/null 2>&1 || return 1 + fi hash=$(printf '%s\n' "$pw" | docker run --rm -i --log-driver none "$img" caddy hash-password 2>/dev/null) || return 1 [ -n "$hash" ] || return 1 printf '%s' "$hash" | openssl base64 -A diff --git a/lib/pithead/36-quadlet-units.sh b/lib/pithead/36-quadlet-units.sh index de32c4868a..d864c3f8b1 100644 --- a/lib/pithead/36-quadlet-units.sh +++ b/lib/pithead/36-quadlet-units.sh @@ -41,9 +41,6 @@ render_quadlet_units() { _qcompose_require() { _qcompose_image "$1" >/dev/null || error "render-quadlet: $composef has no image for service $1. Refusing to render; no output was created." } - _qcompose_require caddy - _qcompose_require docker-proxy - _qcompose_require docker-control case ",$profiles," in *,local_tari,*) _qcompose_require tari ;; esac case ",$profiles," in *,tari_payout_confirm,*) _qcompose_require tari-wallet ;; esac mkdir -p "$outdir" @@ -310,7 +307,7 @@ EOF Description=pithead caddy [Container] ContainerName=caddy -Image=$(_qcompose_image caddy) +Image=$reg/pithead-caddy:$ver Network=host Volume=$(_qenv QUADLET_CADDYFILE):/etc/caddy/Caddyfile:ro Volume=pithead-caddy-data:/data @@ -335,7 +332,7 @@ EOF Description=pithead read socket proxy [Container] ContainerName=docker-proxy -Image=$(_qcompose_image docker-proxy) +Image=$reg/pithead-socket-proxy:$ver Network=proxy.network Environment=CONTAINERS=1 LOGS=1 Volume=$proxy_sock:/var/run/docker.sock:ro @@ -356,7 +353,7 @@ EOF Description=pithead control socket proxy [Container] ContainerName=docker-control -Image=$(_qcompose_image docker-control) +Image=$reg/pithead-socket-proxy:$ver Network=proxy.network Environment=CONTAINERS=1 POST=1 ALLOW_START=1 ALLOW_STOP=1 Volume=$proxy_sock:/var/run/docker.sock:ro diff --git a/os/KNOWN-ISSUES.md b/os/KNOWN-ISSUES.md index 4706199314..837285d808 100644 --- a/os/KNOWN-ISSUES.md +++ b/os/KNOWN-ISSUES.md @@ -428,7 +428,7 @@ not proven. provision phase armed a "post-validation" fault by moving `docker-compose.yml` aside; the guest then emitted nothing further and `faulted setup never reached its credentials handoff` failed. The machine was not hung. All three of the wizard's validations reach - `caddy_hash_password_b64`, which greps the pinned caddy ref straight out of + `caddy_hash_password_b64`, which reads the pinned caddy digest from `docker-compose.yml`, so removing that file faults `parse_and_validate_config` — which has its own recovery, publishes the error and the answers to the page, and never calls `setup`. That path correctly publishes no credentials handoff, and the harness polled 24x5s for one. The diff --git a/os/build-image.sh b/os/build-image.sh index 2c97728a83..67bdfd077e 100755 --- a/os/build-image.sh +++ b/os/build-image.sh @@ -79,7 +79,7 @@ is_immutable_image_ref() { [[ "$1" =~ ^[^[:space:]@]+@sha256:[0-9a-f]{64}$ ]]; } pin_first_party_images() { local compose="$1" registry="$2" version="$3" dashboard="${4:-}" svc digest - for svc in tor monero p2pool xmrig-proxy dashboard; do + for svc in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do if [ "$svc" = dashboard ] && [ -n "$dashboard" ]; then digest="${dashboard##*@}" else @@ -174,22 +174,9 @@ stage_compose() { # -> prints the COMPOSE_SOURCE line cat "$dir/COMPOSE_SOURCE" || return 1 } -# A bench build that leaves the DEFAULT registry in place will ask it for -# pithead-:$STACK_VERSION at first boot. Only the wizard's image is baked (below), so -# every other service is a pull — and an UNRELEASED version has no such tags anywhere public. -# The appliance then provisions, publishes its dashboard credentials, and comes up with ZERO -# containers; five battery legs report that and take up to 25 minutes each to do it (#2043). -# -# The refs are the same ones verify_release_images checks, and the same five the bench publishes -# to a local registry before a battery. Refuse here, in seconds, naming the remedy — the failure -# is in the BUILD's configuration, not in the appliance, and the battery cannot tell the -# difference from the inside. -# -# An unreachable registry refuses too, and correctly: an appliance built against a registry this -# host cannot read is an appliance that cannot pull either. -require_pullable_services() { # +require_pullable_services() { local registry="$1" version="$2" svc missing="" - for svc in tor monero p2pool xmrig-proxy dashboard; do + for svc in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do docker manifest inspect "${registry}/pithead-${svc}:${version}" >/dev/null 2>&1 || missing="${missing} pithead-${svc}:${version}" done diff --git a/os/quadlet/caddy.container b/os/quadlet/caddy.container index 7d43d6a420..fdcc9c9b6f 100644 --- a/os/quadlet/caddy.container +++ b/os/quadlet/caddy.container @@ -2,7 +2,7 @@ Description=pithead caddy [Container] ContainerName=caddy -Image=docker.io/library/caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b +Image=ghcr.io/p2pool-starter-stack/pithead-caddy:v1.14.0 Network=host Volume=/opt/pithead/Caddyfile:/etc/caddy/Caddyfile:ro Volume=pithead-caddy-data:/data diff --git a/os/quadlet/docker-control.container b/os/quadlet/docker-control.container index ac925b1365..2f429aa85a 100644 --- a/os/quadlet/docker-control.container +++ b/os/quadlet/docker-control.container @@ -2,7 +2,7 @@ Description=pithead control socket proxy [Container] ContainerName=docker-control -Image=docker.io/tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 +Image=ghcr.io/p2pool-starter-stack/pithead-socket-proxy:v1.14.0 Network=proxy.network Environment=CONTAINERS=1 POST=1 ALLOW_START=1 ALLOW_STOP=1 Volume=/run/podman/podman.sock:/var/run/docker.sock:ro diff --git a/os/quadlet/docker-proxy.container b/os/quadlet/docker-proxy.container index 91fea229bc..acc8a02171 100644 --- a/os/quadlet/docker-proxy.container +++ b/os/quadlet/docker-proxy.container @@ -2,7 +2,7 @@ Description=pithead read socket proxy [Container] ContainerName=docker-proxy -Image=docker.io/tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 +Image=ghcr.io/p2pool-starter-stack/pithead-socket-proxy:v1.14.0 Network=proxy.network Environment=CONTAINERS=1 LOGS=1 Volume=/run/podman/podman.sock:/var/run/docker.sock:ro diff --git a/os/quadlet/local/caddy.container b/os/quadlet/local/caddy.container index 7d43d6a420..fdcc9c9b6f 100644 --- a/os/quadlet/local/caddy.container +++ b/os/quadlet/local/caddy.container @@ -2,7 +2,7 @@ Description=pithead caddy [Container] ContainerName=caddy -Image=docker.io/library/caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b +Image=ghcr.io/p2pool-starter-stack/pithead-caddy:v1.14.0 Network=host Volume=/opt/pithead/Caddyfile:/etc/caddy/Caddyfile:ro Volume=pithead-caddy-data:/data diff --git a/os/quadlet/local/docker-control.container b/os/quadlet/local/docker-control.container index ac925b1365..2f429aa85a 100644 --- a/os/quadlet/local/docker-control.container +++ b/os/quadlet/local/docker-control.container @@ -2,7 +2,7 @@ Description=pithead control socket proxy [Container] ContainerName=docker-control -Image=docker.io/tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 +Image=ghcr.io/p2pool-starter-stack/pithead-socket-proxy:v1.14.0 Network=proxy.network Environment=CONTAINERS=1 POST=1 ALLOW_START=1 ALLOW_STOP=1 Volume=/run/podman/podman.sock:/var/run/docker.sock:ro diff --git a/os/quadlet/local/docker-proxy.container b/os/quadlet/local/docker-proxy.container index 91fea229bc..acc8a02171 100644 --- a/os/quadlet/local/docker-proxy.container +++ b/os/quadlet/local/docker-proxy.container @@ -2,7 +2,7 @@ Description=pithead read socket proxy [Container] ContainerName=docker-proxy -Image=docker.io/tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 +Image=ghcr.io/p2pool-starter-stack/pithead-socket-proxy:v1.14.0 Network=proxy.network Environment=CONTAINERS=1 LOGS=1 Volume=/run/podman/podman.sock:/var/run/docker.sock:ro diff --git a/os/quadlet/payout/caddy.container b/os/quadlet/payout/caddy.container index 7d43d6a420..fdcc9c9b6f 100644 --- a/os/quadlet/payout/caddy.container +++ b/os/quadlet/payout/caddy.container @@ -2,7 +2,7 @@ Description=pithead caddy [Container] ContainerName=caddy -Image=docker.io/library/caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b +Image=ghcr.io/p2pool-starter-stack/pithead-caddy:v1.14.0 Network=host Volume=/opt/pithead/Caddyfile:/etc/caddy/Caddyfile:ro Volume=pithead-caddy-data:/data diff --git a/os/quadlet/payout/docker-control.container b/os/quadlet/payout/docker-control.container index ac925b1365..2f429aa85a 100644 --- a/os/quadlet/payout/docker-control.container +++ b/os/quadlet/payout/docker-control.container @@ -2,7 +2,7 @@ Description=pithead control socket proxy [Container] ContainerName=docker-control -Image=docker.io/tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 +Image=ghcr.io/p2pool-starter-stack/pithead-socket-proxy:v1.14.0 Network=proxy.network Environment=CONTAINERS=1 POST=1 ALLOW_START=1 ALLOW_STOP=1 Volume=/run/podman/podman.sock:/var/run/docker.sock:ro diff --git a/os/quadlet/payout/docker-proxy.container b/os/quadlet/payout/docker-proxy.container index 91fea229bc..acc8a02171 100644 --- a/os/quadlet/payout/docker-proxy.container +++ b/os/quadlet/payout/docker-proxy.container @@ -2,7 +2,7 @@ Description=pithead read socket proxy [Container] ContainerName=docker-proxy -Image=docker.io/tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459 +Image=ghcr.io/p2pool-starter-stack/pithead-socket-proxy:v1.14.0 Network=proxy.network Environment=CONTAINERS=1 LOGS=1 Volume=/run/podman/podman.sock:/var/run/docker.sock:ro diff --git a/scripts/lint/verify-healthcheck-scripts.sh b/scripts/lint/verify-healthcheck-scripts.sh index 7066202657..43d44a0671 100755 --- a/scripts/lint/verify-healthcheck-scripts.sh +++ b/scripts/lint/verify-healthcheck-scripts.sh @@ -109,8 +109,6 @@ extract_healthcheck_targets() { # in_build_block=0 fi fi - # Only services this tree actually builds carry a Dockerfile to check against — a pulled - # third-party image (tari, caddy, the socket proxies) has none in this repo. [ -n "$build" ] || continue if [[ "$line" =~ ^[[:space:]]+test:\ \[(.*)\][[:space:]]*$ ]]; then emit_healthcheck_targets "$svc" "$build" "${BASH_REMATCH[1]}" @@ -289,7 +287,7 @@ services: test: ["CMD", "/app/healthcheck.sh"] caddy: - image: caddy:2.11.4 + build: ./build/caddy healthcheck: test: ["CMD", "wget", "-q", "--spider", "-T", "5", "http://127.0.0.1:2019/config/"] @@ -302,17 +300,11 @@ services: EOF targets="$(extract_healthcheck_targets "$WORK/compose.yml" | sort)" st "tari (no build:, no .sh) contributes nothing" "$(grep -c '^tari|' <<<"$targets" || true)" "0" - st "caddy's wget probe (no .sh path, no build:) contributes nothing" "$(grep -c '^caddy|' <<<"$targets" || true)" "0" + st "caddy's wget probe (a build: but no .sh path) contributes nothing" "$(grep -c '^caddy|' <<<"$targets" || true)" "0" st "xmrig-proxy's inline build: form is read" "$(grep -c '^xmrig-proxy|\./build/xmrig-proxy|/usr/local/bin/xmrig-proxy-healthcheck\.sh$' <<<"$targets" || true)" "1" st "dashboard's block build:/context: form is read" "$(grep -c '^dashboard|\./dashboard|/app/healthcheck\.sh$' <<<"$targets" || true)" "1" - # THE PARSER-GAP mutation: a block-list `test:` (quoted item, on its own lines rather than a - # flow sequence) is equally valid compose YAML. A parser that only recognises `test: [...]` - # makes this service invisible to the whole check — not a red, just silently unchecked. st "block-list test: form (positive) is read" "$(grep -c '^foo-blocklist|\./build/foo-blocklist|/usr/local/bin/foo-healthcheck\.sh$' <<<"$targets" || true)" "1" - # A second compose file, block-list form, whose script the Dockerfile does NOT provide — the - # missing-script half of the same gap. Kept separate from $WORK/compose.yml above so the - # "fully consistent tree passes" assertion below stays about a tree that really is consistent. cat >"$WORK/compose-blocklist-missing.yml" <<'EOF' services: bar-blocklist: diff --git a/scripts/release/bundle.sh b/scripts/release/bundle.sh index 4a35033435..efedc5ae8c 100644 --- a/scripts/release/bundle.sh +++ b/scripts/release/bundle.sh @@ -181,22 +181,11 @@ make_bundle() ( sed -i.bak "s|\(pithead-${suffix}:\${STACK_VERSION:-dev}\)|\1@${sha}|" "$d/docker-compose.yml" done rm -f "$d/docker-compose.yml.bak" - # Post-condition: NEVER ship a partially-pinned bundle. Every first-party image line must now - # carry an @sha256 digest. local unpinned - unpinned="$(grep -E "pithead-(tor|monero|p2pool|xmrig-proxy|dashboard):" "$d/docker-compose.yml" | grep -v "@sha256:" || true)" + unpinned="$(grep -E "pithead-(tor|monero|p2pool|xmrig-proxy|caddy|socket-proxy|dashboard):" "$d/docker-compose.yml" | grep -v "@sha256:" || true)" [ -z "$unpinned" ] || die "make_bundle: first-party image(s) left un-pinned in the bundle compose (#376):"$'\n'"$unpinned" - # --no-xattrs: we cut releases on macOS, where tar is bsdtar and stores each file's extended - # attributes (incl. macOS's com.apple.provenance) as LIBARCHIVE.xattr.* pax headers. GNU tar on - # a user's Linux box doesn't know that keyword and warns once per file on extract (#252). Stripping - # xattrs makes the bundle clean; the flag is a portable no-op on GNU tar (xattrs aren't stored by - # default), so release.sh stays correct if a release is ever cut on Linux. tar --no-xattrs -czf "$out" -C "$WORKDIR" "pithead" - # Guard the fix (#252): the bundle must carry no extended-attribute pax headers - # (LIBARCHIVE.xattr.* from bsdtar / SCHILY.xattr.* from GNU tar) — those make GNU tar warn once - # per file on a Linux extract. pax headers store the keyword as plain text in the tar stream, so - # grepping the decompressed bytes detects them regardless of which tar built the archive. if gzip -dc "$out" 2>/dev/null | grep -qa -e 'LIBARCHIVE.xattr' -e 'SCHILY.xattr'; then die "Bundle $out carries xattr pax headers (#252) — GNU tar will warn on extract. Does this tar honor --no-xattrs?" fi diff --git a/scripts/release/release.sh b/scripts/release/release.sh index 2caa97b562..9babf2c709 100755 --- a/scripts/release/release.sh +++ b/scripts/release/release.sh @@ -61,18 +61,9 @@ PROD_REGISTRY=ghcr.io/p2pool-starter-stack REGISTRY="${PITHEAD_REGISTRY:-$PROD_REGISTRY}" IMAGE_PREFIX="${PITHEAD_IMAGE_PREFIX:-pithead-}" -# The 5 stack images, by build-dir / image-name suffix (build context = "build/", -# published image = "$REGISTRY/${IMAGE_PREFIX}"). The compose service for "monero" is "monerod". dashboard is the one exception — build context "dashboard/" at the repo root (#1106) — see build_images() below. -IMAGES=(tor monero p2pool xmrig-proxy dashboard) +IMAGES=(tor monero p2pool xmrig-proxy caddy socket-proxy dashboard) PUBLISHED_IMAGES=("${IMAGES[@]}" os-rootfs) -# Target platform(s) for the published images. linux/amd64 ONLY: the bundled binaries are x86_64 -# (monero/p2pool/xmrig-proxy ship `linux-x64`, and xmrig-proxy has NO arm64 build at all — so an arm64 -# image can't be made to work), and self-hosted miners run x86_64. The point of buildx here is to FORCE -# amd64 even on an arm64 release host — a plain `docker build` on Apple Silicon labels the image arm64 -# (the v1.0.0 bug), so it never ran on x86_64. The smoke stage fails the release if a pushed image -# doesn't carry every platform listed here. (Overridable via PITHEAD_PLATFORMS, but the components must -# actually ship binaries for any arch you add.) PLATFORMS="${PITHEAD_PLATFORMS:-linux/amd64}" BUILDX_BUILDER="${PITHEAD_BUILDX_BUILDER:-pithead-release}" @@ -261,16 +252,10 @@ pin() { xmrig-proxy) grep -oE '^ARG XMRIG_PROXY_VERSION=.*' build/xmrig-proxy/Dockerfile | cut -d= -f2 ;; tor) grep -oE '^ARG TOR_VERSION=.*' build/tor/Dockerfile | cut -d= -f2 ;; tor-base) grep -oE '^FROM [^ ]+' build/tor/Dockerfile | head -1 | awk '{print $2}' ;; - # `tari` is the NODE, deliberately, because scripts/watch/pin-watch.sh reads this arm for upstream - # currency and both Tari images come from one upstream repo — a second row there would say the - # same thing twice. The stack pins two images though (node + view-only console wallet), they are - # bumped together, and the release notes have to name both or a wallet-only move reads as - # unchanged (#1138). tests/stack/standalone/test_compose.sh asserts the two carry the same tag, so the - # lockstep this relies on is guarded rather than assumed. tari) grep -oE 'ghcr.io/tari-project/minotari_node:[^ ]+' docker-compose.yml | head -1 ;; tari-wallet) grep -oE 'ghcr.io/tari-project/minotari_console_wallet:[^ ]+' docker-compose.yml | head -1 ;; - caddy) grep -oE 'caddy:[0-9.]+@sha256:[a-f0-9]+' docker-compose.yml | head -1 ;; - socket-proxy) grep -oE 'tecnativa/docker-socket-proxy:[^ ]+' docker-compose.yml | head -1 ;; + caddy) grep -oE '^FROM caddy:[0-9.]+@sha256:[a-f0-9]+' build/caddy/Dockerfile | head -1 | cut -d' ' -f2 ;; + socket-proxy) grep -oE '^FROM tecnativa/docker-socket-proxy:[^ ]+' build/socket-proxy/Dockerfile | head -1 | cut -d' ' -f2 ;; rigforge) grep -oE '^ARG RIGFORGE_REF=.*' os/rootfs/Dockerfile | cut -d= -f2 ;; esac } diff --git a/scripts/release/resolve-pins.sh b/scripts/release/resolve-pins.sh index c8f7da15fb..35cc84615d 100755 --- a/scripts/release/resolve-pins.sh +++ b/scripts/release/resolve-pins.sh @@ -1,30 +1,4 @@ #!/usr/bin/env bash -# -# Third-party image pin currency, at the digest level (#1137). -# -# pin-watch.sh asks "is the pinned VERSION behind upstream's latest release" and says outright that -# it does NOT ask whether a pinned `tag@sha256:...` still has a digest that matches its tag. This -# script asks exactly that second question, for every third-party image docker-compose.yml pins by -# digest: ghcr.io/tari-project's tari node and wallet, tecnativa's socket-proxy, and caddy. -# -# The digest is what actually runs. A version bump that moves a tag and leaves the digest behind -# still runs the OLD image while the pin, the release notes, and every doc claim the new one — the -# exact half-done bump #1137 is about. Comparing tags (what pin-watch.sh already does) cannot catch -# it; only asking the registry what a tag resolves to right now can. -# -# Pin source is one grep over docker-compose.yml, not a hand-kept list: first-party images use -# ${PITHEAD_REGISTRY...}/${STACK_VERSION...} and are never digest-pinned, so the `@sha256:` pattern -# alone is the whole filter. A new third-party pin lands here on the next run with no edit to this -# file, and a first-party image added the same way is never mistaken for one. -# -# UNREACHABLE IS NOT CURRENT. A registry lookup that cannot complete is counted, named, and rc 1 — -# never silently treated as a match. A pin that could not be checked is UNCHECKED, not current. -# -# Usage: -# scripts/release/resolve-pins.sh Compare every digest-pinned image against its registry. -# rc 1 on any mismatch OR any failed lookup. -# scripts/release/resolve-pins.sh --self-test Drive extraction + comparison against fixtures, docker -# stubbed as a shell function. No network. set -Eeuo pipefail diff --git a/scripts/watch/trivyignore-watch.sh b/scripts/watch/trivyignore-watch.sh index 8ca1dcd0fe..17be821663 100755 --- a/scripts/watch/trivyignore-watch.sh +++ b/scripts/watch/trivyignore-watch.sh @@ -1,46 +1,4 @@ #!/usr/bin/env bash -# -# .config/trivyignore obsolete-mute watch (#1174). -# -# The weekly CVE sweep (#833) applies `.config/trivyignore`, hiding muted findings. This watch -# scans without that file so stale mutes cannot survive unseen, as two did in #1153. -# -# REPORT-ONLY. The `pin-watch.sh` posture: never a gate, because a cleared mute is housekeeping, not -# a build failure. It never edits `.config/trivyignore` and never opens a PR. -# -# `.config/trivyignore` covers several images. Seven IDs looked dead in a rootfs-only scan, -# but some were live in the dashboard. An ID is obsolete only if absent from every image. -# -# The covered images, enumerated from the real build/scan setup rather than guessed (ci.yml's -# build-images matrix + os-rootfs.yml, both cited below): -# pithead-os-rootfs os/rootfs/Dockerfile (debian:trixie-slim + the golang builder stage) -# pithead-dashboard dashboard (python:3.11-slim, default production stage) -# pithead-monero build/monero (ubuntu:24.04) -# pithead-p2pool build/p2pool (ubuntu:24.04) -# pithead-xmrig-proxy build/xmrig-proxy (ubuntu:24.04) -# pithead-tor build/tor (alpine:3.24) -# -# Build each image as the gate does; other build inputs would prove nothing about the gate. -# -# FAIL LOUDLY ON A BROKEN RUN. An empty image list, a build that cannot run, or a scan that cannot -# run (trivy/docker missing, a pull failure, an unparseable report) must never fall through to "0 -# obsolete mutes found" — that is a false green wearing the report's own shape, the same defect -# class the sweep itself has. A broken or partial scan means "unknown", never "clean", so this -# refuses to name ANY mute obsolete off an incomplete run and exits 1 instead. -# -# `--check-parity` compares TRIVY_VERSION with gate installer pins and image version (#1290, #2214). -# -# Usage: -# scripts/watch/trivyignore-watch.sh Build + scan every covered image with NO ignore file -# applied, print the report, rc 1 only if the run -# itself is broken (an obsolete-mute finding is -# printed, not a failure — report-only). -# scripts/watch/trivyignore-watch.sh --self-test Drive the union/report logic against fixture scan -# output. No docker, no network, no image builds. -# scripts/watch/trivyignore-watch.sh --check-parity -# Check that every gate workflow's install-trivy step -# pins `version:` to TRIVY_VERSION (#1290). No -# docker, no network. Exit code is the check's own rc. set -Eeuo pipefail @@ -55,15 +13,10 @@ GATE_WORKFLOWS="$ROOT/.github/workflows/ci.yml $ROOT/.github/workflows/os-rootfs TRIVY_VERSION="0.73.0" TRIVY_IMAGE="aquasec/trivy@sha256:7cced7cae583819fc7806d4cbc0dbbc7cad18b99f7d3e235192e6da8c091045c" # TRIVY_VERSION above -# Match the gate's severity/fixability scope so unrelated findings do not keep mutes live. SEVERITY="HIGH,CRITICAL" -IMAGES="pithead-os-rootfs pithead-dashboard pithead-monero pithead-p2pool pithead-xmrig-proxy pithead-tor" +IMAGES="pithead-os-rootfs pithead-dashboard pithead-monero pithead-p2pool pithead-xmrig-proxy pithead-caddy pithead-socket-proxy pithead-tor" -# --- building and scanning ------------------------------------------------------------------------ - -# -> image tag on stdout, rc 1 if the build fails. Build output goes to stderr so stdout -# carries only the tag. build_image() { local name="$1" tag="pithead-mutewatch-$1:latest" case "$name" in @@ -80,10 +33,9 @@ build_image() { --build-arg PITHEAD_UPDATER=rauc "$ROOT" >&2 || return 1 ;; pithead-dashboard) docker build -t "$tag" "$ROOT/dashboard" >&2 || return 1 ;; - pithead-monero) docker build -t "$tag" "$ROOT/build/monero" >&2 || return 1 ;; - pithead-p2pool) docker build -t "$tag" "$ROOT/build/p2pool" >&2 || return 1 ;; - pithead-xmrig-proxy) docker build -t "$tag" "$ROOT/build/xmrig-proxy" >&2 || return 1 ;; - pithead-tor) docker build -t "$tag" "$ROOT/build/tor" >&2 || return 1 ;; + pithead-monero | pithead-p2pool | pithead-xmrig-proxy | pithead-caddy | pithead-socket-proxy | pithead-tor) + docker build -t "$tag" "$ROOT/build/${name#pithead-}" >&2 || return 1 + ;; *) return 1 ;; esac printf '%s' "$tag" diff --git a/tests/integration/lib/run-lifecycle.sh b/tests/integration/lib/run-lifecycle.sh index bfc90f82a9..e5e3070010 100644 --- a/tests/integration/lib/run-lifecycle.sh +++ b/tests/integration/lib/run-lifecycle.sh @@ -30,10 +30,9 @@ _run_lifecycle() { assert_rc "status OK after restart" "$?" "0" lifecycle_gate_sample after-restart run_connection_announcements || lifecycle_stopped run_connection_announcements || return 1 - # Remove the socket-proxy image and prove up fetches a missing pinned image (#2654). if rx 'test -f dashboard/Dockerfile'; then local proxy_ref proxy_id proxy_fails="$IT_FAIL" - proxy_ref="$(rx "docker compose config --images" 2>/dev/null | grep -m1 'docker-socket-proxy')" + proxy_ref="$(rx "docker compose config --images" 2>/dev/null | grep -m1 'pithead-socket-proxy')" proxy_id="$(rx "docker image inspect --format '{{.Id}}' $(quote_arg "$proxy_ref")" 2>/dev/null)" lifecycle_gate_sample before-image-down it_step "removing the pinned socket-proxy image, then pithead up (#2654)…" diff --git a/tests/integration/mini-stack/test-boot-health-proxy.sh b/tests/integration/mini-stack/test-boot-health-proxy.sh index 7526f5aa8d..b5ba0c7513 100644 --- a/tests/integration/mini-stack/test-boot-health-proxy.sh +++ b/tests/integration/mini-stack/test-boot-health-proxy.sh @@ -11,10 +11,10 @@ cleanup() { rm -rf "$scratch" } trap cleanup EXIT -# Fail when the required daemon or already-built real dashboard image is missing. docker info >/dev/null docker image inspect pithead-dashboard:itest >/dev/null -image=$(awk '$0 == " caddy:" { s=1; next } s && $1 == "image:" { print $2; exit }' "$ROOT/docker-compose.yml") +image=pithead-caddy:boot-proxy-test +docker build -q -t "$image" "$ROOT/build/caddy" >/dev/null # shellcheck source=lib/pithead/35-caddyfile-and-auth-helpers.sh source "$ROOT/lib/pithead/35-caddyfile-and-auth-helpers.sh" is_appliance() { return 1; } diff --git a/tests/integration/selftest/selftest-lifecycle-gate-wiring.sh b/tests/integration/selftest/selftest-lifecycle-gate-wiring.sh index d465daca35..c0bb687085 100644 --- a/tests/integration/selftest/selftest-lifecycle-gate-wiring.sh +++ b/tests/integration/selftest/selftest-lifecycle-gate-wiring.sh @@ -35,7 +35,7 @@ rx() { 'source-image: guarded recreate matches declared image and Compose owner' \ 'source-image: original image restored' ;; - 'docker compose config --images') echo fixture-docker-socket-proxy ;; + 'docker compose config --images') echo fixture-pithead-socket-proxy ;; 'docker image inspect --format '*) echo fixture-image ;; *) return 0 ;; esac diff --git a/tests/integration/selftest/selftest-lifecycle-restore-health.sh b/tests/integration/selftest/selftest-lifecycle-restore-health.sh index 5ce248b574..57dda7fae4 100644 --- a/tests/integration/selftest/selftest-lifecycle-restore-health.sh +++ b/tests/integration/selftest/selftest-lifecycle-restore-health.sh @@ -152,7 +152,7 @@ drive_restore() { # [*-fails|archive-missing|verify-fails] -> rx() { case "$1" in "test -f dashboard/Dockerfile") [ "${SRC_CHECKOUT:-no}" = yes ] ;; - *"config --images") [ "$RESTORE_CASE" != no-proxy-image ] && printf 'tecnativa/docker-socket-proxy@sha256:x\n' ;; + *"config --images") [ "$RESTORE_CASE" != no-proxy-image ] && printf 'ghcr.io/p2pool-starter-stack/pithead-socket-proxy:dev\n' ;; *"image inspect --format"*) printf 'sha256:id' ;; "docker image inspect "*) [ "$RESTORE_CASE" != up-fails ] || trace_lifecycle post-up-image-inspect ;; ls*) [ "$RESTORE_CASE" != archive-missing ] && printf 'backups/pithead-backup-test.tar.gz' ;; diff --git a/tests/os/image-upgrade-bundle.sh b/tests/os/image-upgrade-bundle.sh index ec41f4a658..26dad7eb7f 100755 --- a/tests/os/image-upgrade-bundle.sh +++ b/tests/os/image-upgrade-bundle.sh @@ -32,7 +32,7 @@ TAG="$(tr -d '[:space:]' &2 exit 1 } -tar -xOf "$td/candidate.tar.gz" pithead/docker-compose.yml | grep -E 'pithead-(tor|monero|p2pool|xmrig-proxy|dashboard):\$\{STACK_VERSION:-dev\}@sha256:[0-9a-f]{64}' >/dev/null || { +tar -xOf "$td/candidate.tar.gz" pithead/docker-compose.yml | grep -E 'pithead-(tor|monero|p2pool|xmrig-proxy|caddy|socket-proxy|dashboard):\$\{STACK_VERSION:-dev\}@sha256:[0-9a-f]{64}' >/dev/null || { echo "candidate images are not digest pinned" >&2 exit 1 } diff --git a/tests/os/selftest-marker-images.sh b/tests/os/selftest-marker-images.sh index 4a652ada11..3580f80d33 100644 --- a/tests/os/selftest-marker-images.sh +++ b/tests/os/selftest-marker-images.sh @@ -42,7 +42,7 @@ for invalid_mapping in '{' '[]' 'null' '"not an object"' "$manifest"; do if select_marker_dashboard "$invalid_mapping" v2 "$registry" >"$T/refusal.log" 2>&1; then fail 'invalid JSON mapping accepted'; fi done mkdir -p os/build/stage images -for service in tor monero p2pool xmrig-proxy dashboard; do +for service in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do printf ' %s:\n image: registry.example/fixture/pithead-%s:v2\n' "$service" "$service" done >os/build/stage/docker-compose.yml printf '[{"Config":"%s.json"}]\n' "$config_digest" >images/manifest.json diff --git a/tests/os/verify-image-artifact-helpers.sh b/tests/os/verify-image-artifact-helpers.sh index 2698378311..fbbee89688 100644 --- a/tests/os/verify-image-artifact-helpers.sh +++ b/tests/os/verify-image-artifact-helpers.sh @@ -26,14 +26,14 @@ compose_reference() { # esac } -compose_matches_source() { # +compose_matches_source() { local actual="$2.actual" rc suffix expected_count pinned_count - for suffix in tor monero p2pool xmrig-proxy dashboard; do + for suffix in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do expected_count="$(grep -oE "pithead-${suffix}:[^[:space:]@]+" "$2" | wc -l)" pinned_count="$(grep -oE "pithead-${suffix}:[^[:space:]@]+@sha256:[0-9a-f]{64}" "$1/opt/pithead/docker-compose.yml" | wc -l)" [ "$expected_count" -gt 0 ] && [ "$expected_count" = "$pinned_count" ] || return 1 done - sed -E '/pithead-(tor|monero|p2pool|xmrig-proxy|dashboard):/s/@sha256:[0-9a-f]{64}//' "$1/opt/pithead/docker-compose.yml" >"$actual" || return 1 + sed -E '/pithead-(tor|monero|p2pool|xmrig-proxy|caddy|socket-proxy|dashboard):/s/@sha256:[0-9a-f]{64}//' "$1/opt/pithead/docker-compose.yml" >"$actual" || return 1 cmp -s "$actual" "$2" rc=$? rm -f "$actual" diff --git a/tests/stack/appliance/test-appliance-build-compose-source.sh b/tests/stack/appliance/test-appliance-build-compose-source.sh index bdf6685033..e0f3db3b5d 100644 --- a/tests/stack/appliance/test-appliance-build-compose-source.sh +++ b/tests/stack/appliance/test-appliance-build-compose-source.sh @@ -351,11 +351,10 @@ rp_run() { # -> "" then rc=N echo "rc=$?" ) 2>&1 } -rp_all="reg.test/pithead-tor:v9.9.9 reg.test/pithead-monero:v9.9.9 reg.test/pithead-p2pool:v9.9.9 reg.test/pithead-xmrig-proxy:v9.9.9 reg.test/pithead-dashboard:v9.9.9" +rp_all="reg.test/pithead-tor:v9.9.9 reg.test/pithead-monero:v9.9.9 reg.test/pithead-p2pool:v9.9.9 reg.test/pithead-xmrig-proxy:v9.9.9 reg.test/pithead-caddy:v9.9.9 reg.test/pithead-socket-proxy:v9.9.9 reg.test/pithead-dashboard:v9.9.9" rp_out="$(rp_run "$rp_all")" -assert_contains "a registry holding all five services is accepted" "$rp_out" "rc=0" +assert_contains "a registry holding every first-party service is accepted" "$rp_out" "rc=0" assert_eq " and accepting says nothing — the fixture really does resolve refs" "$(printf '%s' "$rp_out" | grep -c 'refusing a bench build')" "0" -# One missing ref is the whole defect: the stack comes up partial-to-empty either way. rp_out="$(rp_run "${rp_all% reg.test/pithead-dashboard:v9.9.9}")" assert_contains "a single unresolvable service refuses the build" "$rp_out" "rc=1" assert_contains " the refusal names the ref that could not be served" "$rp_out" "pithead-dashboard:v9.9.9" diff --git a/tests/stack/appliance/test-appliance-restore.sh b/tests/stack/appliance/test-appliance-restore.sh index a752e1dcce..91d0f373c6 100644 --- a/tests/stack/appliance/test-appliance-restore.sh +++ b/tests/stack/appliance/test-appliance-restore.sh @@ -31,7 +31,7 @@ mkdir -p "$RS/build/tari" "$RS/data/tor" "$RS/data/dashboard" "$RS/bin" "$RS/vol export PITHEAD_RESTORE_STAGE_ROOT="$RS/stage" cp "$STACK" "$RS/pithead" cp "$ROOT/build/tari/config.toml.template" "$RS/build/tari/" -cp "$ROOT/docker-compose.yml" "$RS/docker-compose.yml" # caddy_hash_password_b64 reads the pinned image from here +cp "$ROOT/docker-compose.yml" "$RS/docker-compose.yml" cat >"$RS/bin/docker" <<'EOF' #!/usr/bin/env bash case "$*" in diff --git a/tests/stack/dashboard/test-dashboard.sh b/tests/stack/dashboard/test-dashboard.sh index 57b90851d8..7355250f4a 100644 --- a/tests/stack/dashboard/test-dashboard.sh +++ b/tests/stack/dashboard/test-dashboard.sh @@ -531,9 +531,21 @@ fp1="$(run_sourced "$V" env_get_file "$V/.env" DASHBOARD_AUTH_PW_FP)" [ -n "$hash1" ] && ok "auth hash persisted (base64)" || bad "auth hash persisted (base64)" "empty" [ -n "$fp1" ] && ok "auth fingerprint persisted" || bad "auth fingerprint persisted" "empty" assert_contains "auth hashing disables container logs" "$(cat "$AUTH_LOG")" "run --rm -i --log-driver none " -assert_contains "auth hashed via the pinned caddy image" "$(cat "$AUTH_LOG")" "hash-password" +assert_contains "auth hashed via the pithead caddy image" "$(cat "$AUTH_LOG")" "run --rm -i --log-driver none ghcr.io/p2pool-starter-stack/pithead-caddy:dev caddy hash-password" assert_not_contains "auth password stays out of docker argv" "$(cat "$AUTH_LOG")" "hunter2hunter2" assert_contains "Caddyfile gains basic_auth" "$(cat "$V/Caddyfile")" "basic_auth" +mkdir -p "$V/hash-bin" "$V/hash-rel" +printf '%s\n' '#!/usr/bin/env bash' 'echo "$*" >>"$HASH_LOG"' 'case "$*" in "image inspect "*) exit 1 ;; "compose build caddy") exit "$HASH_BUILD_RC" ;; *hash-password*) echo x ;; esac' >"$V/hash-bin/docker" +chmod +x "$V/hash-bin/docker" +hash_out=$(HASH_LOG="$V/hash.log" HASH_BUILD_RC=0 PATH="$V/hash-bin:$PATH" run_sourced "$V" caddy_hash_password_b64 pw) +assert_eq "a source checkout builds a missing caddy image before hashing" "$(cat "$V/hash.log")" "$(printf '%s\n' 'image inspect ghcr.io/p2pool-starter-stack/pithead-caddy:dev' 'compose build caddy' 'run --rm -i --log-driver none ghcr.io/p2pool-starter-stack/pithead-caddy:dev caddy hash-password')" +assert_eq "the hash comes from the built caddy image" "$hash_out" "$(printf x | openssl base64 -A)" +hash_rc=0 +HASH_LOG="$V/hash-fail.log" HASH_BUILD_RC=1 PATH="$V/hash-bin:$PATH" run_sourced "$V" caddy_hash_password_b64 pw >/dev/null || hash_rc=$? +assert_eq "a failed caddy build refuses to hash" "$hash_rc" "1" +printf ' image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-caddy:${STACK_VERSION:-dev}@sha256:%s\n' "$(printf 'a%.0s' {1..64})" >"$V/hash-rel/docker-compose.yml" +HASH_LOG="$V/hash-rel.log" STACK_VERSION=v9.9.9 PATH="$V/hash-bin:$PATH" run_sourced "$V/hash-rel" caddy_hash_password_b64 pw >/dev/null +assert_eq "a release install hashes with the digest-pinned caddy image" "$(cat "$V/hash-rel.log")" "run --rm -i --log-driver none ghcr.io/p2pool-starter-stack/pithead-caddy:v9.9.9@sha256:$(printf 'a%.0s' {1..64}) caddy hash-password" case "$(cat "$V/.env" "$V/Caddyfile")" in *hunter2hunter2*) bad "auth plaintext never persisted" "password leaked into .env/Caddyfile" ;; *) ok "auth plaintext never persisted" ;; diff --git a/tests/stack/lib/verdict-label-determinism.sh b/tests/stack/lib/verdict-label-determinism.sh index c4339f5a8c..30e50cfcd4 100644 --- a/tests/stack/lib/verdict-label-determinism.sh +++ b/tests/stack/lib/verdict-label-determinism.sh @@ -172,6 +172,9 @@ test-release.sh|comp test-release.sh|pin_rel test-release.sh|svc test-render-quadlet.sh|f +test-render-quadlet.sh|img +test-render-quadlet.sh|pair +test-render-quadlet.sh|pkg test-render-quadlet.sh|qk test-render-quadlet.sh|ql test-render-quadlet.sh|qvar diff --git a/tests/stack/release/test-release-verify.sh b/tests/stack/release/test-release-verify.sh index 87d94f3b70..8bec2e086c 100644 --- a/tests/stack/release/test-release-verify.sh +++ b/tests/stack/release/test-release-verify.sh @@ -18,15 +18,12 @@ VRI="$SANDBOX/verify376" write_fake_docker "$VRI/bin" write_unreachable_docker "$VRI/nodocker" -# A deterministic 64-hex digest per image, and a digest-pinned compose (#461) so verify has the same -# @sha256 bytes to check that a release install's compose would pull (#451). TOR_DG is what the tor -# assertions expect the tor image to be verified/failed against. hex64() { printf "$1%.0s" $(seq 1 64); } TOR_DG="sha256:$(hex64 1)" -write_pinned_compose() { # $1=dir — one image: line per first-party suffix, each pinned by @sha256 +write_pinned_compose() { local d="$1" n=1 suffix : >"$d/docker-compose.yml" - for suffix in tor monero p2pool xmrig-proxy dashboard; do + for suffix in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do printf ' image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-%s:${STACK_VERSION:-dev}@sha256:%s\n' \ "$suffix" "$(hex64 "$n")" >>"$d/docker-compose.yml" n=$((n + 1)) @@ -47,14 +44,11 @@ out="$(PATH="$VRI/nodocker:/usr/bin:/bin" run_sourced "$VRI" verify_release_imag assert_rc "pubkey without a runnable verifier -> pull aborts" "$?" "1" assert_contains "verifier-missing abort names docker, not a host cosign" "$out" "docker is not available" -# Valid signatures (fake cosign exits 0): all 5 images verified with the committed key, no Rekor -# (--private-infrastructure), against the EXACT @sha256 digest compose pins and pulls (#451 — bound -# to the same bytes, not the mutable tag). : >"$VRI/cosign.log" out="$(PATH="$VRI/bin:/usr/bin:/bin" COSIGN_LOG="$VRI/cosign.log" PITHEAD_REGISTRY="" \ STACK_VERSION="v9.9.9" run_sourced "$VRI" verify_release_images 2>&1)" assert_rc "valid signatures -> pull proceeds" "$?" "0" -assert_eq "all 5 first-party images verified" "$(grep -c '^\[cosign\] verify ' "$VRI/cosign.log")" "5" +assert_eq "all 7 first-party images verified" "$(grep -c '^\[cosign\] verify ' "$VRI/cosign.log")" "7" assert_contains "verify binds to the pinned digest, not the tag (#451)" \ "$(cat "$VRI/cosign.log")" "verify --key cosign.pub --private-infrastructure ghcr.io/p2pool-starter-stack/pithead-tor@$TOR_DG" assert_not_contains "verify never resolves the mutable tag (#451)" "$(cat "$VRI/cosign.log")" "pithead-tor:v9.9.9" @@ -199,18 +193,12 @@ assert_rc "a path outside the install dir is refused, not guessed at" "$?" "1" run_sourced "$CCP" cosign_container_path "/etc/hosts" >/dev/null 2>&1 assert_rc "an absolute path elsewhere on the box is refused" "$?" "1" -# The build side of the same gate (#1891): what the appliance BAKES so the verify above can run at -# all — the release key, the five digest pins verify binds to, and the debug-build escape. It lives -# in this fragment rather than its own because the behaviour is verify_release_images', which this -# domain owns; run.sh sits exactly on its file-budget ceiling and a new registration there would -# have to displace something that file's own position-lock comment protects. - echo "== unit: appliance image signature pins (#1891) ==" SIG="$SANDBOX/appliance-signature" mkdir -p "$SIG/opt/pithead" SIG_BI="$(cat "$ROOT/os/build-image.sh")" SIG_DF="$(cat "$ROOT/os/rootfs/Dockerfile")" -assert_contains "the staged five-image compose is digest-pinned before the rootfs build" "$SIG_BI" 'pin_first_party_images os/build/stage/docker-compose.yml' +assert_contains "the staged first-party compose is digest-pinned before the rootfs build" "$SIG_BI" 'pin_first_party_images os/build/stage/docker-compose.yml' assert_contains "a synthetic-compose build (unresolvable version, by design) skips digest pinning" \ "$SIG_BI" $'if [ "${PITHEAD_OS_SYNTHETIC_COMPOSE:-}" != 1 ]; then\n pin_first_party_images' assert_contains "a debug registry requires its alternate cosign public key" "$SIG_BI" 'PITHEAD_REGISTRY_COSIGN_PUB: a readable alternate public key is required' @@ -221,16 +209,14 @@ printf '%s\n' \ 'image: ${PITHEAD_REGISTRY:-example.invalid}/pithead-monero:${STACK_VERSION:-dev}' \ 'image: ${PITHEAD_REGISTRY:-example.invalid}/pithead-p2pool:${STACK_VERSION:-dev}' \ 'image: ${PITHEAD_REGISTRY:-example.invalid}/pithead-xmrig-proxy:${STACK_VERSION:-dev}' \ + 'image: ${PITHEAD_REGISTRY:-example.invalid}/pithead-caddy:${STACK_VERSION:-dev}' \ + 'image: ${PITHEAD_REGISTRY:-example.invalid}/pithead-socket-proxy:${STACK_VERSION:-dev}' \ 'image: ${PITHEAD_REGISTRY:-example.invalid}/pithead-dashboard:${STACK_VERSION:-dev}' >"$SIG/compose.yml" cp "$SIG/compose.yml" "$SIG/reference.yml" -printf 'image: caddy:2.11.4@sha256:%064d\n' 3 >>"$SIG/compose.yml" -printf 'image: caddy:2.11.4@sha256:%064d\n' 3 >>"$SIG/reference.yml" +printf 'image: ghcr.io/tari-project/minotari_node:v1.0.0@sha256:%064d\n' 9 >>"$SIG/compose.yml" +printf 'image: ghcr.io/tari-project/minotari_node:v1.0.0@sha256:%064d\n' 9 >>"$SIG/reference.yml" MF_INDEX="sha256:$(hex64 a)" MF_CHILD="sha256:$(hex64 b)" -# The fake stands in for `docker buildx imagetools inspect` and emits its real shape: the index -# line at column 0, the per-platform children indented under Manifests:. A child carries an -# indented Digest: of its own, so the ^ anchor and the first-match exit in pin_first_party_images -# are both load-bearing here rather than incidental. fake_imagetools() { printf 'Name: example.invalid/pithead-tor:v9.9.9\n' printf 'MediaType: application/vnd.oci.image.index.v1+json\n' @@ -248,12 +234,7 @@ fake_imagetools() { docker() { fake_imagetools; } pin_first_party_images "$SIG/compose.yml" example.invalid v9.9.9 ) -assert_eq "all five provision pulls are immutable" "$(grep 'pithead-' "$SIG/compose.yml" | grep -c '@sha256:')" 5 -# #1891, the boot-breaking one: cosign signs the manifest-LIST (index) digest — sign_images hands -# `cosign sign` exactly what release.sh's manifest_digest resolved. A multi-arch tag's per-platform -# children are not signed at all (ghcr answers 200 for the index's .sig tag and 404 for the amd64 -# child's), so a resolver that pinned a child would pin bytes no signature covers and the -# fail-closed verify above would refuse on EVERY boot. Pin the index, never the child. +assert_eq "all seven provision pulls are immutable" "$(grep 'pithead-' "$SIG/compose.yml" | grep -c '@sha256:')" 7 assert_contains "a manifest list pins the signed index digest" "$(cat "$SIG/compose.yml")" "@$MF_INDEX" assert_not_contains "a manifest list never pins an unsigned per-platform child" "$(cat "$SIG/compose.yml")" "$MF_CHILD" @@ -268,11 +249,11 @@ tail -1 "$SIG/reference.duplicate.yml" >>"$SIG/opt/pithead/docker-compose.yml" compose_matches_source "$SIG" "$SIG/reference.duplicate.yml" assert_rc "the image verifier requires every duplicate first-party reference to be pinned" "$?" 1 missing_pin_accepted="" -for suffix in tor monero p2pool xmrig-proxy dashboard; do +for suffix in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do sed -E "/pithead-${suffix}:/s/@sha256:[0-9a-f]{64}//" "$SIG/compose.yml" >"$SIG/opt/pithead/docker-compose.yml" compose_matches_source "$SIG" "$SIG/reference.yml" && missing_pin_accepted="${missing_pin_accepted}${suffix} " done -assert_eq "the image verifier requires valid pins on all five first-party images" "$missing_pin_accepted" "" +assert_eq "the image verifier requires valid pins on all seven first-party images" "$missing_pin_accepted" "" sed -E '/pithead-tor:/s/STACK_VERSION:-dev/STACK_VERSION:-other/' "$SIG/compose.yml" >"$SIG/opt/pithead/docker-compose.yml" compose_matches_source "$SIG" "$SIG/reference.yml" assert_rc "the image verifier refuses a changed source tag despite a digest" "$?" 1 @@ -294,13 +275,13 @@ for pin_case in staging unset empty synthetic; do pin_tag=v9.9.9 [ "$pin_case" != staging ] || pin_tag=v9.9.9-rc.1 pin_number=0 - for pin_service in tor monero p2pool xmrig-proxy dashboard; do + for pin_service in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do pin_number=$((pin_number + 1)) printf 'image: ${PITHEAD_REGISTRY:-example.invalid}/pithead-%s:${STACK_VERSION:-dev}@sha256:%064d\n' \ "$pin_service" "$pin_number" >>"$pin_dir/expected.yml" printf 'example.invalid/pithead-%s:%s\n' "$pin_service" "$pin_tag" >>"$pin_dir/expected-lookups" done - printf 'image: caddy:2.11.4@sha256:%064d\n' 3 >>"$pin_dir/expected.yml" + printf 'image: ghcr.io/tari-project/minotari_node:v1.0.0@sha256:%064d\n' 9 >>"$pin_dir/expected.yml" if [ "$pin_case" = synthetic ]; then cp "$SIG/reference.yml" "$pin_dir/expected.yml" : >"$pin_dir/expected-lookups" @@ -320,10 +301,9 @@ for pin_case in staging unset empty synthetic; do docker() { [ "$1 $2 $3" = "buildx imagetools inspect" ] || return 1 printf '%s\n' "$4" >>lookups - # Only the expected tag exists: final tags are absent in the staging case. [ "${4##*:}" = "$pin_tag" ] || return 1 local service_number=0 service - for service in tor monero p2pool xmrig-proxy dashboard; do + for service in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do service_number=$((service_number + 1)) if [ "$4" = "example.invalid/pithead-$service:$pin_tag" ]; then printf 'Digest: sha256:%064d\n' "$service_number" @@ -335,7 +315,7 @@ for pin_case in staging unset empty synthetic; do source "$SIG/pin-call.sh" ) >"$pin_dir/output" 2>&1 assert_rc "$pin_case pin invocation succeeds" "$?" 0 - assert_eq "$pin_case resolves exactly the five expected registry tags" \ + assert_eq "$pin_case resolves exactly the seven expected registry tags" \ "$(cat "$pin_dir/lookups")" "$(cat "$pin_dir/expected-lookups")" assert_eq "$pin_case preserves version references and third-party pins" \ "$(cat "$pin_dir/os/build/stage/docker-compose.yml")" "$(cat "$pin_dir/expected.yml")" diff --git a/tests/stack/release/test-release.sh b/tests/stack/release/test-release.sh index 7d343ceaf8..dd148fee51 100644 --- a/tests/stack/release/test-release.sh +++ b/tests/stack/release/test-release.sh @@ -239,8 +239,8 @@ _expected_docs=$(printf '%s\n' configuration.md dashboard.md faq.md getting-star assert_eq "bundle ships exactly the operator docs, no developer or appliance material" "$_bundle_docs" "$_expected_docs" assert_eq "bundled operator docs have no unresolved relative links or images" "$(grep -ERh '](\(\.\.?/|\([[:alnum:]_-]+(\.md|/))|src(set)?="\./' "$SANDBOX/bundle/pithead/docs" 2>/dev/null | wc -l | tr -d ' ')" "0" assert_eq "bundle excludes source, test, dashboard and appliance trees" "$(grep -Ec '^pithead/(lib|os|scripts|tests|dashboard|\.github)/' "$SANDBOX/bundle.list" || true)" "0" -_bundle_unpinned=$(grep -E 'pithead-(tor|monero|p2pool|xmrig-proxy|dashboard):' "$SANDBOX/bundle-compose.yml" 2>/dev/null | grep -cv '@sha256:') -[ "${_bundle_unpinned:-1}" -eq 0 ] && ok "bundle compose digest-pins all 5 first-party images (#376)" || bad "bundle digest-pins first-party images (#376)" "unpinned lines: ${_bundle_unpinned:-?}" +_bundle_unpinned=$(grep -E 'pithead-(tor|monero|p2pool|xmrig-proxy|caddy|socket-proxy|dashboard):' "$SANDBOX/bundle-compose.yml" 2>/dev/null | grep -cv '@sha256:') +[ "${_bundle_unpinned:-1}" -eq 0 ] && ok "bundle compose digest-pins all first-party images (#376)" || bad "bundle digest-pins first-party images (#376)" "unpinned lines: ${_bundle_unpinned:-?}" if grep -q 'pithead-dashboard:${STACK_VERSION:-dev}@sha256:0000000000000000000000000000000000000000000000000000000000000001' "$SANDBOX/bundle-compose.yml" 2>/dev/null; then ok "digest pin appends only the bare sha256, no double-repo (#376)" else @@ -342,8 +342,8 @@ done for row in \ "tari|docker-compose.yml|ghcr.io/tari-project/minotari_node:" \ "tari-wallet|docker-compose.yml|ghcr.io/tari-project/minotari_console_wallet:" \ - "caddy|docker-compose.yml|caddy:" \ - "socket-proxy|docker-compose.yml|tecnativa/docker-socket-proxy:" \ + "caddy|build/caddy/Dockerfile|caddy:" \ + "socket-proxy|build/socket-proxy/Dockerfile|tecnativa/docker-socket-proxy:" \ "tor|build/tor/Dockerfile|-r" \ "tor-base|build/tor/Dockerfile|:"; do comp="${row%%|*}" diff --git a/tests/stack/standalone/test_caddyfile.sh b/tests/stack/standalone/test_caddyfile.sh index c6cbd28dbc..fdb0aa82dc 100755 --- a/tests/stack/standalone/test_caddyfile.sh +++ b/tests/stack/standalone/test_caddyfile.sh @@ -13,16 +13,8 @@ if ! docker info >/dev/null 2>&1; then exit 0 fi -CADDY_IMAGE="$(awk ' - $0 == " caddy:" { service = 1; next } - service && /^ [[:alnum:]_-]+:$/ { exit } - service && $1 == "image:" { print $2; exit } -' "$ROOT/docker-compose.yml")" -[[ "$CADDY_IMAGE" =~ @sha256:[a-f0-9]{64}$ ]] || { - echo "FAIL: services.caddy.image is not pinned by sha256 in docker-compose.yml" >&2 - exit 1 -} -case "$CADDY_IMAGE" in */*) ;; *) CADDY_IMAGE="docker.io/library/$CADDY_IMAGE" ;; esac +CADDY_IMAGE=pithead-caddy:caddyfile-test +docker build -q -t "$CADDY_IMAGE" "$ROOT/build/caddy" >/dev/null # shellcheck source=tests/stack/lib.sh source "$ROOT/tests/stack/lib.sh" diff --git a/tests/stack/standalone/test_compose.sh b/tests/stack/standalone/test_compose.sh index 44c8b35064..32a8b7cf3d 100755 --- a/tests/stack/standalone/test_compose.sh +++ b/tests/stack/standalone/test_compose.sh @@ -129,30 +129,13 @@ expect_present "monerod healthcheck via script" "monerod-healthcheck.sh" expect_present "p2pool healthcheck via script" "p2pool-healthcheck.sh" expect_absent "no get_info (creds) in compose healthcheck" "get_info" -# Log rotation (#123): every service must carry the json-file size cap, including caddy and the two -# socket proxies that previously fell back to Docker's uncapped default. All 9 services (monerod is -# present under the local_node profile in this env) render one `max-size` line each. expect_min "log rotation on every service" "max-size:" 9 -# Image digest pinning (#135): the externally-pulled images must reference an immutable @sha256 -# digest, not just a mutable tag, so a re-pushed tag can't silently change the running image. -# -# The WHOLE reference, not the `tag@sha256:` prefix (#1137). In a `tag@digest` reference the digest -# is authoritative and the tag is decoration — that is the point of the pin, per the comment on -# these images in docker-compose.yml. A prefix match therefore passes on the half-done bump that -# matters: move the tag here and in the compose file, leave the digest, and the stack keeps pulling -# the old image while the file, this test, the release notes and the docs all announce the new -# version. Spelling the digest out makes the value a reviewable part of the diff at bump time. -# A COUNT, not a presence check (#1137's residual). This image runs TWICE — docker-proxy and -# docker-control — and expect_present is a grep -q, so it matches either line: bumping one proxy and -# leaving the other was green. The two would then run different socket-proxy builds, which is exactly -# the split the separate-proxy design exists to prevent. -expect_min "tecnativa socket-proxy pinned by digest (both proxies)" "tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459" 2 -expect_present "caddy pinned by digest" "caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b" +expect_min "socket proxies run the pithead-built image" "ghcr.io/p2pool-starter-stack/pithead-socket-proxy:dev" 2 +expect_present "caddy runs the pithead-built image" "ghcr.io/p2pool-starter-stack/pithead-caddy:dev" expect_present "tari node pinned by digest" "minotari_node:v6.0.1-pre.0-mainnet@sha256:23ce381b74e48cf67677dfe85c800daf54a155a610c595c94b16db6b186950ec" -# Per-service precision checks via the JSON render. JSON="$(docker compose --env-file "$ENV_FILE" -f "$ROOT/docker-compose.yml" config --format json 2>/dev/null)" -jq_assert() { #