Compare commits

...
Author SHA1 Message Date
shadowdaoandClaude Sonnet 5.5 af8e8a37e5 arm64-attach: diagnostics in plan step
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 21:18:47 -08:00
jknappandClaude Sonnet 5.5 6bf0b3d0d7 Merge pull request #50: arm64-attach plan after buildx [skip ci]
[skip ci]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-20 05:14:31 +00:00
shadowdaoandClaude Sonnet 5.5 c7a2d9f275 arm64-attach: run the plan step after Buildx setup (imagetools needs the plugin); show inspect errors
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 21:14:17 -08:00
jknappandClaude Sonnet 5.5 2ad7249d9f Merge pull request #49: arm64 publish policy [skip ci]
serialise arm64 legs, one retry, no silent arm64 drop, ELF check. [skip ci]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-20 05:13:12 +00:00
shadowdaoandClaude Sonnet 5.5 344c5e8d0d ci: address Opus review of the arm64 policy PR
- job timeouts 130 (cac, cac-fpm) / 80 (shared-httpd) so the retry fits; test pins the budget
- verify-image-arch.py: bounded docker calls, pull retried 3x, exit 4 'could not pull' (not an
  arch verdict), pulled image removed afterwards
- ARM64_DIGEST only taken from the first attempt when it succeeded
- comments/docs: max-parallel is per-job and unverified; guard also fires on skipped/cancelled

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 21:12:56 -08:00
shadowdaoandClaude Sonnet 5.5 e1ea28e6a8 ci: arm64 policy - serialise legs, one retry, never drop an existing arm64, ELF check before publish
- max-parallel: 2 on the cac / cac-fpm matrices (8 concurrent QEMU legs failed on 2026-11-19)
- ONE retry of a failed arm64 leg (90 s pause) in cac, cac-fpm, shared-httpd
- assemble-multiarch-index.sh: --guard-existing-arm64 (fail instead of replacing a multi-arch
  tag by amd64-only; dispatch input allow_amd64_only overrides) and --verify-bin (ELF machine
  type of amd64 and arm64 before any tag is written)
- tests: assemble-guard.test.sh, wiring tests; docs/arm64-publish-policy.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 21:12:56 -08:00
jknappandClaude Sonnet 5.5 655c88f10b Merge pull request #48: arm64-attach workflow [skip ci]
arm64-attach workflow, attach script, ELF check. [skip ci]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-20 05:11:33 +00:00
shadowdaoandClaude Sonnet 5.5 42f72e24ff attach-arm64: address review (never roll back a newer publish, mandatory --expect-index, --follow-tag, trunk-only, pin checks to planned amd64 digest)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 21:11:26 -08:00
shadowdaoandClaude Sonnet 5.5 02de5c6568 ci: arm64-attach workflow - restore an arm64 entry on an existing tag without touching amd64
New manual workflow arm64-attach.yaml (cac / cac-fpm, one php leg per run, serialised):
builds ONLY arm64 (QEMU, push by digest, same Dockerfile and build-args), checks the ELF
machine type of the arm64 entry (AArch64) and of the existing amd64 entry (x86-64), checks
PHP version parity, then re-creates the tag index from the existing amd64 entries (carried
over by digest) + the new arm64 via scripts/attach-arm64-index.sh. The amd64 manifest digest
is verified identical afterwards (previous index restored if not). Refuses when the tag already
has arm64 unless force=true, and when the tag moved since the plan.

- scripts/attach-arm64-index.sh (+ stub-registry test)
- scripts/verify-image-arch.py (+ test): ELF e_machine check via docker cp, nothing is executed;
  idea from haproxy-manager-base PR #22
- multiarch-workflow.test.py: static wiring checks for the new workflow
- Shell-Checks: new scripts and tests added

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 21:03:27 -08:00
jknapp 935b02eae4 Merge pull request 'tests: fix SC2034 + pipefail hazard in lsphp-src-upload-progress test' (#47) from fix/shellcheck-upload-progress-test into trunk
[skip ci] Fix shellcheck SC2034 and pipefail SIGPIPE pattern in lsphp upload-progress test
2026-11-19 20:13:37 +00:00
shadowdaoandClaude Sonnet 5.5 be8723c468 tests: fix SC2034 and early-exit pipeline in lsphp-src-upload-progress test
Shell-Checks failed on SC2034 (SRC only used inside eval), and the
lsphp-info-probe structural scan flagged the grep|grep|head pipeline
(pipefail SIGPIPE hazard) in the same new test. Replace with a read loop;
export SRC. No product script changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 12:01:11 -08:00
jknapp a43a755b9d Merge pull request #46 PHP 8.6 for cac/cac-fpm [skip ci]
[skip ci]
2026-11-19 19:38:17 +00:00
shadowdaoandClaude Sonnet 5.5 47fef38052 install-php86: keep geoip (Remi php-rlerdorf-geoip provides php-pecl-geoip on 8.6); fix grep pipe
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 11:37:57 -08:00
shadowdaoandClaude Sonnet 5.5 854042b1c3 feat: PHP 8.6 for cac and cac-fpm (Remi php:remi-8.6), per-family version lists in plan-legs
install-php86.sh = install-php85.sh minus php-pecl-geoip (no 8.6 build), fail-loud with
extension assertion. plan-legs.sh: per-family lists so cac/cac-fpm get 82-86 while
cac-litespeed/cac-lsphp stay 82-85 (no lsphp86). :latest stays on php85. ini files are
shared (single prod-php.ini), so 8.5 hardening incl. session.use_strict_mode=0 applies unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 11:32:25 -08:00
jknapp e6e3f1fd48 Merge pull request #45 re-pin LSAPI [skip ci]
[skip ci]
2026-11-19 17:54:45 +00:00
shadowdaoandClaude Sonnet 5.5 32af04b825 fix(lsphp-src): re-pin LiteSpeed LSAPI php-litespeed-8.4.tgz (republished 2026-11-19 17:39Z) [skip ci]
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 09:54:36 -08:00
jknapp 697926a5bb Merge pull request fix/lsphp-inconsistent-repo-pin (#44) [skip ci]
[skip ci]
2026-11-19 17:46:09 +00:00
shadowdaoandClaude Sonnet 5.5 fe9d9fe181 fix(lsphp): post-install check asserts exact resolved pins incl. -ldap [skip ci]
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 09:46:06 -08:00
shadowdaoandClaude Sonnet 5.5 40f62c2b64 fix(lsphp): per-package pins so an inconsistent LiteSpeed 8.4 set still builds [skip ci]
Stage 2 pinned lsphp84, -common and -ldap to one version; LiteSpeed's repo
offers lsphp84 8.4.27-2 but lsphp84-common only 8.4.27-3 (run 5691 job 18704:
E: Version '8.4.27-2+noble' for 'lsphp84-common' was not found). New
scripts/lsphp-pin-resolve.sh resolves -common/-ldap to the exact version when
offered (unchanged for 82/83/85), else a same-PHP-version, same-distro,
>= revision; never a different PHP release. lsphp84 itself stays exact and the
post-install check requires same upstream + >=. Fixture test added to CI.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 09:44:50 -08:00
jknappandClaude Sonnet 5.5 d792a6549b Merge pull request #43: re-pin LSAPI to 8.4 [skip ci]
[skip ci]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 15:37:16 +00:00
shadowdaoandClaude Sonnet 5.5 ea219b4adf lsphp-src: re-pin LiteSpeed SAPI to php-litespeed-8.4.tgz (matches packaged -2 builds)
Run 5686 passed the ini gate but failed the LSAPI name-set gate: packaged lsphp82-85 carry LSAPI_ENABLE_ADMIN_OVERRIDE / 'LiteSpeed V8.4', absent from the 8.3 tgz. Gate kept. [skip ci]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 07:37:13 -08:00
jknappandClaude Sonnet 5.5 95cced5144 Merge pull request #42: lsphp-src-build reproduce upload_progress default [skip ci]
[skip ci]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 14:56:03 +00:00
shadowdaoandClaude Sonnet 5.5 01ac98d677 lsphp-src-build: reproduce packaged session.upload_progress.enabled=1 default (step 2c)
Emergency run 5683 failed the 4b ini-defaults gate in all 8 jobs; that was the only differing default. Gate kept. [skip ci]

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-19 06:55:56 -08:00
jknapp 2b308e9192 Merge pull request #41: workflow_dispatch input to rebuild a single image leg [skip ci] 2026-11-12 15:57:29 +00:00
shadowdaoandClaude Sonnet 5.5 b5bb46740d build-push: workflow_dispatch input only to rebuild a single image leg
Gitea cannot re-run one job and a full run takes ~1h. Add a plan job that
turns the optional `only` input (e.g. cac:php85) into one filtered matrix per
image family; image jobs take their matrix from it and are skipped when empty.
Push events / empty input plan the full set as before. Unknown values fail
the plan job. Tests added to multiarch-workflow.test.py.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXjXyosSkunDsdWz3mb
2026-11-12 07:52:13 -08:00
jknapp 4e657304c5 Merge pull request #40: multi-arch (amd64 + arm64) for cac, cac-fpm, shared-httpd [skip ci] 2026-11-12 14:50:26 +00:00
shadowdaoandClaude Sonnet 5.5 01741e735a ci: publish cac, cac-fpm and shared-httpd multi-arch (amd64 + arm64)
One job per matrix leg on the trusted x86 runner: amd64 built natively, arm64
under QEMU, each pushed BY DIGEST (untagged), then
scripts/assemble-multiarch-index.sh creates the existing tags (:phpNN, :latest
for php85 / shared-httpd :latest) from this run's digests. The arm64 step is
continue-on-error with its own timeout, so an arm64 failure publishes the usual
amd64-only tag and a stale arm64 is never re-attached. Build args, base-image
pin, pkg-cache probe, php.net EXPECT_PHP_MIN gate, secrets and the
cac-litespeed/cac-lsphp/shared-ols jobs are untouched. No Dockerfile change.

Adds scripts/tests/multiarch-workflow.test.py (static wiring + tag-scheme
execution) to Shell-Checks, and fixes index-platforms.test.sh line 17 which
tripped lsphp-info-probe.test.sh's early-exit-reader scan on trunk.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXjXyosSkunDsdWz3mb
2026-11-12 06:13:02 -08:00
jknapp 1c9b0edeca Merge pull request 'Remove mod_http2/mod_md from Apache images + build gate (CVE-2026-119618)' (#39) from fix/disable-http2-md-modules into trunk
Cloud Apache Container / Build-and-Push (82) (push) Successful in 5m40s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 6m2s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 5m50s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 5m39s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 5m25s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 5m8s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 3m10s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 6m24s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 5m59s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 5m23s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 5m45s
Cloud Apache Container / Build-LSPHP-Images (82) (push) Successful in 4m17s
Cloud Apache Container / Build-LSPHP-Images (83) (push) Successful in 6m25s
Cloud Apache Container / Build-LSPHP-Images (84) (push) Successful in 6m45s
Cloud Apache Container / Build-LSPHP-Images (85) (push) Successful in 3m55s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 1m11s
Cloud Apache Container / Build-Shared-OLS (push) Successful in 3m28s
Cloud Apache Container / Shell-Checks (push) Failing after 16s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 3m20s
2026-11-12 14:01:06 +00:00
shadowdaoandClaude Sonnet 5.5 541c565947 Remove mod_http2/mod_md from Apache images, add build gate (CVE-2026-119618)
mod_http2 (httpd 2.4.55-2.4.70) assign_headers() heap corruption -> RCE;
AlmaLinux has no fixed httpd yet. Nothing in WHP uses HTTP/2 inside a
container (HAProxy edge terminates h2/h3 and speaks HTTP/1.1 to backends),
so uninstall mod_http2 (and mod_md if ever present) from cac, cac-fpm and
shared-httpd. scripts/httpd-h2-md-gate.sh fails the build if http2_module,
proxy_http2_module or md_module is loadable or `httpd -t` fails, writes
/etc/whp-httpd-version and the images get LABEL org.whp.httpd-h2-md=removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXjXyosSkunDsdWz3mb
2026-11-12 05:58:57 -08:00
jknapp adf74e2f69 Merge pull request #38: index-safe php.net emergency guard and emergency workflow [skip ci] 2026-11-12 01:55:43 +00:00
shadowdaoandClaude Sonnet 5.5 8a6a6d7b44 ci: multi-arch-safe php.net guard and emergency workflow (no platform change)
- scripts/image-label-amd64.sh: index-safe read of the amd64 image's labels
  (OCI index with attestations, Docker manifest list, single manifest).
- scripts/php-emergency-guard.sh: used by both build-push.yaml guard sites;
  same decisions as the old inline step on single-platform images, but FAILS
  CLOSED when the labels cannot be read (only "tag not found" passes).
- lsphp-source-emergency.yaml: push by digest + assemble (copy of HMB
  assemble-multiarch-index.sh); optional arm64; refuses to replace a
  multi-arch production tag with amd64-only unless allow_amd64_only.
- Tests wired into Shell-Checks; main build matrix platforms unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXjXyosSkunDsdWz3mb
2026-11-11 17:22:24 -08:00
jknapp 4b35869477 Merge pull request #37: arch-aware mariadb repo and lsphp lookups [skip ci] 2026-11-12 01:15:07 +00:00
shadowdaoandClaude Sonnet 5.5 ad66667053 build: arch-aware mariadb.repo and lsphp index lookup (amd64 unchanged)
- Dockerfile, Dockerfile.fpm: select rhel$releasever-<amd64|aarch64> from uname -m
  (amd64 file is byte-identical; $basearch cannot be used, x86_64 path 404s).
- scripts/lsphp-repo-version.sh replaces three inline binary-amd64 lookups
  (build-push.yaml x2, lsphp-source-emergency.yaml); arch defaults to amd64.
- fixture test wired into Shell-Checks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXjXyosSkunDsdWz3mb
2026-11-11 17:01:34 -08:00
jknapp e7d4db5bd3 Merge pull request 'fix(cac): healthcheck fails only on no answer or 5xx, not 4xx' (#34) from fix/healthcheck-4xx into trunk
Cloud Apache Container / Shell-Checks (push) Successful in 17s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 4m12s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 5m6s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 5m21s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 2m31s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 5m49s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 5m35s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 5m53s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 5m39s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 2m36s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 4m52s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 4m53s
Cloud Apache Container / Build-LSPHP-Images (84) (push) Successful in 2m50s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 4m36s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 1m40s
Cloud Apache Container / Build-Shared-OLS (push) Successful in 38s
Cloud Apache Container / Build-LSPHP-Images (83) (push) Successful in 5m25s
Cloud Apache Container / Build-LSPHP-Images (82) (push) Successful in 5m46s
Cloud Apache Container / Build-LSPHP-Images (85) (push) Successful in 5m33s
2026-10-22 15:04:10 +00:00
jknapp 0fee1b54c4 Merge pull request 'pkg-cache: Debian/NodeSource/Go/EL9 modes; wire cac-litespeed + cac-lsphp; docs' (#36) from ci/pkg-cache-more-upstreams into trunk
Cloud Apache Container / Shell-Checks (push) Successful in 37s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 2m44s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 4m36s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 4m52s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 5m9s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 4m14s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 2m31s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 4m53s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 4m45s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 2m43s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 3m57s
Cloud Apache Container / Build-LSPHP-Images (85) (push) Successful in 4m6s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 5m17s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 5m48s
Cloud Apache Container / Build-LSPHP-Images (83) (push) Successful in 5m20s
Cloud Apache Container / Build-LSPHP-Images (82) (push) Successful in 6m2s
Cloud Apache Container / Build-LSPHP-Images (84) (push) Successful in 5m37s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 1m43s
Cloud Apache Container / Build-Shared-OLS (push) Successful in 44s
2026-10-22 14:35:51 +00:00
shadowdaoandClaude Opus 5.5 9baa7a6029 docs(pkg-cache): new upstreams, modes, wired repos, how to add an upstream
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 07:35:36 -07:00
shadowdaoandClaude Opus 5.5 3a6cab19ee ci: wire cac-litespeed and cac-lsphp to the package cache and digest-pinned base
Dockerfile.litespeed / Dockerfile.lsphp: one global
ARG BASE_IMAGE=litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER}
used by every stage (incl. the emergency lsphp-src stage, which stays on
upstream repos). The stages that run lsphp-apt-upgrade.sh (litespeed final,
lsphp ext-build + final) take ARG PKG_CACHE=, ship pkg-cache-repos.sh +
keys/pkg-cache/, and wrap the upgrade in `pkg-cache-repos.sh apt` ...
`pkg-cache-repos.sh restore`. Without PKG_CACHE both are no-ops.

lsphp-apt-upgrade.sh: the madison gate also accepts ${PKG_CACHE}/litespeed/
as the lsphp source, but only when PKG_CACHE is set.

build-push.yaml: Build-LiteSpeed-Images and Build-LSPHP-Images resolve the
base digest directly from Docker Hub, probe the cache, set up buildx with
the registry mirror only for a pinned base, and pass BASE_IMAGE + PKG_CACHE.
OLS_VERSION (1.8.4) is now a job-level env read by both the digest lookup
and the build-arg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 07:11:52 -07:00
shadowdaoandClaude Opus 5.5 6a11fc9894 feat(pkg-cache): Debian, NodeSource, Go proxy and EL9 support in pkg-cache-repos.sh
Backward compatible; existing modes unchanged for existing callers.
- apt: also rewrites deb.debian.org/debian, deb.debian.org/debian-security and
  security.debian.org to <cache>/debian and <cache>/debian-security; the
  listing no longer fails under pipefail when /etc/apt/sources.list is absent
  (Debian 13 images).
- rpm: rewrites rpm.nodesource.com repos to <cache>/nodesource (gpgcheck=1;
  NodeSource does not sign repomd).
- new `nodesource MAJOR`: writes the nodesource-nodejs repo itself with the
  committed signing key (replaces curl setup_N.x | bash).
- new `go-env`: prints GOPROXY=<cache>/goproxy|https://proxy.golang.org|direct
  plus SSL_CERT_FILE for the RUN; go.sum + sum.golang.org still verify.
- release-install: EL9 or EL10 picked from rpm %rhel; adds RPM-GPG-KEY-EPEL-9.
- PKG_CACHE is regex-validated.
Tested through the cache on a throwaway runner CT (pve vmbr2): EL9+EPEL9,
NodeSource 22 on EL10, Debian trixie apt, golang:1.25 apt + go-env; restore
left no cache reference in each case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 07:08:22 -07:00
jknapp 05ad47a833 Merge pull request 'ci: pin base images by digest resolved directly from Docker Hub' (#35) from ci/base-image-digest-pin into trunk
Cloud Apache Container / Shell-Checks (push) Successful in 1m8s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 3m50s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 5m55s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 5m24s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 5m55s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 5m21s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 2m15s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 6m7s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 6m1s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 1m28s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 6m4s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 7m2s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 7m21s
Cloud Apache Container / Build-LSPHP-Images (83) (push) Successful in 7m3s
Cloud Apache Container / Build-LSPHP-Images (84) (push) Successful in 7m3s
Cloud Apache Container / Build-LSPHP-Images (85) (push) Successful in 7m30s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 3m48s
Cloud Apache Container / Build-Shared-OLS (push) Successful in 3m47s
Cloud Apache Container / Build-LSPHP-Images (82) (push) Successful in 14m41s
2026-10-22 13:59:04 +00:00
shadowdaoandClaude Opus 5.5 d1547f3418 ci: pin base images by digest resolved directly from Docker Hub
With the pkg-cache BuildKit mirror on, `FROM almalinux/10-base` was resolved
by tag through the cache, so a compromised cache could substitute the image.

Each job using the mirror now looks up the base tag's digest DIRECTLY at
registry-1.docker.io (.gitea/scripts/resolve-base-image.sh, HTTPS, HEAD on
the manifest, regex-validated) and builds FROM image@sha256:... via the
BASE_IMAGE build-arg, so the mirror can only serve content-addressed blobs.
If the lookup fails, the mirror is NOT used for that job and the tag is pulled
straight from Docker Hub. The digest is resolved every run (no manual bumps);
local builds default to the tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 06:58:16 -07:00
shadowdaoandClaude Opus 5.5 a00a3c7fc3 fix(cac): healthcheck fails only on no answer or 5xx, not 4xx
curl -f also failed on 403/404, so a new site with an empty docroot showed
unhealthy forever and WHP's monitor restarted it as PHP wedged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 05:41:40 -07:00
jknapp 3334f94cd5 Merge pull request 'ci: stop building PHP 7.4, 8.0 and 8.1 images' (#33) from ci/drop-eol-php into trunk
Cloud Apache Container / Shell-Checks (push) Successful in 17s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 2m52s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 4m57s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 2m36s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 4m40s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 4m26s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 5m13s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 4m12s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 4m59s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 2m40s
Cloud Apache Container / Build-LSPHP-Images (85) (push) Successful in 1m57s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 5m6s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 55s
Cloud Apache Container / Build-Shared-OLS (push) Successful in 47s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 5m19s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 5m40s
Cloud Apache Container / Build-LSPHP-Images (83) (push) Successful in 5m47s
Cloud Apache Container / Build-LSPHP-Images (82) (push) Successful in 6m29s
Cloud Apache Container / Build-LSPHP-Images (84) (push) Successful in 6m12s
2026-10-22 01:13:20 +00:00
shadowdaoandClaude Opus 5.5 76fc53358c ci: stop building PHP 7.4, 8.0 and 8.1 images
All four image matrices (cac, cac-fpm, cac-litespeed, cac-lsphp) and the
emergency lsphp-from-source workflow now build PHP 8.2-8.5 only. 7.4-8.1 are
end of life and got no upstream fix for CVE-2026-109618/109619; no fleet site
runs them any more. Existing :php74/:php80/:php81 tags stay in the registry
but are no longer rebuilt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 18:13:18 -07:00
jknapp fc60ac5ef3 Merge pull request 'fix(pkg-cache): no | while read pipelines under pipefail (Shell-Checks)' (#32) from fix/pkg-cache-shellcheck-pipefail into trunk
Cloud Apache Container / Shell-Checks (push) Successful in 16s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 5m14s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 4m24s
Cloud Apache Container / Build-and-Push (74) (push) Successful in 6m4s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 4m8s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 4m28s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 4m4s
Cloud Apache Container / Build-FPM-Images (74) (push) Successful in 3m39s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 4m10s
Cloud Apache Container / Build-FPM-Images (80) (push) Successful in 4m11s
Cloud Apache Container / Build-FPM-Images (81) (push) Successful in 4m45s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 4m10s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 4m34s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 4m10s
Cloud Apache Container / Build-LiteSpeed-Images (81) (push) Successful in 4m9s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 1m31s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 5m4s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 4m59s
Cloud Apache Container / Build-LSPHP-Images (82) (push) Successful in 2m7s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 4m14s
Cloud Apache Container / Build-LSPHP-Images (81) (push) Failing after 3m52s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 4m51s
Cloud Apache Container / Build-LSPHP-Images (84) (push) Successful in 2m5s
Cloud Apache Container / Build-LSPHP-Images (85) (push) Successful in 2m1s
Cloud Apache Container / Build-Shared-OLS (push) Successful in 52s
Cloud Apache Container / Build-LSPHP-Images (83) (push) Successful in 5m47s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 3m59s
2026-10-21 23:48:21 +00:00
shadowdaoandClaude Opus 5.5 472fdcbc4d fix(pkg-cache): no | while read pipelines under pipefail
Shell-Checks' structural scan (scripts/tests/lsphp-info-probe.test.sh)
flagged two `cmd | while read` loops in pkg-cache-repos.sh restore.
Read the lists with mapfile from a process substitution instead, so
there is no pipeline. The test now passes locally (36/0), shellcheck is
clean, and the restore tests (new cache-referencing file removed,
leftover reference -> FATAL) behave as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 16:48:17 -07:00
jknapp cb0cecb557 Merge pull request 'feat(build): opt-in PKG_CACHE build arg for the internal package cache (HTTPS, GPG-verified)' (#31) from feat/pkg-cache-build-arg into trunk
Cloud Apache Container / Shell-Checks (push) Failing after 9s
Cloud Apache Container / Build-and-Push (74) (push) Successful in 3m47s
Cloud Apache Container / Build-FPM-Images (74) (push) Failing after 1m35s
Cloud Apache Container / Build-and-Push (80) (push) Successful in 5m21s
Cloud Apache Container / Build-and-Push (85) (push) Successful in 4m24s
Cloud Apache Container / Build-and-Push (83) (push) Successful in 5m37s
Cloud Apache Container / Build-and-Push (81) (push) Successful in 6m15s
Cloud Apache Container / Build-and-Push (82) (push) Successful in 6m0s
Cloud Apache Container / Build-and-Push (84) (push) Successful in 5m40s
Cloud Apache Container / Build-FPM-Images (80) (push) Successful in 3m35s
Cloud Apache Container / Build-LiteSpeed-Images (82) (push) Successful in 1m33s
Cloud Apache Container / Build-FPM-Images (82) (push) Successful in 5m1s
Cloud Apache Container / Build-FPM-Images (81) (push) Successful in 5m19s
Cloud Apache Container / Build-LiteSpeed-Images (83) (push) Successful in 1m27s
Cloud Apache Container / Build-FPM-Images (83) (push) Successful in 4m12s
Cloud Apache Container / Build-LiteSpeed-Images (81) (push) Successful in 4m37s
Cloud Apache Container / Build-LiteSpeed-Images (84) (push) Successful in 1m39s
Cloud Apache Container / Build-FPM-Images (84) (push) Successful in 5m13s
Cloud Apache Container / Build-FPM-Images (85) (push) Successful in 4m57s
Cloud Apache Container / Build-LSPHP-Images (82) (push) Successful in 2m20s
Cloud Apache Container / Build-LSPHP-Images (81) (push) Failing after 3m30s
Cloud Apache Container / Build-Shared-OLS (push) Successful in 51s
Cloud Apache Container / Build-LiteSpeed-Images (85) (push) Successful in 4m20s
Cloud Apache Container / Build-LSPHP-Images (85) (push) Successful in 4m55s
Cloud Apache Container / Build-LSPHP-Images (83) (push) Successful in 5m39s
Cloud Apache Container / Build-LSPHP-Images (84) (push) Successful in 5m36s
Cloud Apache Container / Build-Shared-httpd (push) Successful in 4m45s
2026-10-21 23:46:39 +00:00
41 changed files with 3378 additions and 108 deletions

No files matched your search

+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
## plan-legs.sh - decide which image legs of build-push.yaml run.
##
## Env:
## ONLY workflow_dispatch input "only". Empty/blank (and every push
## event) = build everything, exactly as before.
## GITHUB_OUTPUT file the outputs are appended to (set by the runner).
##
## ONLY is a comma list of tokens (spaces ignored):
## cac:php86 cac-fpm:php84 cac-litespeed:php83 cac-lsphp:php82 one leg
## cac | cac-fpm | cac-litespeed | cac-lsphp every PHP version of that image
## (php86 exists for cac and cac-fpm only; lsphp86 does not exist yet)
## shared-httpd | shared-ols that image
## Any other token is an error (exit 2, nothing is written): a typo must fail
## the plan job loudly, never silently build nothing.
##
## Outputs (matrix families = JSON array of phpver, [] = skip the job;
## single-leg images = true|false):
## cac cac_fpm cac_litespeed cac_lsphp shared_httpd shared_ols
set -euo pipefail
MATRIX_FAMILIES=(cac cac-fpm cac-litespeed cac-lsphp)
SINGLE_FAMILIES=(shared-httpd shared-ols)
# PHP versions per family. cac/cac-fpm (AlmaLinux + Remi) also ship 8.6; the
# LiteSpeed families have no lsphp86 package yet, so they stay on 82..85 (a
# shared list would make every trunk push build, and fail, litespeed/lsphp php86).
declare -A FAM_PHPVER=(
[cac]="82 83 84 85 86"
[cac-fpm]="82 83 84 85 86"
[cac-litespeed]="82 83 84 85"
[cac-lsphp]="82 83 84 85"
)
die() { echo "plan-legs: $*" >&2; exit 2; }
only=${ONLY-}
only=${only//[[:space:]]/}
declare -A want_ver want_single
want_all=false
if [ -z "$only" ]; then
want_all=true
else
n=0
IFS=',' read -r -a toks <<< "$only"
for t in "${toks[@]}"; do
[ -n "$t" ] || continue
n=$((n + 1))
fam=${t%%:*}
ver=""
if [ "$fam" != "$t" ]; then
ver=${t#*:}
[ -n "$ver" ] || die "empty PHP version in '$t'"
fi
if [[ " ${MATRIX_FAMILIES[*]} " == *" $fam "* ]]; then
if [ -z "$ver" ]; then
for v in ${FAM_PHPVER[$fam]}; do want_ver["$fam:$v"]=1; done
elif [[ "$ver" =~ ^php(8[2-6])$ ]] && [[ " ${FAM_PHPVER[$fam]} " == *" ${BASH_REMATCH[1]} "* ]]; then
want_ver["$fam:${BASH_REMATCH[1]}"]=1
else
die "unknown PHP version in '$t' (${fam} has: ${FAM_PHPVER[$fam]// /, })"
fi
elif [[ " ${SINGLE_FAMILIES[*]} " == *" $fam "* ]]; then
[ "$fam" = "$t" ] || die "'$t': $fam has a single leg, use plain '$fam'"
want_single["$fam"]=1
else
die "unknown image '$t' (known: ${MATRIX_FAMILIES[*]} ${SINGLE_FAMILIES[*]})"
fi
done
[ "$n" -gt 0 ] || die "'only' has no usable entries: '$only'"
fi
matrix_json() { # family
local fam=$1 v out=""
for v in ${FAM_PHPVER[$fam]}; do
if $want_all || [ -n "${want_ver["$fam:$v"]-}" ]; then out+="${out:+,}$v"; fi
done
printf '[%s]' "$out"
}
single_json() { # family
if $want_all || [ -n "${want_single["$1"]-}" ]; then echo true; else echo false; fi
}
out=${GITHUB_OUTPUT:-/dev/stdout}
{
echo "cac=$(matrix_json cac)"
echo "cac_fpm=$(matrix_json cac-fpm)"
echo "cac_litespeed=$(matrix_json cac-litespeed)"
echo "cac_lsphp=$(matrix_json cac-lsphp)"
echo "shared_httpd=$(single_json shared-httpd)"
echo "shared_ols=$(single_json shared-ols)"
} >> "$out"
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
## resolve-base-image.sh IMAGE:TAG — CI only (not copied into images).
## Prints IMAGE@sha256:<digest> for a Docker Hub tag, looked up DIRECTLY at
## registry-1.docker.io over HTTPS (never via the pkg-cache mirror), so the
## build can say `FROM IMAGE@sha256:...` and the mirror can only serve
## content-addressed blobs that BuildKit verifies. Exits non-zero (prints
## nothing on stdout) if the lookup fails; the workflow then skips the mirror
## and pulls the tag directly from Docker Hub. HEAD requests do not count
## against Docker Hub pull rate limits.
## Canonical copy: cloud-apache-container/.gitea/scripts/resolve-base-image.sh
## (docs/pkg-cache.md there); other repos carry identical copies.
set -euo pipefail
ref="${1:?usage: resolve-base-image.sh IMAGE:TAG}"
name_re='^[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+([._-][a-z0-9]+)*)?$'
tag_re='^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$'
name="${ref%:*}"; tag="${ref##*:}"
[ "$name" != "$ref" ] || { echo "resolve-base-image: '$ref' has no :tag" >&2; exit 2; }
[[ "$name" =~ $name_re ]] || { echo "resolve-base-image: bad image name '$name'" >&2; exit 2; }
[[ "$tag" =~ $tag_re ]] || { echo "resolve-base-image: bad tag '$tag'" >&2; exit 2; }
repo="$name"; [[ "$repo" == */* ]] || repo="library/$repo" # official images
curl_opts=(-fsS --proto '=https' --retry 3 --retry-all-errors --max-time 20)
token=$(curl "${curl_opts[@]}" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull" |
python3 -c 'import json,sys; print(json.load(sys.stdin)["token"])')
[ -n "$token" ] || { echo "resolve-base-image: no Docker Hub token for $repo" >&2; exit 1; }
hdrs=$(curl "${curl_opts[@]}" -I \
-H "Authorization: Bearer ${token}" \
-H 'Accept: application/vnd.oci.image.index.v1+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.list.v2+json' \
-H 'Accept: application/vnd.oci.image.manifest.v1+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.v2+json' \
"https://registry-1.docker.io/v2/${repo}/manifests/${tag}")
digest=$(printf '%s\n' "$hdrs" | tr -d '\r' | awk 'tolower($1)=="docker-content-digest:" {print $2}' | tail -n1)
[[ "$digest" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "resolve-base-image: no valid digest for $ref (got '${digest}')" >&2; exit 1; }
printf '%s@%s\n' "$name" "$digest"
+228
View File
@@ -0,0 +1,228 @@
name: Attach arm64 to an existing tag
run-name: attach arm64 to ${{ github.event.inputs.image }}:php${{ github.event.inputs.phpver }}
# Manual only (never on push): publishes an arm64 image for an EXISTING tag of cac or cac-fpm
# and merges it with the tag's CURRENT amd64 manifest into a new index. The amd64 image is
# NOT rebuilt and NOT touched: its manifest digest (and config, layers, attestation) stay
# byte-identical (with force=true the old arm64 is replaced and the amd64 attestation entry is not carried); only the tag's index digest changes. Use it to restore an arm64 entry that a
# later amd64-only publish dropped (the arm64 leg of build-push.yaml is best effort).
#
# One leg per run (image + phpver), and runs are serialised (concurrency group below), because
# QEMU legs that ran together are what failed on their network steps in the first place.
# Refuses when the tag already has an arm64 entry unless force=true. Tags are never created:
# the tag must exist and already have an amd64 entry. Tag names are not inputs: php<phpver>.
on:
workflow_dispatch:
inputs:
image:
description: 'cac or cac-fpm'
required: true
type: string
phpver:
description: 'PHP version without dots: 82, 83, 84, 85 or 86 (tag = php<phpver>)'
required: true
type: string
force:
description: 'true = replace an arm64 entry the tag already has (default: refuse)'
required: false
default: 'false'
type: string
concurrency:
group: arm64-attach
cancel-in-progress: false
jobs:
Attach-arm64:
# Only from trunk: the arm64 is built from the dispatched ref's Dockerfile.
if: github.ref == 'refs/heads/trunk'
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@v4
# Inputs reach the shell via env only, and are regex-checked before use.
- name: Validate inputs
id: v
env:
IN_IMAGE: ${{ github.event.inputs.image }}
IN_PHPVER: ${{ github.event.inputs.phpver }}
IN_FORCE: ${{ github.event.inputs.force }}
run: |
set -euo pipefail
case "$IN_IMAGE" in
cac) dockerfile=Dockerfile; bins="/usr/sbin/httpd /usr/bin/php" ;;
cac-fpm) dockerfile=Dockerfile.fpm; bins="/usr/sbin/php-fpm /usr/bin/php" ;;
*) echo "::error::image must be cac or cac-fpm"; exit 1 ;;
esac
[[ "$IN_PHPVER" =~ ^8[2-6]$ ]] || { echo "::error::phpver must be one of 82 83 84 85 86"; exit 1; }
case "${IN_FORCE:-false}" in true|false) ;; *) echo "::error::force must be true or false"; exit 1 ;; esac
{
echo "repo=repo.anhonesthost.net/cloud-hosting-platform/${IN_IMAGE}"
echo "tag=php${IN_PHPVER}"
echo "image=${IN_IMAGE}"
echo "phpver=${IN_PHPVER}"
echo "dockerfile=${dockerfile}"
echo "bins=${bins}"
echo "force=${IN_FORCE:-false}"
} >> "$GITHUB_OUTPUT"
echo "attach arm64 to ${IN_IMAGE}:php${IN_PHPVER} (force=${IN_FORCE:-false})"
- name: Login to Gitea
uses: docker/login-action@v3
with:
registry: repo.anhonesthost.net
username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }}
- name: Resolve base image digest (Docker Hub, direct)
id: base
env:
BASE_TAG: almalinux/10-base:latest
run: |
set -uo pipefail
if ref=$(.gitea/scripts/resolve-base-image.sh "$BASE_TAG") && [[ "$ref" =~ ^[a-z0-9][a-z0-9._/-]*@sha256:[0-9a-f]{64}$ ]]; then
echo "base-image: ${BASE_TAG} -> ${ref}"
echo "image=${ref}" >> "$GITHUB_OUTPUT"
echo "pinned=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::base image ${BASE_TAG}: Docker Hub digest lookup failed - pulling the tag directly"
echo "image=${BASE_TAG}" >> "$GITHUB_OUTPUT"
echo "pinned=false" >> "$GITHUB_OUTPUT"
fi
- name: Probe package cache
id: pkgcache
env:
BASE_PINNED: ${{ steps.base.outputs.pinned }}
run: |
url=""; mirror=""
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi
if [ "$BASE_PINNED" = true ] && curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi
echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<not used>}"
echo "url=${url}" >> "$GITHUB_OUTPUT"
echo "mirror=${mirror}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx (Docker Hub via pkg-cache mirror)
if: steps.pkgcache.outputs.mirror != ''
uses: docker/setup-buildx-action@v3
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["192.168.1.40:5000"]
[registry."192.168.1.40:5000"]
ca = ["${{ github.workspace }}/keys/pkg-cache/ca.crt"]
- name: Set up Docker Buildx
if: steps.pkgcache.outputs.mirror == ''
uses: docker/setup-buildx-action@v3
# (needs the buildx plugin, hence after the Buildx setup) Cheap pre-check BEFORE the long build: tag exists, has exactly one amd64 entry,
# and has no arm64 entry yet (exit 3 otherwise). Writes nothing. The index digest read here
# is handed to the final step, which refuses if the tag moved in between.
- name: Plan (read the tag, no writes)
id: plan
env:
REPO: ${{ steps.v.outputs.repo }}
TAG: ${{ steps.v.outputs.tag }}
FORCE: ${{ steps.v.outputs.force }}
run: |
set -euo pipefail
docker buildx version
rc=0; out=$(docker buildx imagetools inspect "$REPO:$TAG" --format '{{.Manifest.Digest}}' 2>&1) || rc=$?
echo "diag: inspect rc=$rc out=$(printf '%s' "$out" | head -c 400)"
f=(); [ "$FORCE" = true ] && f=(--force)
scripts/attach-arm64-index.sh --repo "$REPO" --tag "$TAG" --plan-only "${f[@]}"
- name: Cache-bust value
id: bust
env:
RUN_ID: ${{ gitea.run_id }}
run: echo "value=$(date -u +%Y%m%dT%H%M%SZ)-${RUN_ID}" >> "$GITHUB_OUTPUT"
# Same php.net floor as the normal build: the Dockerfile fails on anything older.
- name: Resolve current PHP release from php.net
id: phpmin
env:
PHPVER: ${{ steps.v.outputs.tag }}
run: |
set -euo pipefail
v="${PHPVER#php}"; branch="${v:0:1}.${v:1}"
json=$(curl -fsS --retry 5 --max-time 60 "https://www.php.net/releases/index.php?json&max=1&version=${branch}")
min=$(printf '%s' "$json" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(next(iter(d)) if isinstance(d,dict) and d else "")')
[[ "$min" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::no usable php.net release for ${branch}"; exit 1; }
echo "php.net current ${branch}: ${min}"
echo "min=${min}" >> "$GITHUB_OUTPUT"
# arm64 only, pushed UNTAGGED by digest. Required here (this run exists only for it): a
# failure fails the run and the tag is not touched.
- name: Build arm64 (push by digest)
id: arm64
timeout-minutes: 60
uses: docker/build-push-action@v6
with:
file: ./${{ steps.v.outputs.dockerfile }}
platforms: linux/arm64
build-args: |
PHPVER=${{ steps.v.outputs.phpver }}
CACHE_BUST=${{ steps.bust.outputs.value }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/${{ steps.v.outputs.image }},push-by-digest=true,name-canonical=true,push=true
# The arm64 entry must contain AArch64 binaries and the existing amd64 entry x86-64 ones:
# the manifest platform label alone does not prove it (scripts/verify-image-arch.py).
- name: Verify ELF architecture of both platforms
env:
REPO: ${{ steps.v.outputs.repo }}
TAG: ${{ steps.v.outputs.tag }}
BINS: ${{ steps.v.outputs.bins }}
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
AMD64: ${{ steps.plan.outputs.amd64 }}
run: |
set -euo pipefail
[[ "$AMD64" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::no planned amd64 digest"; exit 1; }
[[ "$ARM64_DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::no arm64 digest from the build"; exit 1; }
bins=(); for b in $BINS; do bins+=(--bin "$b"); done
python3 -I scripts/verify-image-arch.py --image "$REPO@$ARM64_DIGEST" --platform linux/arm64 "${bins[@]}"
python3 -I scripts/verify-image-arch.py --image "$REPO@$AMD64" --platform linux/amd64 "${bins[@]}"
# The new arm64 was built now, the amd64 entry earlier: refuse a PHP version skew between them.
- name: PHP version parity (amd64 native, arm64 under QEMU)
env:
REPO: ${{ steps.v.outputs.repo }}
TAG: ${{ steps.v.outputs.tag }}
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
AMD64: ${{ steps.plan.outputs.amd64 }}
run: |
set -euo pipefail
want=$(docker run --rm --platform linux/amd64 --entrypoint php "$REPO@$AMD64" -r 'echo PHP_VERSION;')
got=$(docker run --rm --platform linux/arm64 --entrypoint php "$REPO@$ARM64_DIGEST" -r 'echo PHP_VERSION;')
echo "amd64 (existing tag) PHP ${want}; new arm64 PHP ${got}"
[[ "$want" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || { echo "::error::cannot read the amd64 PHP version"; exit 1; }
[ "$want" = "$got" ] || { echo "::error::PHP version differs between the existing amd64 (${want}) and the new arm64 (${got}); not attaching. The amd64 image needs a rebuild first."; exit 1; }
# Re-creates the tag index: existing amd64 entries by digest + the new arm64. Aborts if the
# tag moved since the plan; verifies the amd64 manifest digest is unchanged afterwards.
- name: Attach (create the new index)
env:
REPO: ${{ steps.v.outputs.repo }}
TAG: ${{ steps.v.outputs.tag }}
FORCE: ${{ steps.v.outputs.force }}
BEFORE: ${{ steps.plan.outputs.before_index }}
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
run: |
set -euo pipefail
[[ "$BEFORE" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::no plan digest"; exit 1; }
f=(); [ "$FORCE" = true ] && f=(--force)
# :latest tracks php85 in the normal build; keep that alias equal if (and only if) it is one.
[ "$TAG" = php85 ] && f+=(--follow-tag latest)
scripts/attach-arm64-index.sh --repo "$REPO" --tag "$TAG" \
--arm64 "$ARM64_DIGEST" --expect-index "$BEFORE" "${f[@]}"
docker buildx imagetools inspect "$REPO:$TAG"
+569 -58
View File
@@ -1,10 +1,27 @@
name: Cloud Apache Container name: Cloud Apache Container
run-name: ${{ gitea.actor }} pushed a change to trunk run-name: ${{ gitea.actor }} pushed a change to trunk
# Manual run. `only` (optional) rebuilds just the named legs instead of every
# image: Gitea cannot re-run a single job and a full run takes ~1h.
# Syntax: comma list of cac:php86, cac-fpm:php84, cac-litespeed:php83,
# cac-lsphp:php82, shared-httpd, shared-ols; a bare family name (cac) = all its
# PHP versions. Empty = everything (same as a push). Unknown values fail the
# plan job. See .gitea/scripts/plan-legs.sh.
on: on:
push: push:
branches: branches:
- trunk - trunk
workflow_dispatch: workflow_dispatch:
inputs:
only:
description: 'Only build these legs (comma list, e.g. cac:php85 or cac-fpm:php84,shared-httpd). Empty = build everything.'
required: false
default: ''
type: string
allow_amd64_only:
description: 'true = let a build whose arm64 leg failed replace a tag that already has arm64 with an amd64-only one (default: fail instead; restore arm64 afterwards with the arm64-attach workflow).'
required: false
default: 'false'
type: string
jobs: jobs:
# Shell gate. Runs FIRST and costs seconds; the images below do not depend on # Shell gate. Runs FIRST and costs seconds; the images below do not depend on
@@ -52,12 +69,57 @@ jobs:
scripts/create-vhost-litespeed.sh \ scripts/create-vhost-litespeed.sh \
scripts/install-lscache-wp.sh \ scripts/install-lscache-wp.sh \
scripts/lsphp-apt-upgrade.sh \ scripts/lsphp-apt-upgrade.sh \
scripts/lsphp-pin-resolve.sh \
scripts/tests/lsphp-pin-resolve.test.sh \
scripts/lsphp-src-build.sh \ scripts/lsphp-src-build.sh \
scripts/lsphp-src-overlay.sh \ scripts/lsphp-src-overlay.sh \
scripts/lsphp-abi-gate.sh \ scripts/lsphp-abi-gate.sh \
scripts/tune-mpm.sh \ scripts/tune-mpm.sh \
scripts/httpd-h2-md-gate.sh \
scripts/tests/lsphp-info-probe.test.sh \ scripts/tests/lsphp-info-probe.test.sh \
scripts/tests/lsphp-abi-gate.test.sh scripts/lsphp-repo-version.sh \
scripts/tests/lsphp-repo-version.test.sh \
scripts/image-label-amd64.sh \
scripts/php-emergency-guard.sh \
scripts/index-platforms.sh \
scripts/assemble-multiarch-index.sh \
scripts/attach-arm64-index.sh \
scripts/tests/assemble-guard.test.sh \
scripts/tests/attach-arm64-index.test.sh \
scripts/tests/verify-image-arch.test.sh \
scripts/tests/image-label-amd64.test.sh \
scripts/tests/index-platforms.test.sh \
scripts/tests/lsphp-abi-gate.test.sh \
scripts/tests/lsphp-src-upload-progress.test.sh \
.gitea/scripts/resolve-base-image.sh \
.gitea/scripts/plan-legs.sh
- name: lsphp pin-resolve fixture test
run: ./scripts/tests/lsphp-pin-resolve.test.sh
- name: lsphp repo-version lookup test
run: ./scripts/tests/lsphp-repo-version.test.sh
- name: multi-arch guard tests (index-safe label read, fail-closed, assemble rules)
run: |
./scripts/tests/image-label-amd64.test.sh
./scripts/tests/index-platforms.test.sh
# arm64-attach.yaml: attach an arm64 entry to an existing tag without touching the amd64
# manifest; and the ELF machine-type check (an image labelled arm64 must hold AArch64 binaries).
- name: arm64 attach + ELF architecture tests
run: |
./scripts/tests/attach-arm64-index.test.sh
./scripts/tests/verify-image-arch.test.sh
./scripts/tests/assemble-guard.test.sh
# Static wiring of the multi-arch publish jobs (cac, cac-fpm, shared-httpd):
# by-digest pushes, non-fatal arm64 leg, timeouts, exact tag scheme.
- name: multi-arch workflow wiring test
run: python3 -I scripts/tests/multiarch-workflow.test.py
- name: lsphp-src session defaults patch test
run: ./scripts/tests/lsphp-src-upload-progress.test.sh
- name: lsphp probe regression test - name: lsphp probe regression test
run: ./scripts/tests/lsphp-info-probe.test.sh run: ./scripts/tests/lsphp-info-probe.test.sh
@@ -73,18 +135,72 @@ jobs:
fi fi
./scripts/tests/lsphp-abi-gate.test.sh ./scripts/tests/lsphp-abi-gate.test.sh
Build-and-Push: # Decides which image legs run. A job-level `if:` cannot see the `matrix`
# context, so instead of skipping matrix cells this job emits one filtered
# matrix per image family (and a true/false per single-leg image); each image
# job below takes its matrix from here and is skipped when its list is empty.
# Push events and an empty `only` input plan the full set, as before.
plan:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
cac: ${{ steps.plan.outputs.cac }}
cac_fpm: ${{ steps.plan.outputs.cac_fpm }}
cac_litespeed: ${{ steps.plan.outputs.cac_litespeed }}
cac_lsphp: ${{ steps.plan.outputs.cac_lsphp }}
shared_httpd: ${{ steps.plan.outputs.shared_httpd }}
shared_ols: ${{ steps.plan.outputs.shared_ols }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Plan legs
id: plan
env:
ONLY: ${{ github.event.inputs.only }}
run: .gitea/scripts/plan-legs.sh
Build-and-Push:
needs: plan
if: needs.plan.outputs.cac != '[]'
runs-on: ubuntu-latest
timeout-minutes: 130
strategy: strategy:
# One PHP version failing (e.g. an EOL stream) must not cancel the # One PHP version failing (e.g. an EOL stream) must not cancel the
# security builds of the others. # security builds of the others.
fail-fast: false fail-fast: false
# 2026-11-19: 4+4 QEMU arm64 legs ran at once and 6 of 8 failed on network steps
# (Remi / pkg-cache timeouts, truncated repomd.xml.asc); legs run alone succeeded.
# Caps concurrent legs of this family (max-parallel 1 = safest, slowest; whether
# the runner honours it is unverified: Gitea expands the matrix server-side). It is a
# per-job cap only: concurrency ACROSS jobs (cac + cac-fpm + shared-httpd) is not bounded.
max-parallel: 2
matrix: matrix:
phpver: [74, 80, 81, 82, 83, 84, 85] phpver: ${{ fromJSON(needs.plan.outputs.cac) }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# Base image pinned by DIGEST, looked up directly at Docker Hub (never via
# the pkg-cache mirror), so the mirror can only serve content-addressed
# blobs that BuildKit verifies. If the lookup fails this job does NOT use
# the mirror and pulls the tag straight from Docker Hub. docs/pkg-cache.md.
- name: Resolve base image digest (Docker Hub, direct)
id: base
env:
BASE_TAG: almalinux/10-base:latest
run: |
set -uo pipefail
if ref=$(.gitea/scripts/resolve-base-image.sh "$BASE_TAG") && [[ "$ref" =~ ^[a-z0-9][a-z0-9._/-]*@sha256:[0-9a-f]{64}$ ]]; then
echo "base-image: ${BASE_TAG} -> ${ref} (digest from registry-1.docker.io)"
echo "image=${ref}" >> "$GITHUB_OUTPUT"
echo "pinned=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::base image ${BASE_TAG}: Docker Hub digest lookup failed - pulling the tag directly from Docker Hub, pkg-cache registry mirror NOT used"
echo "image=${BASE_TAG}" >> "$GITHUB_OUTPUT"
echo "pinned=false" >> "$GITHUB_OUTPUT"
fi
# Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if # Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if
# it answers over TLS with our pinned CA; otherwise (down, unreachable, # it answers over TLS with our pinned CA; otherwise (down, unreachable,
# bad/expired cert) this job builds from the upstream repos and Docker Hub # bad/expired cert) this job builds from the upstream repos and Docker Hub
@@ -92,17 +208,22 @@ jobs:
# separately so either can fail back on its own. # separately so either can fail back on its own.
- name: Probe package cache - name: Probe package cache
id: pkgcache id: pkgcache
# The registry mirror is only used for a digest-pinned base image.
env:
BASE_PINNED: ${{ steps.base.outputs.pinned }}
run: | run: |
url=""; mirror="" url=""; mirror=""
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi if [ "$BASE_PINNED" = true ] && curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi
echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<unreachable: Docker Hub>}" echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<not used: Docker Hub direct>}"
[ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories" [ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories"
echo "url=${url}" >> "$GITHUB_OUTPUT" echo "url=${url}" >> "$GITHUB_OUTPUT"
echo "mirror=${mirror}" >> "$GITHUB_OUTPUT" echo "mirror=${mirror}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with:
platforms: arm64
# BuildKit (docker-container driver) ignores dockerd's registry-mirrors, # BuildKit (docker-container driver) ignores dockerd's registry-mirrors,
# so the mirror is configured on the builder; BuildKit itself still falls # so the mirror is configured on the builder; BuildKit itself still falls
@@ -157,32 +278,125 @@ jobs:
username: ${{ secrets.CI_USER }} username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }} password: ${{ secrets.CI_TOKEN }}
- name: Build and Push Image # amd64: required. Pushed untagged BY DIGEST (no tag); failure fails the
# job and publishes nothing, exactly as before multi-arch. The tags are only
# created by the assemble step below.
- name: Build amd64 (push by digest)
id: amd64
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
platforms: linux/amd64 platforms: linux/amd64
push: true
build-args: | build-args: |
PHPVER=${{ matrix.phpver }} PHPVER=${{ matrix.phpver }}
CACHE_BUST=${{ steps.bust.outputs.value }} CACHE_BUST=${{ steps.bust.outputs.value }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }} PKG_CACHE=${{ steps.pkgcache.outputs.url }}
EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }} EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}
tags: | outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/cac,push-by-digest=true,name-canonical=true,push=true
repo.anhonesthost.net/cloud-hosting-platform/cac:php${{ matrix.phpver }}
${{ matrix.phpver == '85' && 'repo.anhonesthost.net/cloud-hosting-platform/cac:latest' || '' }} # arm64: best effort, built under QEMU on this same trusted x86 runner (no
# secret ever leaves it). Same Dockerfile, same build-args (incl. the php.net
# EXPECT_PHP_MIN gate, which runs `php -r` on the arm64 binary). Must never
# block or alter the amd64 tag: on failure/timeout the tag is published
# amd64-only, as before multi-arch.
- name: Build arm64 (push by digest)
id: arm64
continue-on-error: true
timeout-minutes: 45
uses: docker/build-push-action@v6
with:
platforms: linux/arm64
build-args: |
PHPVER=${{ matrix.phpver }}
CACHE_BUST=${{ steps.bust.outputs.value }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/cac,push-by-digest=true,name-canonical=true,push=true
# ONE retry of a failed arm64 leg after a pause (network-step flakes). Same inputs.
- name: Wait before arm64 retry
if: steps.arm64.outcome == 'failure'
run: sleep 90
- name: Retry arm64 (push by digest)
id: arm64_retry
if: steps.arm64.outcome == 'failure'
continue-on-error: true
timeout-minutes: 45
uses: docker/build-push-action@v6
with:
platforms: linux/arm64
build-args: |
PHPVER=${{ matrix.phpver }}
CACHE_BUST=${{ steps.bust.outputs.value }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/cac,push-by-digest=true,name-canonical=true,push=true
# Creates the index tag(s) from THIS run's digests only (a previous run's
# arm64 is never re-attached). scripts/assemble-multiarch-index.sh.
- name: Assemble index tag(s)
env:
AMD64_DIGEST: ${{ steps.amd64.outputs.digest }}
ARM64_DIGEST: ${{ steps.arm64.outcome == 'success' && steps.arm64.outputs.digest || steps.arm64_retry.outputs.digest }}
ARM64_OUTCOME: ${{ (steps.arm64.outcome == 'success' || steps.arm64_retry.outcome == 'success') && 'success' || steps.arm64.outcome }}
ALLOW_AMD64_ONLY: ${{ github.event.inputs.allow_amd64_only }}
PHPVER: ${{ matrix.phpver }}
run: |
set -euo pipefail
tags=(--tag "php${PHPVER}")
# :latest tracks php85 (unchanged tag scheme; php86 is a new tag, NOT latest).
[ "$PHPVER" = 85 ] && tags+=(--tag latest)
scripts/assemble-multiarch-index.sh \
--amd64 "$AMD64_DIGEST" \
--arm64 "$ARM64_DIGEST" --arm64-outcome "$ARM64_OUTCOME" \
--guard-existing-arm64 --verify-bin /usr/sbin/httpd --verify-bin /usr/bin/php \
--repo repo.anhonesthost.net/cloud-hosting-platform/cac \
"${tags[@]}"
Build-FPM-Images: Build-FPM-Images:
needs: plan
if: needs.plan.outputs.cac_fpm != '[]'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 130
strategy: strategy:
# One PHP version failing (e.g. an EOL stream) must not cancel the # One PHP version failing (e.g. an EOL stream) must not cancel the
# security builds of the others. # security builds of the others.
fail-fast: false fail-fast: false
# 2026-11-19: 4+4 QEMU arm64 legs ran at once and 6 of 8 failed on network steps
# (Remi / pkg-cache timeouts, truncated repomd.xml.asc); legs run alone succeeded.
# Caps concurrent legs of this family (max-parallel 1 = safest, slowest; whether
# the runner honours it is unverified: Gitea expands the matrix server-side). It is a
# per-job cap only: concurrency ACROSS jobs (cac + cac-fpm + shared-httpd) is not bounded.
max-parallel: 2
matrix: matrix:
phpver: [74, 80, 81, 82, 83, 84, 85] phpver: ${{ fromJSON(needs.plan.outputs.cac_fpm) }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# Base image pinned by DIGEST, looked up directly at Docker Hub (never via
# the pkg-cache mirror), so the mirror can only serve content-addressed
# blobs that BuildKit verifies. If the lookup fails this job does NOT use
# the mirror and pulls the tag straight from Docker Hub. docs/pkg-cache.md.
- name: Resolve base image digest (Docker Hub, direct)
id: base
env:
BASE_TAG: almalinux/10-base:latest
run: |
set -uo pipefail
if ref=$(.gitea/scripts/resolve-base-image.sh "$BASE_TAG") && [[ "$ref" =~ ^[a-z0-9][a-z0-9._/-]*@sha256:[0-9a-f]{64}$ ]]; then
echo "base-image: ${BASE_TAG} -> ${ref} (digest from registry-1.docker.io)"
echo "image=${ref}" >> "$GITHUB_OUTPUT"
echo "pinned=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::base image ${BASE_TAG}: Docker Hub digest lookup failed - pulling the tag directly from Docker Hub, pkg-cache registry mirror NOT used"
echo "image=${BASE_TAG}" >> "$GITHUB_OUTPUT"
echo "pinned=false" >> "$GITHUB_OUTPUT"
fi
# Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if # Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if
# it answers over TLS with our pinned CA; otherwise (down, unreachable, # it answers over TLS with our pinned CA; otherwise (down, unreachable,
# bad/expired cert) this job builds from the upstream repos and Docker Hub # bad/expired cert) this job builds from the upstream repos and Docker Hub
@@ -190,17 +404,22 @@ jobs:
# separately so either can fail back on its own. # separately so either can fail back on its own.
- name: Probe package cache - name: Probe package cache
id: pkgcache id: pkgcache
# The registry mirror is only used for a digest-pinned base image.
env:
BASE_PINNED: ${{ steps.base.outputs.pinned }}
run: | run: |
url=""; mirror="" url=""; mirror=""
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi if [ "$BASE_PINNED" = true ] && curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi
echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<unreachable: Docker Hub>}" echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<not used: Docker Hub direct>}"
[ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories" [ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories"
echo "url=${url}" >> "$GITHUB_OUTPUT" echo "url=${url}" >> "$GITHUB_OUTPUT"
echo "mirror=${mirror}" >> "$GITHUB_OUTPUT" echo "mirror=${mirror}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with:
platforms: arm64
# BuildKit (docker-container driver) ignores dockerd's registry-mirrors, # BuildKit (docker-container driver) ignores dockerd's registry-mirrors,
# so the mirror is configured on the builder; BuildKit itself still falls # so the mirror is configured on the builder; BuildKit itself still falls
@@ -255,23 +474,95 @@ jobs:
username: ${{ secrets.CI_USER }} username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }} password: ${{ secrets.CI_TOKEN }}
- name: Build and Push FPM Image # amd64: required. Pushed untagged BY DIGEST (no tag); failure fails the
# job and publishes nothing, exactly as before multi-arch. The tags are only
# created by the assemble step below.
- name: Build amd64 (push by digest)
id: amd64
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
file: ./Dockerfile.fpm file: ./Dockerfile.fpm
platforms: linux/amd64 platforms: linux/amd64
push: true
build-args: | build-args: |
PHPVER=${{ matrix.phpver }} PHPVER=${{ matrix.phpver }}
CACHE_BUST=${{ steps.bust.outputs.value }} CACHE_BUST=${{ steps.bust.outputs.value }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }} PKG_CACHE=${{ steps.pkgcache.outputs.url }}
EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }} EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}
tags: | outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/cac-fpm,push-by-digest=true,name-canonical=true,push=true
repo.anhonesthost.net/cloud-hosting-platform/cac-fpm:php${{ matrix.phpver }}
${{ matrix.phpver == '85' && 'repo.anhonesthost.net/cloud-hosting-platform/cac-fpm:latest' || '' }} # arm64: best effort, built under QEMU on this same trusted x86 runner (no
# secret ever leaves it). Same Dockerfile, same build-args (incl. the php.net
# EXPECT_PHP_MIN gate, which runs `php -r` on the arm64 binary). Must never
# block or alter the amd64 tag: on failure/timeout the tag is published
# amd64-only, as before multi-arch.
- name: Build arm64 (push by digest)
id: arm64
continue-on-error: true
timeout-minutes: 45
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.fpm
platforms: linux/arm64
build-args: |
PHPVER=${{ matrix.phpver }}
CACHE_BUST=${{ steps.bust.outputs.value }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/cac-fpm,push-by-digest=true,name-canonical=true,push=true
# ONE retry of a failed arm64 leg after a pause (network-step flakes). Same inputs.
- name: Wait before arm64 retry
if: steps.arm64.outcome == 'failure'
run: sleep 90
- name: Retry arm64 (push by digest)
id: arm64_retry
if: steps.arm64.outcome == 'failure'
continue-on-error: true
timeout-minutes: 45
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.fpm
platforms: linux/arm64
build-args: |
PHPVER=${{ matrix.phpver }}
CACHE_BUST=${{ steps.bust.outputs.value }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/cac-fpm,push-by-digest=true,name-canonical=true,push=true
# Creates the index tag(s) from THIS run's digests only (a previous run's
# arm64 is never re-attached). scripts/assemble-multiarch-index.sh.
- name: Assemble index tag(s)
env:
AMD64_DIGEST: ${{ steps.amd64.outputs.digest }}
ARM64_DIGEST: ${{ steps.arm64.outcome == 'success' && steps.arm64.outputs.digest || steps.arm64_retry.outputs.digest }}
ARM64_OUTCOME: ${{ (steps.arm64.outcome == 'success' || steps.arm64_retry.outcome == 'success') && 'success' || steps.arm64.outcome }}
ALLOW_AMD64_ONLY: ${{ github.event.inputs.allow_amd64_only }}
PHPVER: ${{ matrix.phpver }}
run: |
set -euo pipefail
tags=(--tag "php${PHPVER}")
# :latest tracks php85 (unchanged tag scheme; php86 is a new tag, NOT latest).
[ "$PHPVER" = 85 ] && tags+=(--tag latest)
scripts/assemble-multiarch-index.sh \
--amd64 "$AMD64_DIGEST" \
--arm64 "$ARM64_DIGEST" --arm64-outcome "$ARM64_OUTCOME" \
--guard-existing-arm64 --verify-bin /usr/sbin/php-fpm --verify-bin /usr/bin/php \
--repo repo.anhonesthost.net/cloud-hosting-platform/cac-fpm \
"${tags[@]}"
Build-LiteSpeed-Images: Build-LiteSpeed-Images:
needs: plan
if: needs.plan.outputs.cac_litespeed != '[]'
runs-on: ubuntu-latest runs-on: ubuntu-latest
# One place for the OLS base tag: digest lookup and build-args both read it.
# OLS_VERSION pinned to 1.8.4 (see the build step); Dockerfile default differs.
env:
OLS_VERSION: "1.8.4"
strategy: strategy:
# One PHP version failing (e.g. an EOL stream) must not cancel the # One PHP version failing (e.g. an EOL stream) must not cancel the
# security builds of the others. # security builds of the others.
@@ -281,15 +572,68 @@ jobs:
# images stop at older OLS releases for those PHP versions, and the # images stop at older OLS releases for those PHP versions, and the
# cac-litespeed tier is a paid premium offering: 8.1+ is the # cac-litespeed tier is a paid premium offering: 8.1+ is the
# modernization story we're selling. # modernization story we're selling.
phpver: [81, 82, 83, 84, 85] phpver: ${{ fromJSON(needs.plan.outputs.cac_litespeed) }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# Base image pinned by DIGEST, looked up directly at Docker Hub (never via
# the pkg-cache mirror), so the mirror can only serve content-addressed
# blobs that BuildKit verifies. If the lookup fails this job does NOT use
# the mirror and pulls the tag straight from Docker Hub. docs/pkg-cache.md.
- name: Resolve base image digest (Docker Hub, direct)
id: base
env:
BASE_TAG: litespeedtech/openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ matrix.phpver }}
run: |
set -uo pipefail
if ref=$(.gitea/scripts/resolve-base-image.sh "$BASE_TAG") && [[ "$ref" =~ ^[a-z0-9][a-z0-9._/-]*@sha256:[0-9a-f]{64}$ ]]; then
echo "base-image: ${BASE_TAG} -> ${ref} (digest from registry-1.docker.io)"
echo "image=${ref}" >> "$GITHUB_OUTPUT"
echo "pinned=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::base image ${BASE_TAG}: Docker Hub digest lookup failed - pulling the tag directly from Docker Hub, pkg-cache registry mirror NOT used"
echo "image=${BASE_TAG}" >> "$GITHUB_OUTPUT"
echo "pinned=false" >> "$GITHUB_OUTPUT"
fi
# Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if
# it answers over TLS with our pinned CA; otherwise (down, unreachable,
# bad/expired cert) this job builds from the upstream repos and Docker Hub
# exactly as before. The repo cache and the registry mirror are probed
# separately so either can fail back on its own.
- name: Probe package cache
id: pkgcache
# The registry mirror is only used for a digest-pinned base image.
env:
BASE_PINNED: ${{ steps.base.outputs.pinned }}
run: |
url=""; mirror=""
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi
if [ "$BASE_PINNED" = true ] && curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi
echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<not used: Docker Hub direct>}"
[ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories"
echo "url=${url}" >> "$GITHUB_OUTPUT"
echo "mirror=${mirror}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
# BuildKit (docker-container driver) ignores dockerd's registry-mirrors,
# so the mirror is configured on the builder; BuildKit itself still falls
# back to Docker Hub if the mirror stops answering mid-run.
- name: Set up Docker Buildx (Docker Hub via pkg-cache mirror)
if: steps.pkgcache.outputs.mirror != ''
uses: docker/setup-buildx-action@v3
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["192.168.1.40:5000"]
[registry."192.168.1.40:5000"]
ca = ["${{ github.workspace }}/keys/pkg-cache/ca.crt"]
- name: Set up Docker Buildx - name: Set up Docker Buildx
if: steps.pkgcache.outputs.mirror == ''
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
# Per-run cache-bust value. Each job's buildx builder is created fresh by # Per-run cache-bust value. Each job's buildx builder is created fresh by
@@ -314,8 +658,7 @@ jobs:
PHPVER: ${{ matrix.phpver }} PHPVER: ${{ matrix.phpver }}
run: | run: |
set -euo pipefail set -euo pipefail
idx=$(curl -fsS --proto '=https' --retry 3 --max-time 60 https://rpms.litespeedtech.com/debian/dists/noble/main/binary-amd64/Packages) pkg=$(./scripts/lsphp-repo-version.sh "${PHPVER}" "${LSPHP_ARCH:-amd64}")
pkg=$(printf '%s\n' "$idx" | awk -v p="lsphp${PHPVER}" '/^Package: /{n=$2} /^Version: / && n==p {print $2}' | sort -V | tail -n1)
if [ -z "$pkg" ]; then echo "::error::lsphp${PHPVER} not found in the LiteSpeed repo index"; exit 1; fi if [ -z "$pkg" ]; then echo "::error::lsphp${PHPVER} not found in the LiteSpeed repo index"; exit 1; fi
php="${pkg%%-*}" php="${pkg%%-*}"
[[ "$pkg" =~ ^[0-9][0-9A-Za-z.+~:-]*$ ]] || { echo "::error::malformed lsphp${PHPVER} package version in the repo index"; exit 1; } [[ "$pkg" =~ ^[0-9][0-9A-Za-z.+~:-]*$ ]] || { echo "::error::malformed lsphp${PHPVER} package version in the repo index"; exit 1; }
@@ -335,7 +678,10 @@ jobs:
# :phpNN points at right now. While LiteSpeed still lags, a normal build # :phpNN points at right now. While LiteSpeed still lags, a normal build
# would silently put the VULNERABLE packaged lsphp back. Refuse instead; # would silently put the VULNERABLE packaged lsphp back. Refuse instead;
# the job goes green again by itself once the LiteSpeed repo catches up. # the job goes green again by itself once the LiteSpeed repo catches up.
# Fail-open if the tag cannot be inspected (first build, registry blip). # Reads the labels of the linux/amd64 image behind the tag (index-safe:
# works for single-platform and multi-arch tags) and FAILS CLOSED if they
# cannot be read; only a tag that does not exist yet (first build) passes
# unchecked. scripts/php-emergency-guard.sh, tests in scripts/tests/.
- name: Do not roll back a newer php.net emergency image - name: Do not roll back a newer php.net emergency image
env: env:
PHPVER: ${{ matrix.phpver }} PHPVER: ${{ matrix.phpver }}
@@ -343,14 +689,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
ref="repo.anhonesthost.net/cloud-hosting-platform/cac-litespeed:php${PHPVER}" ref="repo.anhonesthost.net/cloud-hosting-platform/cac-litespeed:php${PHPVER}"
src=$(docker buildx imagetools inspect "$ref" --format '{{ index .Image.Config.Labels "org.whp.lsphp-source" }}' 2>/dev/null || true) ./scripts/php-emergency-guard.sh "$ref" "$NEW_PHP"
cur=$(docker buildx imagetools inspect "$ref" --format '{{ index .Image.Config.Labels "org.whp.php-version" }}' 2>/dev/null || true)
new="$NEW_PHP"
echo "published $ref: source=${src:-?} php=${cur:-?}; this build: packaged $new"
if [ "$src" = "php.net" ] && [ "$cur" != "$new" ] && [ "$(printf '%s\n%s\n' "$cur" "$new" | sort -V | tail -n1)" = "$cur" ]; then
echo "::error::$ref is a php.net emergency build of PHP $cur; LiteSpeed still ships $new. Not overwriting it with an older PHP. Re-run lsphp-source-emergency.yaml for a newer fix, or wait for LiteSpeed."
exit 1
fi
- name: Build and Push LiteSpeed Image - name: Build and Push LiteSpeed Image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
@@ -360,21 +699,28 @@ jobs:
push: true push: true
build-args: | build-args: |
PHPVER=${{ matrix.phpver }} PHPVER=${{ matrix.phpver }}
OLS_VERSION=1.8.4 OLS_VERSION=${{ env.OLS_VERSION }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
CACHE_BUST=${{ steps.bust.outputs.value }} CACHE_BUST=${{ steps.bust.outputs.value }}
EXPECT_LSPHP_PKG=${{ steps.lsphp.outputs.pkg }} EXPECT_LSPHP_PKG=${{ steps.lsphp.outputs.pkg }}
EXPECT_PHP_VERSION=${{ steps.lsphp.outputs.php }} EXPECT_PHP_VERSION=${{ steps.lsphp.outputs.php }}
# OLS_VERSION pinned to 1.8.4 — only release with prebuilt images # OLS_VERSION pinned to 1.8.4. It was the only release with an lsphp81
# for every PHP version we ship (1.8.5 and 1.9.0 don't have an # variant; 8.1 and older are no longer built (2026-10-21), so the pin
# lsphp81 variant on Docker Hub). Bump alongside a local rebuild # can move to a newer OLS release after a local rebuild test.
# test when LiteSpeed publishes lsphp81 on a newer OLS release.
# See spec: docs/superpowers/specs/2026-06-01-cac-litespeed-design.md # See spec: docs/superpowers/specs/2026-06-01-cac-litespeed-design.md
tags: | tags: |
repo.anhonesthost.net/cloud-hosting-platform/cac-litespeed:php${{ matrix.phpver }} repo.anhonesthost.net/cloud-hosting-platform/cac-litespeed:php${{ matrix.phpver }}
${{ matrix.phpver == '85' && 'repo.anhonesthost.net/cloud-hosting-platform/cac-litespeed:latest' || '' }} ${{ matrix.phpver == '85' && 'repo.anhonesthost.net/cloud-hosting-platform/cac-litespeed:latest' || '' }}
Build-LSPHP-Images: Build-LSPHP-Images:
needs: plan
if: needs.plan.outputs.cac_lsphp != '[]'
runs-on: ubuntu-latest runs-on: ubuntu-latest
# One place for the OLS base tag: digest lookup and build-args both read it.
# OLS_VERSION pinned to 1.8.4 (see the build step); Dockerfile default differs.
env:
OLS_VERSION: "1.8.4"
strategy: strategy:
# One PHP version failing (e.g. an EOL stream) must not cancel the # One PHP version failing (e.g. an EOL stream) must not cancel the
# security builds of the others. # security builds of the others.
@@ -384,15 +730,68 @@ jobs:
# backend for the shared-ols tier and shares the litespeed prebuilt # backend for the shared-ols tier and shares the litespeed prebuilt
# base, which only ships lsphp for 8.1+. Keep this matrix in lockstep # base, which only ships lsphp for 8.1+. Keep this matrix in lockstep
# with Build-LiteSpeed-Images. # with Build-LiteSpeed-Images.
phpver: [81, 82, 83, 84, 85] phpver: ${{ fromJSON(needs.plan.outputs.cac_lsphp) }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# Base image pinned by DIGEST, looked up directly at Docker Hub (never via
# the pkg-cache mirror), so the mirror can only serve content-addressed
# blobs that BuildKit verifies. If the lookup fails this job does NOT use
# the mirror and pulls the tag straight from Docker Hub. docs/pkg-cache.md.
- name: Resolve base image digest (Docker Hub, direct)
id: base
env:
BASE_TAG: litespeedtech/openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ matrix.phpver }}
run: |
set -uo pipefail
if ref=$(.gitea/scripts/resolve-base-image.sh "$BASE_TAG") && [[ "$ref" =~ ^[a-z0-9][a-z0-9._/-]*@sha256:[0-9a-f]{64}$ ]]; then
echo "base-image: ${BASE_TAG} -> ${ref} (digest from registry-1.docker.io)"
echo "image=${ref}" >> "$GITHUB_OUTPUT"
echo "pinned=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::base image ${BASE_TAG}: Docker Hub digest lookup failed - pulling the tag directly from Docker Hub, pkg-cache registry mirror NOT used"
echo "image=${BASE_TAG}" >> "$GITHUB_OUTPUT"
echo "pinned=false" >> "$GITHUB_OUTPUT"
fi
# Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if
# it answers over TLS with our pinned CA; otherwise (down, unreachable,
# bad/expired cert) this job builds from the upstream repos and Docker Hub
# exactly as before. The repo cache and the registry mirror are probed
# separately so either can fail back on its own.
- name: Probe package cache
id: pkgcache
# The registry mirror is only used for a digest-pinned base image.
env:
BASE_PINNED: ${{ steps.base.outputs.pinned }}
run: |
url=""; mirror=""
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi
if [ "$BASE_PINNED" = true ] && curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi
echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<not used: Docker Hub direct>}"
[ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories"
echo "url=${url}" >> "$GITHUB_OUTPUT"
echo "mirror=${mirror}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
# BuildKit (docker-container driver) ignores dockerd's registry-mirrors,
# so the mirror is configured on the builder; BuildKit itself still falls
# back to Docker Hub if the mirror stops answering mid-run.
- name: Set up Docker Buildx (Docker Hub via pkg-cache mirror)
if: steps.pkgcache.outputs.mirror != ''
uses: docker/setup-buildx-action@v3
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["192.168.1.40:5000"]
[registry."192.168.1.40:5000"]
ca = ["${{ github.workspace }}/keys/pkg-cache/ca.crt"]
- name: Set up Docker Buildx - name: Set up Docker Buildx
if: steps.pkgcache.outputs.mirror == ''
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
# Per-run cache-bust value. Each job's buildx builder is created fresh by # Per-run cache-bust value. Each job's buildx builder is created fresh by
@@ -417,8 +816,7 @@ jobs:
PHPVER: ${{ matrix.phpver }} PHPVER: ${{ matrix.phpver }}
run: | run: |
set -euo pipefail set -euo pipefail
idx=$(curl -fsS --proto '=https' --retry 3 --max-time 60 https://rpms.litespeedtech.com/debian/dists/noble/main/binary-amd64/Packages) pkg=$(./scripts/lsphp-repo-version.sh "${PHPVER}" "${LSPHP_ARCH:-amd64}")
pkg=$(printf '%s\n' "$idx" | awk -v p="lsphp${PHPVER}" '/^Package: /{n=$2} /^Version: / && n==p {print $2}' | sort -V | tail -n1)
if [ -z "$pkg" ]; then echo "::error::lsphp${PHPVER} not found in the LiteSpeed repo index"; exit 1; fi if [ -z "$pkg" ]; then echo "::error::lsphp${PHPVER} not found in the LiteSpeed repo index"; exit 1; fi
php="${pkg%%-*}" php="${pkg%%-*}"
[[ "$pkg" =~ ^[0-9][0-9A-Za-z.+~:-]*$ ]] || { echo "::error::malformed lsphp${PHPVER} package version in the repo index"; exit 1; } [[ "$pkg" =~ ^[0-9][0-9A-Za-z.+~:-]*$ ]] || { echo "::error::malformed lsphp${PHPVER} package version in the repo index"; exit 1; }
@@ -438,7 +836,10 @@ jobs:
# :phpNN points at right now. While LiteSpeed still lags, a normal build # :phpNN points at right now. While LiteSpeed still lags, a normal build
# would silently put the VULNERABLE packaged lsphp back. Refuse instead; # would silently put the VULNERABLE packaged lsphp back. Refuse instead;
# the job goes green again by itself once the LiteSpeed repo catches up. # the job goes green again by itself once the LiteSpeed repo catches up.
# Fail-open if the tag cannot be inspected (first build, registry blip). # Reads the labels of the linux/amd64 image behind the tag (index-safe:
# works for single-platform and multi-arch tags) and FAILS CLOSED if they
# cannot be read; only a tag that does not exist yet (first build) passes
# unchecked. scripts/php-emergency-guard.sh, tests in scripts/tests/.
- name: Do not roll back a newer php.net emergency image - name: Do not roll back a newer php.net emergency image
env: env:
PHPVER: ${{ matrix.phpver }} PHPVER: ${{ matrix.phpver }}
@@ -446,14 +847,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
ref="repo.anhonesthost.net/cloud-hosting-platform/cac-lsphp:php${PHPVER}" ref="repo.anhonesthost.net/cloud-hosting-platform/cac-lsphp:php${PHPVER}"
src=$(docker buildx imagetools inspect "$ref" --format '{{ index .Image.Config.Labels "org.whp.lsphp-source" }}' 2>/dev/null || true) ./scripts/php-emergency-guard.sh "$ref" "$NEW_PHP"
cur=$(docker buildx imagetools inspect "$ref" --format '{{ index .Image.Config.Labels "org.whp.php-version" }}' 2>/dev/null || true)
new="$NEW_PHP"
echo "published $ref: source=${src:-?} php=${cur:-?}; this build: packaged $new"
if [ "$src" = "php.net" ] && [ "$cur" != "$new" ] && [ "$(printf '%s\n%s\n' "$cur" "$new" | sort -V | tail -n1)" = "$cur" ]; then
echo "::error::$ref is a php.net emergency build of PHP $cur; LiteSpeed still ships $new. Not overwriting it with an older PHP. Re-run lsphp-source-emergency.yaml for a newer fix, or wait for LiteSpeed."
exit 1
fi
- name: Build and Push lsphp Image - name: Build and Push lsphp Image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
@@ -463,7 +857,9 @@ jobs:
push: true push: true
build-args: | build-args: |
PHPVER=${{ matrix.phpver }} PHPVER=${{ matrix.phpver }}
OLS_VERSION=1.8.4 OLS_VERSION=${{ env.OLS_VERSION }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
CACHE_BUST=${{ steps.bust.outputs.value }} CACHE_BUST=${{ steps.bust.outputs.value }}
EXPECT_LSPHP_PKG=${{ steps.lsphp.outputs.pkg }} EXPECT_LSPHP_PKG=${{ steps.lsphp.outputs.pkg }}
EXPECT_PHP_VERSION=${{ steps.lsphp.outputs.php }} EXPECT_PHP_VERSION=${{ steps.lsphp.outputs.php }}
@@ -474,11 +870,34 @@ jobs:
${{ matrix.phpver == '85' && 'repo.anhonesthost.net/cloud-hosting-platform/cac-lsphp:latest' || '' }} ${{ matrix.phpver == '85' && 'repo.anhonesthost.net/cloud-hosting-platform/cac-lsphp:latest' || '' }}
Build-Shared-httpd: Build-Shared-httpd:
needs: plan
if: needs.plan.outputs.shared_httpd == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 80
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# Base image pinned by DIGEST, looked up directly at Docker Hub (never via
# the pkg-cache mirror), so the mirror can only serve content-addressed
# blobs that BuildKit verifies. If the lookup fails this job does NOT use
# the mirror and pulls the tag straight from Docker Hub. docs/pkg-cache.md.
- name: Resolve base image digest (Docker Hub, direct)
id: base
env:
BASE_TAG: almalinux/10-base:latest
run: |
set -uo pipefail
if ref=$(.gitea/scripts/resolve-base-image.sh "$BASE_TAG") && [[ "$ref" =~ ^[a-z0-9][a-z0-9._/-]*@sha256:[0-9a-f]{64}$ ]]; then
echo "base-image: ${BASE_TAG} -> ${ref} (digest from registry-1.docker.io)"
echo "image=${ref}" >> "$GITHUB_OUTPUT"
echo "pinned=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::base image ${BASE_TAG}: Docker Hub digest lookup failed - pulling the tag directly from Docker Hub, pkg-cache registry mirror NOT used"
echo "image=${BASE_TAG}" >> "$GITHUB_OUTPUT"
echo "pinned=false" >> "$GITHUB_OUTPUT"
fi
# Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if # Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if
# it answers over TLS with our pinned CA; otherwise (down, unreachable, # it answers over TLS with our pinned CA; otherwise (down, unreachable,
# bad/expired cert) this job builds from the upstream repos and Docker Hub # bad/expired cert) this job builds from the upstream repos and Docker Hub
@@ -486,17 +905,22 @@ jobs:
# separately so either can fail back on its own. # separately so either can fail back on its own.
- name: Probe package cache - name: Probe package cache
id: pkgcache id: pkgcache
# The registry mirror is only used for a digest-pinned base image.
env:
BASE_PINNED: ${{ steps.base.outputs.pinned }}
run: | run: |
url=""; mirror="" url=""; mirror=""
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi if [ "$BASE_PINNED" = true ] && curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi
echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<unreachable: Docker Hub>}" echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<not used: Docker Hub direct>}"
[ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories" [ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories"
echo "url=${url}" >> "$GITHUB_OUTPUT" echo "url=${url}" >> "$GITHUB_OUTPUT"
echo "mirror=${mirror}" >> "$GITHUB_OUTPUT" echo "mirror=${mirror}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
with:
platforms: arm64
# BuildKit (docker-container driver) ignores dockerd's registry-mirrors, # BuildKit (docker-container driver) ignores dockerd's registry-mirrors,
# so the mirror is configured on the builder; BuildKit itself still falls # so the mirror is configured on the builder; BuildKit itself still falls
@@ -522,23 +946,106 @@ jobs:
username: ${{ secrets.CI_USER }} username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }} password: ${{ secrets.CI_TOKEN }}
- name: Build and Push Shared httpd Image # amd64: required. Pushed untagged BY DIGEST (no tag); failure fails the
# job and publishes nothing, exactly as before multi-arch. The tags are only
# created by the assemble step below.
- name: Build amd64 (push by digest)
id: amd64
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
file: ./Dockerfile.shared-httpd file: ./Dockerfile.shared-httpd
platforms: linux/amd64 platforms: linux/amd64
push: true
build-args: | build-args: |
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }} PKG_CACHE=${{ steps.pkgcache.outputs.url }}
tags: | outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/shared-httpd,push-by-digest=true,name-canonical=true,push=true
repo.anhonesthost.net/cloud-hosting-platform/shared-httpd:latest
# arm64: best effort, built under QEMU on this same trusted x86 runner (no
# secret ever leaves it). Same Dockerfile, same build-args (incl. the php.net
# EXPECT_PHP_MIN gate, which runs `php -r` on the arm64 binary). Must never
# block or alter the amd64 tag: on failure/timeout the tag is published
# amd64-only, as before multi-arch.
- name: Build arm64 (push by digest)
id: arm64
continue-on-error: true
timeout-minutes: 25
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.shared-httpd
platforms: linux/arm64
build-args: |
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/shared-httpd,push-by-digest=true,name-canonical=true,push=true
# ONE retry of a failed arm64 leg after a pause (network-step flakes). Same inputs.
- name: Wait before arm64 retry
if: steps.arm64.outcome == 'failure'
run: sleep 90
- name: Retry arm64 (push by digest)
id: arm64_retry
if: steps.arm64.outcome == 'failure'
continue-on-error: true
timeout-minutes: 25
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.shared-httpd
platforms: linux/arm64
build-args: |
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/shared-httpd,push-by-digest=true,name-canonical=true,push=true
# Creates the index tag(s) from THIS run's digests only (a previous run's
# arm64 is never re-attached). scripts/assemble-multiarch-index.sh.
- name: Assemble index tag(s)
env:
AMD64_DIGEST: ${{ steps.amd64.outputs.digest }}
ARM64_DIGEST: ${{ steps.arm64.outcome == 'success' && steps.arm64.outputs.digest || steps.arm64_retry.outputs.digest }}
ARM64_OUTCOME: ${{ (steps.arm64.outcome == 'success' || steps.arm64_retry.outcome == 'success') && 'success' || steps.arm64.outcome }}
ALLOW_AMD64_ONLY: ${{ github.event.inputs.allow_amd64_only }}
run: |
set -euo pipefail
scripts/assemble-multiarch-index.sh \
--amd64 "$AMD64_DIGEST" \
--arm64 "$ARM64_DIGEST" --arm64-outcome "$ARM64_OUTCOME" \
--guard-existing-arm64 --verify-bin /usr/sbin/httpd \
--repo repo.anhonesthost.net/cloud-hosting-platform/shared-httpd \
--tag latest
Build-Shared-OLS: Build-Shared-OLS:
needs: plan
if: needs.plan.outputs.shared_ols == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
# One place for the OLS base tag: digest lookup and build-args both read it.
env:
OLS_VERSION: "1.8.4"
PHPVER: "83"
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
# Base image pinned by DIGEST, looked up directly at Docker Hub (never via
# the pkg-cache mirror), so the mirror can only serve content-addressed
# blobs that BuildKit verifies. If the lookup fails this job does NOT use
# the mirror and pulls the tag straight from Docker Hub. docs/pkg-cache.md.
- name: Resolve base image digest (Docker Hub, direct)
id: base
env:
BASE_TAG: litespeedtech/openlitespeed:${{ env.OLS_VERSION }}-lsphp${{ env.PHPVER }}
run: |
set -uo pipefail
if ref=$(.gitea/scripts/resolve-base-image.sh "$BASE_TAG") && [[ "$ref" =~ ^[a-z0-9][a-z0-9._/-]*@sha256:[0-9a-f]{64}$ ]]; then
echo "base-image: ${BASE_TAG} -> ${ref} (digest from registry-1.docker.io)"
echo "image=${ref}" >> "$GITHUB_OUTPUT"
echo "pinned=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::base image ${BASE_TAG}: Docker Hub digest lookup failed - pulling the tag directly from Docker Hub, pkg-cache registry mirror NOT used"
echo "image=${BASE_TAG}" >> "$GITHUB_OUTPUT"
echo "pinned=false" >> "$GITHUB_OUTPUT"
fi
# Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if # Internal package cache (CT130 pkg-cache, docs/pkg-cache.md). Used ONLY if
# it answers over TLS with our pinned CA; otherwise (down, unreachable, # it answers over TLS with our pinned CA; otherwise (down, unreachable,
# bad/expired cert) this job builds from the upstream repos and Docker Hub # bad/expired cert) this job builds from the upstream repos and Docker Hub
@@ -546,11 +1053,14 @@ jobs:
# separately so either can fail back on its own. # separately so either can fail back on its own.
- name: Probe package cache - name: Probe package cache
id: pkgcache id: pkgcache
# The registry mirror is only used for a digest-pinned base image.
env:
BASE_PINNED: ${{ steps.base.outputs.pinned }}
run: | run: |
url=""; mirror="" url=""; mirror=""
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40/; then url="https://192.168.1.40"; fi
if curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi if [ "$BASE_PINNED" = true ] && curl -fsS --max-time 5 --cacert keys/pkg-cache/ca.crt -o /dev/null https://192.168.1.40:5000/v2/; then mirror="192.168.1.40:5000"; fi
echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<unreachable: Docker Hub>}" echo "pkg-cache: repos=${url:-<unreachable: upstream>} registry-mirror=${mirror:-<not used: Docker Hub direct>}"
[ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories" [ -n "$url" ] || echo "::warning::pkg-cache unreachable - building from upstream repositories"
echo "url=${url}" >> "$GITHUB_OUTPUT" echo "url=${url}" >> "$GITHUB_OUTPUT"
echo "mirror=${mirror}" >> "$GITHUB_OUTPUT" echo "mirror=${mirror}" >> "$GITHUB_OUTPUT"
@@ -591,8 +1101,9 @@ jobs:
# Single image (runs no PHP). PHPVER just selects the OLS base tag; # Single image (runs no PHP). PHPVER just selects the OLS base tag;
# pinned to 83 / OLS 1.8.4 to match the rest of the litespeed family. # pinned to 83 / OLS 1.8.4 to match the rest of the litespeed family.
build-args: | build-args: |
PHPVER=83 PHPVER=${{ env.PHPVER }}
OLS_VERSION=1.8.4 OLS_VERSION=${{ env.OLS_VERSION }}
BASE_IMAGE=${{ steps.base.outputs.image }}
PKG_CACHE=${{ steps.pkgcache.outputs.url }} PKG_CACHE=${{ steps.pkgcache.outputs.url }}
tags: | tags: |
repo.anhonesthost.net/cloud-hosting-platform/shared-ols:latest repo.anhonesthost.net/cloud-hosting-platform/shared-ols:latest
+110 -10
View File
@@ -15,6 +15,16 @@ run-name: EMERGENCY lsphp php.net build by ${{ gitea.actor }}
## ##
## Tags: always :phpNN-phpnet-X.Y.Z (immutable, for staging / rollback) ## Tags: always :phpNN-phpnet-X.Y.Z (immutable, for staging / rollback)
## and :phpNN only when push_production_tags = true. ## and :phpNN only when push_production_tags = true.
##
## Multi-arch safety (docs/arm64/IMAGE-PIPELINE-PLAN.md 2.2 #6, 4.4): each
## platform is pushed BY DIGEST and the tags are assembled afterwards with
## scripts/assemble-multiarch-index.sh (copy of haproxy-manager-base's), so a
## tag is never overwritten with a bare single-platform manifest by accident.
## arm64 is built from the SAME php.net source in THIS run (continue-on-error);
## a previous run's arm64 is never re-attached. If a production tag is
## currently a multi-arch index and arm64 was not built successfully, the
## production tag is REFUSED unless allow_amd64_only = true (an explicit
## security-over-parity decision); the immutable tag is still created.
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
@@ -32,6 +42,16 @@ on:
required: true required: true
default: false default: false
type: boolean type: boolean
build_arm64:
description: "Also build linux/arm64 (QEMU, slow, best effort). Needed to keep arm64 in a multi-arch :phpNN."
required: false
default: false
type: boolean
allow_amd64_only:
description: "Allow replacing a multi-arch production tag with amd64-only when arm64 is not built/failed (ARM hosts then cannot pull it)."
required: false
default: false
type: boolean
jobs: jobs:
Build-lsphp-from-source: Build-lsphp-from-source:
@@ -39,7 +59,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
phpver: [81, 82, 83, 84, 85] phpver: [82, 83, 84, 85]
image: [lsphp, litespeed] image: [lsphp, litespeed]
steps: steps:
- name: Select this job's target (skip if not requested) - name: Select this job's target (skip if not requested)
@@ -49,6 +69,8 @@ jobs:
IN_VERSIONS: ${{ inputs.php_versions }} IN_VERSIONS: ${{ inputs.php_versions }}
IN_IMAGES: ${{ inputs.images }} IN_IMAGES: ${{ inputs.images }}
IN_PROD: ${{ format('{0}', inputs.push_production_tags) }} IN_PROD: ${{ format('{0}', inputs.push_production_tags) }}
IN_ARM: ${{ format('{0}', inputs.build_arm64) }}
IN_AMD_ONLY: ${{ format('{0}', inputs.allow_amd64_only) }}
PHPVER: ${{ matrix.phpver }} PHPVER: ${{ matrix.phpver }}
IMG: ${{ matrix.image }} IMG: ${{ matrix.image }}
run: | run: |
@@ -57,10 +79,14 @@ jobs:
case "$IN_PROD" in true|false) ;; *) echo "::error::push_production_tags must be true|false, got '$IN_PROD'"; exit 1 ;; esac case "$IN_PROD" in true|false) ;; *) echo "::error::push_production_tags must be true|false, got '$IN_PROD'"; exit 1 ;; esac
v="" v=""
for pair in $IN_VERSIONS; do for pair in $IN_VERSIONS; do
[[ "$pair" =~ ^(8[1-5])=([0-9]+\.[0-9]+\.[0-9]+)$ ]] || { echo "::error::bad php_versions entry '$pair' (want NN=X.Y.Z, NN in 81..85)"; exit 1; } [[ "$pair" =~ ^(8[2-5])=([0-9]+\.[0-9]+\.[0-9]+)$ ]] || { echo "::error::bad php_versions entry '$pair' (want NN=X.Y.Z, NN in 82..85)"; exit 1; }
[ "${BASH_REMATCH[1]}" = "$PHPVER" ] && v="${BASH_REMATCH[2]}" [ "${BASH_REMATCH[1]}" = "$PHPVER" ] && v="${BASH_REMATCH[2]}"
done done
case "$IN_ARM" in true|false) ;; *) echo "::error::build_arm64 must be true|false, got '$IN_ARM'"; exit 1 ;; esac
case "$IN_AMD_ONLY" in true|false) ;; *) echo "::error::allow_amd64_only must be true|false, got '$IN_AMD_ONLY'"; exit 1 ;; esac
echo "prod=$IN_PROD" >> "$GITHUB_OUTPUT" echo "prod=$IN_PROD" >> "$GITHUB_OUTPUT"
echo "arm=$IN_ARM" >> "$GITHUB_OUTPUT"
echo "amd_only=$IN_AMD_ONLY" >> "$GITHUB_OUTPUT"
if [ -z "$v" ] || { [ "$IN_IMAGES" != both ] && [ "$IN_IMAGES" != "$IMG" ]; }; then if [ -z "$v" ] || { [ "$IN_IMAGES" != both ] && [ "$IN_IMAGES" != "$IMG" ]; }; then
echo "not requested: php${PHPVER} / ${IMG}"; echo "skip=1" >> "$GITHUB_OUTPUT"; exit 0 echo "not requested: php${PHPVER} / ${IMG}"; echo "skip=1" >> "$GITHUB_OUTPUT"; exit 0
fi fi
@@ -92,8 +118,7 @@ jobs:
sha=$(printf '%s' "$json" | python3 -c 'import json,sys; d=json.load(sys.stdin); v=sys.argv[1]; print(next((s["sha256"] for s in d.get("source", []) if s.get("filename")=="php-%s.tar.xz"%v), ""))' "$v") sha=$(printf '%s' "$json" | python3 -c 'import json,sys; d=json.load(sys.stdin); v=sys.argv[1]; print(next((s["sha256"] for s in d.get("source", []) if s.get("filename")=="php-%s.tar.xz"%v), ""))' "$v")
[ -n "$sha" ] || { echo "::error::php.net has no release php-$v.tar.xz (EOL branch? typo?): $json"; exit 1; } [ -n "$sha" ] || { echo "::error::php.net has no release php-$v.tar.xz (EOL branch? typo?): $json"; exit 1; }
[[ "$sha" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::no sha256 for php-$v.tar.xz in the php.net releases JSON"; exit 1; } [[ "$sha" =~ ^[0-9a-f]{64}$ ]] || { echo "::error::no sha256 for php-$v.tar.xz in the php.net releases JSON"; exit 1; }
idx=$(curl -fsS --proto '=https' --retry 3 --max-time 60 https://rpms.litespeedtech.com/debian/dists/noble/main/binary-amd64/Packages) pkg=$(./scripts/lsphp-repo-version.sh "${PHPVER}" "${LSPHP_ARCH:-amd64}")
pkg=$(printf '%s\n' "$idx" | awk -v p="lsphp${PHPVER}" '/^Package: /{n=$2} /^Version: / && n==p {print $2}' | sort -V | tail -n1)
[ -n "$pkg" ] || { echo "::error::lsphp${PHPVER} not in the LiteSpeed repo index"; exit 1; } [ -n "$pkg" ] || { echo "::error::lsphp${PHPVER} not in the LiteSpeed repo index"; exit 1; }
[[ "$pkg" =~ ^[0-9][0-9A-Za-z.+~:-]*$ ]] || { echo "::error::malformed lsphp${PHPVER} package version in the repo index"; exit 1; } [[ "$pkg" =~ ^[0-9][0-9A-Za-z.+~:-]*$ ]] || { echo "::error::malformed lsphp${PHPVER} package version in the repo index"; exit 1; }
pphp=${pkg%%-*} pphp=${pkg%%-*}
@@ -112,6 +137,12 @@ jobs:
if: steps.t.outputs.skip == '0' if: steps.t.outputs.skip == '0'
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Set up QEMU (arm64)
if: steps.t.outputs.skip == '0' && steps.t.outputs.arm == 'true'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Login to Gitea - name: Login to Gitea
if: steps.t.outputs.skip == '0' if: steps.t.outputs.skip == '0'
uses: docker/login-action@v3 uses: docker/login-action@v3
@@ -120,13 +151,15 @@ jobs:
username: ${{ secrets.CI_USER }} username: ${{ secrets.CI_USER }}
password: ${{ secrets.CI_TOKEN }} password: ${{ secrets.CI_TOKEN }}
- name: Build and push (php.net lsphp) # amd64: required. Pushed untagged by digest; tags are made below.
- name: Build amd64 (push by digest)
if: steps.t.outputs.skip == '0' if: steps.t.outputs.skip == '0'
id: amd64
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
file: ${{ steps.t.outputs.dockerfile }} file: ${{ steps.t.outputs.dockerfile }}
platforms: linux/amd64 platforms: linux/amd64
push: true outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/${{ steps.t.outputs.image_name }},push-by-digest=true,name-canonical=true,push=true
build-args: | build-args: |
PHPVER=${{ matrix.phpver }} PHPVER=${{ matrix.phpver }}
OLS_VERSION=1.8.4 OLS_VERSION=1.8.4
@@ -136,7 +169,74 @@ jobs:
PHP_SRC_VERSION=${{ steps.t.outputs.version }} PHP_SRC_VERSION=${{ steps.t.outputs.version }}
PHP_SRC_SHA256=${{ steps.v.outputs.sha }} PHP_SRC_SHA256=${{ steps.v.outputs.sha }}
LSPHP_SOURCE=php.net LSPHP_SOURCE=php.net
tags: |
repo.anhonesthost.net/cloud-hosting-platform/${{ steps.t.outputs.image_name }}:php${{ matrix.phpver }}-phpnet-${{ steps.t.outputs.version }} # arm64: best effort, same php.net source and version, never blocks amd64.
${{ steps.t.outputs.prod == 'true' && format('repo.anhonesthost.net/cloud-hosting-platform/{0}:php{1}', steps.t.outputs.image_name, matrix.phpver) || '' }} - name: Build arm64 (push by digest)
${{ steps.t.outputs.prod == 'true' && matrix.phpver == 85 && format('repo.anhonesthost.net/cloud-hosting-platform/{0}:latest', steps.t.outputs.image_name) || '' }} if: steps.t.outputs.skip == '0' && steps.t.outputs.arm == 'true'
id: arm64
continue-on-error: true
timeout-minutes: 120
uses: docker/build-push-action@v6
with:
file: ${{ steps.t.outputs.dockerfile }}
platforms: linux/arm64
outputs: type=image,name=repo.anhonesthost.net/cloud-hosting-platform/${{ steps.t.outputs.image_name }},push-by-digest=true,name-canonical=true,push=true
build-args: |
PHPVER=${{ matrix.phpver }}
OLS_VERSION=1.8.4
CACHE_BUST=${{ steps.v.outputs.bust }}
EXPECT_LSPHP_PKG=${{ steps.v.outputs.pkg }}
EXPECT_PHP_VERSION=${{ steps.v.outputs.pkgphp }}
PHP_SRC_VERSION=${{ steps.t.outputs.version }}
PHP_SRC_SHA256=${{ steps.v.outputs.sha }}
LSPHP_SOURCE=php.net
# Immutable staging/rollback tag: always created (amd64, + arm64 if built).
- name: Assemble immutable tag
if: steps.t.outputs.skip == '0'
env:
AMD64_DIGEST: ${{ steps.amd64.outputs.digest }}
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
ARM64_OUTCOME: ${{ steps.arm64.outcome }}
REPO: repo.anhonesthost.net/cloud-hosting-platform/${{ steps.t.outputs.image_name }}
TAG: php${{ matrix.phpver }}-phpnet-${{ steps.t.outputs.version }}
run: |
./scripts/assemble-multiarch-index.sh \
--amd64 "$AMD64_DIGEST" \
--arm64 "$ARM64_DIGEST" --arm64-outcome "${ARM64_OUTCOME:-skipped}" \
--repo "$REPO" --tag "$TAG"
# Production tags: never silently drop arm64 from a multi-arch tag.
- name: Assemble production tags
if: steps.t.outputs.skip == '0' && steps.t.outputs.prod == 'true'
env:
AMD64_DIGEST: ${{ steps.amd64.outputs.digest }}
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
ARM64_OUTCOME: ${{ steps.arm64.outcome }}
ALLOW_AMD_ONLY: ${{ steps.t.outputs.amd_only }}
REPO: repo.anhonesthost.net/cloud-hosting-platform/${{ steps.t.outputs.image_name }}
PHPVER: ${{ matrix.phpver }}
run: |
set -euo pipefail
tags=(--tag "php${PHPVER}")
[ "$PHPVER" = 85 ] && tags+=(--tag latest)
if [ "${ARM64_OUTCOME:-skipped}" != success ] && [ "$ALLOW_AMD_ONLY" != true ]; then
for t in "php${PHPVER}" $([ "$PHPVER" = 85 ] && echo latest); do
rc=0; info=$(./scripts/index-platforms.sh "$REPO:$t") || rc=$?
case "$rc" in
0) ;;
3) info="not found" ;;
*) echo "::error::cannot tell whether $REPO:$t is multi-arch; refusing to overwrite it (fail closed)"; exit 1 ;;
esac
echo "$REPO:$t currently: $info"
case "$info" in
*linux/arm64*)
echo "::error::$REPO:$t is multi-arch (has arm64) but arm64 was not built successfully in this run (outcome=${ARM64_OUTCOME:-skipped}). Publishing amd64-only would drop arm64. Re-run with build_arm64=true, or set allow_amd64_only=true to accept that. The immutable tag was still created."
exit 1 ;;
esac
done
fi
./scripts/assemble-multiarch-index.sh \
--amd64 "$AMD64_DIGEST" \
--arm64 "$ARM64_DIGEST" --arm64-outcome "${ARM64_OUTCOME:-skipped}" \
--repo "$REPO" "${tags[@]}"
+20 -2
View File
@@ -1,4 +1,9 @@
FROM almalinux/10-base # Base image. CI passes BASE_IMAGE=almalinux/10-base@sha256:<digest>, resolved
# DIRECTLY from Docker Hub in the same run (.gitea/scripts/resolve-base-image.sh),
# so the pkg-cache registry mirror can only serve content-addressed blobs.
# Local builds use the tag. docs/pkg-cache.md "Base-image digest pinning".
ARG BASE_IMAGE=almalinux/10-base
FROM ${BASE_IMAGE}
ARG PHPVER=83 ARG PHPVER=83
# Per-CI-run value: the first RUN below (dnf update) and everything after it can # Per-CI-run value: the first RUN below (dnf update) and everything after it can
# never be a layer-cache hit, so every build gets the repos' current packages. # never be a layer-cache hit, so every build gets the repos' current packages.
@@ -75,6 +80,8 @@ COPY ./configs/prod-php.ini /etc/php.ini
COPY ./configs/zz-php2shell-mitigation.ini /etc/php.d/zz-php2shell-mitigation.ini COPY ./configs/zz-php2shell-mitigation.ini /etc/php.d/zz-php2shell-mitigation.ini
COPY ./configs/phpinfo.php /var/www/html/ COPY ./configs/phpinfo.php /var/www/html/
COPY ./configs/mariadb.repo /etc/yum.repos.d/ COPY ./configs/mariadb.repo /etc/yum.repos.d/
# mirror.mariadb.org names the arch dir amd64/aarch64 (not $basearch); amd64 result is byte-identical.
RUN sed -i "s/rhel\$releasever-amd64/rhel\$releasever-$(uname -m | sed s/x86_64/amd64/)/" /etc/yum.repos.d/mariadb.repo
COPY ./configs/index.php /var/www/html/ COPY ./configs/index.php /var/www/html/
COPY ./configs/remote_ip.conf /etc/httpd/conf.d/ COPY ./configs/remote_ip.conf /etc/httpd/conf.d/
COPY ./configs/whp-security.conf /etc/httpd/conf.d/ COPY ./configs/whp-security.conf /etc/httpd/conf.d/
@@ -82,7 +89,18 @@ COPY ./configs/whp-security.conf /etc/httpd/conf.d/
# Set up cron job in a single layer # Set up cron job in a single layer
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
# CVE-2026-119618 defense in depth: no HTTP/2 / mod_md in the image, build fails
# if they come back or the config no longer parses. scripts/httpd-h2-md-gate.sh.
# Placed after every other package step so nothing later can re-add them.
RUN /scripts/httpd-h2-md-gate.sh remove && /scripts/httpd-h2-md-gate.sh check
LABEL org.whp.httpd-h2-md="removed"
## Healthy = Apache answered with anything but a 5xx. `curl -f` also failed on
## 4xx, so a new site with an empty docroot (403) or an app with no route for /
## (404) showed unhealthy forever, and WHP's monitor restarted it as "PHP
## wedged". 000 (no answer) and 5xx (PHP/app error) still fail.
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD curl -f http://localhost/ || exit 1 CMD code=$(curl -s -o /dev/null -m 4 -w '%{http_code}' http://localhost/); \
case "$code" in 000|5*) echo "http $code"; exit 1;; esac
ENTRYPOINT [ "/scripts/entrypoint.sh" ] ENTRYPOINT [ "/scripts/entrypoint.sh" ]
+13 -1
View File
@@ -1,4 +1,9 @@
FROM almalinux/10-base # Base image. CI passes BASE_IMAGE=almalinux/10-base@sha256:<digest>, resolved
# DIRECTLY from Docker Hub in the same run (.gitea/scripts/resolve-base-image.sh),
# so the pkg-cache registry mirror can only serve content-addressed blobs.
# Local builds use the tag. docs/pkg-cache.md "Base-image digest pinning".
ARG BASE_IMAGE=almalinux/10-base
FROM ${BASE_IMAGE}
ARG PHPVER=83 ARG PHPVER=83
# Per-CI-run value: the first RUN below (dnf update) and everything after it can # Per-CI-run value: the first RUN below (dnf update) and everything after it can
# never be a layer-cache hit, so every build gets the repos' current packages. # never be a layer-cache hit, so every build gets the repos' current packages.
@@ -72,10 +77,17 @@ COPY ./configs/prod-php.ini /etc/php.ini
# all images ship PHP >= 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12. # all images ship PHP >= 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12.
COPY ./configs/zz-php2shell-mitigation.ini /etc/php.d/zz-php2shell-mitigation.ini COPY ./configs/zz-php2shell-mitigation.ini /etc/php.d/zz-php2shell-mitigation.ini
COPY ./configs/mariadb.repo /etc/yum.repos.d/ COPY ./configs/mariadb.repo /etc/yum.repos.d/
# mirror.mariadb.org names the arch dir amd64/aarch64 (not $basearch); amd64 result is byte-identical.
RUN sed -i "s/rhel\$releasever-amd64/rhel\$releasever-$(uname -m | sed s/x86_64/amd64/)/" /etc/yum.repos.d/mariadb.repo
# Set up cron job for log rotation # Set up cron job for log rotation
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
# CVE-2026-119618: this image carries httpd-core only (no mod_http2/mod_md). The
# gate keeps it that way and records the version in /etc/whp-httpd-version.
RUN /scripts/httpd-h2-md-gate.sh remove && /scripts/httpd-h2-md-gate.sh check
LABEL org.whp.httpd-h2-md="removed"
EXPOSE 9000 EXPOSE 9000
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
+18 -3
View File
@@ -22,12 +22,18 @@
## after FROM for any RUN steps that need it. ## after FROM for any RUN steps that need it.
ARG OLS_VERSION=1.8.5 ARG OLS_VERSION=1.8.5
ARG PHPVER=83 ARG PHPVER=83
## CI passes BASE_IMAGE=litespeedtech/openlitespeed@sha256:<digest> of the
## ${OLS_VERSION}-lsphp${PHPVER} tag, resolved DIRECTLY from Docker Hub in the same
## run (.gitea/scripts/resolve-base-image.sh), so the pkg-cache registry mirror can
## only serve content-addressed blobs. Local builds use the tag. Every stage below
## (incl. the emergency lsphp-src stage) starts from this one image.
ARG BASE_IMAGE=litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER}
## ---- EMERGENCY ONLY: lsphp compiled from php.net source ---------------------- ## ---- EMERGENCY ONLY: lsphp compiled from php.net source ----------------------
## Idle unless PHP_SRC_VERSION is set (then /lsphp-src-out stays empty and the ## Idle unless PHP_SRC_VERSION is set (then /lsphp-src-out stays empty and the
## overlay step below is a no-op). Same stage as Dockerfile.lsphp — see there and ## overlay step below is a no-op). Same stage as Dockerfile.lsphp — see there and
## docs/lsphp-source-emergency.md. ## docs/lsphp-source-emergency.md.
FROM litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER} AS lsphp-src FROM ${BASE_IMAGE} AS lsphp-src
ARG PHPVER=83 ARG PHPVER=83
ARG CACHE_BUST= ARG CACHE_BUST=
ARG EXPECT_LSPHP_PKG= ARG EXPECT_LSPHP_PKG=
@@ -42,7 +48,7 @@ RUN --mount=type=bind,source=scripts,target=/mnt/scripts \
fi; \ fi; \
PHPVER="${PHPVER}" bash /mnt/scripts/lsphp-src-build.sh PHPVER="${PHPVER}" bash /mnt/scripts/lsphp-src-build.sh
FROM litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER} FROM ${BASE_IMAGE}
ARG PHPVER=83 ARG PHPVER=83
ENV PHPVER=${PHPVER} ENV PHPVER=${PHPVER}
@@ -80,11 +86,20 @@ ENV PHPVER=${PHPVER}
ARG CACHE_BUST= ARG CACHE_BUST=
ARG EXPECT_LSPHP_PKG= ARG EXPECT_LSPHP_PKG=
ARG EXPECT_PHP_VERSION= ARG EXPECT_PHP_VERSION=
## OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40
## (CT130 pkg-cache, https only). Unset = upstream repositories (Ubuntu +
## rpms.litespeedtech.com). Repo files are restored at the end of the RUN, so no
## layer keeps the cache address. See scripts/pkg-cache-repos.sh.
ARG PKG_CACHE=
COPY ./scripts/pkg-cache-repos.sh /usr/local/sbin/pkg-cache-repos.sh
COPY ./keys/pkg-cache/ /usr/local/share/pkg-cache/
COPY ./scripts/lsphp-apt-upgrade.sh /usr/local/sbin/lsphp-apt-upgrade.sh COPY ./scripts/lsphp-apt-upgrade.sh /usr/local/sbin/lsphp-apt-upgrade.sh
RUN /usr/local/sbin/lsphp-apt-upgrade.sh "${PHPVER}" \ RUN /usr/local/sbin/pkg-cache-repos.sh apt && \
/usr/local/sbin/lsphp-apt-upgrade.sh "${PHPVER}" \
gettext-base sudo cron \ gettext-base sudo cron \
ca-certificates curl wget \ ca-certificates curl wget \
lsphp${PHPVER}-ldap && \ lsphp${PHPVER}-ldap && \
/usr/local/sbin/pkg-cache-repos.sh restore && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
+39 -5
View File
@@ -21,6 +21,12 @@
ARG OLS_VERSION=1.8.4 ARG OLS_VERSION=1.8.4
ARG PHPVER=83 ARG PHPVER=83
## CI passes BASE_IMAGE=litespeedtech/openlitespeed@sha256:<digest> of the
## ${OLS_VERSION}-lsphp${PHPVER} tag, resolved DIRECTLY from Docker Hub in the same
## run (.gitea/scripts/resolve-base-image.sh), so the pkg-cache registry mirror can
## only serve content-addressed blobs. Local builds use the tag. Every stage below
## (incl. the emergency lsphp-src stage) starts from this one image.
ARG BASE_IMAGE=litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER}
## ---- stage 0 (EMERGENCY ONLY): lsphp compiled from php.net source ----------- ## ---- stage 0 (EMERGENCY ONLY): lsphp compiled from php.net source -----------
## Idle unless PHP_SRC_VERSION is set: lsphp-src-build.sh then exits at once and ## Idle unless PHP_SRC_VERSION is set: lsphp-src-build.sh then exits at once and
@@ -30,7 +36,7 @@ ARG PHPVER=83
## — CI: .gitea/workflows/lsphp-source-emergency.yaml; runbook: ## — CI: .gitea/workflows/lsphp-source-emergency.yaml; runbook:
## docs/lsphp-source-emergency.md. The tarball is sha256- AND OpenPGP-verified ## docs/lsphp-source-emergency.md. The tarball is sha256- AND OpenPGP-verified
## against keys/php-src/; configure flags are replayed from the packaged lsphp. ## against keys/php-src/; configure flags are replayed from the packaged lsphp.
FROM litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER} AS lsphp-src FROM ${BASE_IMAGE} AS lsphp-src
ARG PHPVER=83 ARG PHPVER=83
ARG CACHE_BUST= ARG CACHE_BUST=
ARG EXPECT_LSPHP_PKG= ARG EXPECT_LSPHP_PKG=
@@ -77,7 +83,7 @@ RUN --mount=type=bind,source=scripts,target=/mnt/scripts \
## Separate stage on purpose: the compiler + headers (~400MB) stay out of the ## Separate stage on purpose: the compiler + headers (~400MB) stay out of the
## shipped image, which gains only the ~40KB .so. Costs ~1-2 min of CI per PHP ## shipped image, which gains only the ~40KB .so. Costs ~1-2 min of CI per PHP
## version; both stages share the same base layer, so no extra pull. ## version; both stages share the same base layer, so no extra pull.
FROM litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER} AS ext-build FROM ${BASE_IMAGE} AS ext-build
ARG PHPVER=83 ARG PHPVER=83
## Toolchain layer, deliberately BEFORE the source COPY so editing the extension ## Toolchain layer, deliberately BEFORE the source COPY so editing the extension
@@ -94,11 +100,20 @@ ARG PHPVER=83
ARG CACHE_BUST= ARG CACHE_BUST=
ARG EXPECT_LSPHP_PKG= ARG EXPECT_LSPHP_PKG=
ARG EXPECT_PHP_VERSION= ARG EXPECT_PHP_VERSION=
## OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40
## (CT130 pkg-cache, https only). Unset = upstream repositories (Ubuntu +
## rpms.litespeedtech.com). Repo files are restored at the end of the RUN, so no
## layer keeps the cache address. See scripts/pkg-cache-repos.sh.
ARG PKG_CACHE=
COPY ./scripts/pkg-cache-repos.sh /usr/local/sbin/pkg-cache-repos.sh
COPY ./keys/pkg-cache/ /usr/local/share/pkg-cache/
COPY ./scripts/lsphp-apt-upgrade.sh /usr/local/sbin/lsphp-apt-upgrade.sh COPY ./scripts/lsphp-apt-upgrade.sh /usr/local/sbin/lsphp-apt-upgrade.sh
RUN set -e; \ RUN set -e; \
/usr/local/sbin/pkg-cache-repos.sh apt; \
/usr/local/sbin/lsphp-apt-upgrade.sh --no-os-upgrade "${PHPVER}" \ /usr/local/sbin/lsphp-apt-upgrade.sh --no-os-upgrade "${PHPVER}" \
build-essential autoconf pkg-config \ build-essential autoconf pkg-config \
lsphp${PHPVER}-dev; \ lsphp${PHPVER}-dev; \
/usr/local/sbin/pkg-cache-repos.sh restore; \
RTV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}); \ RTV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}); \
DEVV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}-dev); \ DEVV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}-dev); \
if [ "$RTV" != "$DEVV" ]; then \ if [ "$RTV" != "$DEVV" ]; then \
@@ -168,7 +183,7 @@ RUN set -e; \
cp modules/cac_path_parity.so /build-out/ cp modules/cac_path_parity.so /build-out/
## ---- stage 2: the shipped sidecar image ------------------------------------ ## ---- stage 2: the shipped sidecar image ------------------------------------
FROM litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER} FROM ${BASE_IMAGE}
ARG PHPVER=83 ARG PHPVER=83
ENV PHPVER=${PHPVER} ENV PHPVER=${PHPVER}
@@ -196,13 +211,30 @@ ENV PHPVER=${PHPVER}
ARG CACHE_BUST= ARG CACHE_BUST=
ARG EXPECT_LSPHP_PKG= ARG EXPECT_LSPHP_PKG=
ARG EXPECT_PHP_VERSION= ARG EXPECT_PHP_VERSION=
## OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40
## (CT130 pkg-cache, https only). Unset = upstream repositories (Ubuntu +
## rpms.litespeedtech.com). Repo files are restored at the end of the RUN, so no
## layer keeps the cache address. See scripts/pkg-cache-repos.sh.
ARG PKG_CACHE=
COPY ./scripts/pkg-cache-repos.sh /usr/local/sbin/pkg-cache-repos.sh
COPY ./keys/pkg-cache/ /usr/local/share/pkg-cache/
COPY --from=ext-build /build-out/lsphp.version /etc/cac-lsphp-build.version COPY --from=ext-build /build-out/lsphp.version /etc/cac-lsphp-build.version
COPY ./scripts/lsphp-apt-upgrade.sh /usr/local/sbin/lsphp-apt-upgrade.sh COPY ./scripts/lsphp-apt-upgrade.sh /usr/local/sbin/lsphp-apt-upgrade.sh
COPY --chmod=0755 ./scripts/lsphp-pin-resolve.sh /usr/local/sbin/lsphp-pin-resolve.sh
## Per-package pins: lsphpNN is pinned to $V exactly; -common/-ldap to $V when the
## repo offers it, else to a same-PHP-version packaging revision >= $V (LiteSpeed
## published lsphp84 -2 with lsphp84-common -3 on 2026-11-19). See the script.
RUN set -e; \ RUN set -e; \
PR=/usr/local/sbin/lsphp-pin-resolve.sh; \
V=$(cat /etc/cac-lsphp-build.version); \ V=$(cat /etc/cac-lsphp-build.version); \
/usr/local/sbin/pkg-cache-repos.sh apt; \
apt-get update --error-on=any; \
VC=$($PR resolve lsphp${PHPVER}-common "$V"); \
VL=$($PR resolve lsphp${PHPVER}-ldap "$V"); \
echo "lsphp pins: lsphp${PHPVER}=$V -common=$VC -ldap=$VL"; \
if ! /usr/local/sbin/lsphp-apt-upgrade.sh "${PHPVER}" \ if ! /usr/local/sbin/lsphp-apt-upgrade.sh "${PHPVER}" \
ca-certificates \ ca-certificates \
lsphp${PHPVER}="$V" lsphp${PHPVER}-common="$V" lsphp${PHPVER}-ldap="$V"; then \ lsphp${PHPVER}="$V" lsphp${PHPVER}-common="$VC" lsphp${PHPVER}-ldap="$VL"; then \
echo "FATAL: lsphp-apt-upgrade.sh failed (reason above). If apt said" >&2; \ echo "FATAL: lsphp-apt-upgrade.sh failed (reason above). If apt said" >&2; \
echo " \"Version '$V' ... was not found\" or refused a downgrade: $V is what" >&2; \ echo " \"Version '$V' ... was not found\" or refused a downgrade: $V is what" >&2; \
echo " cac_path_parity was compiled against, but the LiteSpeed repo (which" >&2; \ echo " cac_path_parity was compiled against, but the LiteSpeed repo (which" >&2; \
@@ -211,11 +243,13 @@ RUN set -e; \
echo " build (CI) / rebuild with --no-cache (local)." >&2; \ echo " build (CI) / rebuild with --no-cache (local)." >&2; \
exit 1; \ exit 1; \
fi; \ fi; \
/usr/local/sbin/pkg-cache-repos.sh restore; \
apt-get clean; \ apt-get clean; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \ rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
RTV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}); \ RTV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}); \
CMV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}-common); \ CMV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}-common); \
if [ "$RTV" != "$V" ] || [ "$CMV" != "$V" ]; then \ LDV=$(dpkg-query -W -f='${Version}' lsphp${PHPVER}-ldap); \
if [ "$RTV" != "$V" ] || [ "$CMV" != "$VC" ] || [ "$LDV" != "$VL" ] || ! $PR ok "$CMV" "$V"; then \
echo "FATAL: cac_path_parity.so was compiled against lsphp${PHPVER} $V but this" >&2; \ echo "FATAL: cac_path_parity.so was compiled against lsphp${PHPVER} $V but this" >&2; \
echo " image would ship lsphp${PHPVER}=$RTV / -common=$CMV." >&2; \ echo " image would ship lsphp${PHPVER}=$RTV / -common=$CMV." >&2; \
echo " Rebuild with --no-cache so both stages resolve the same release." >&2; \ echo " Rebuild with --no-cache so both stages resolve the same release." >&2; \
+13 -1
View File
@@ -1,4 +1,9 @@
FROM almalinux/10-base # Base image. CI passes BASE_IMAGE=almalinux/10-base@sha256:<digest>, resolved
# DIRECTLY from Docker Hub in the same run (.gitea/scripts/resolve-base-image.sh),
# so the pkg-cache registry mirror can only serve content-addressed blobs.
# Local builds use the tag. docs/pkg-cache.md "Base-image digest pinning".
ARG BASE_IMAGE=almalinux/10-base
FROM ${BASE_IMAGE}
# OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40 # OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40
# (CT130 pkg-cache, https only). Unset = upstream repositories. Release RPMs are # (CT130 pkg-cache, https only). Unset = upstream repositories. Release RPMs are
@@ -26,6 +31,7 @@ COPY ./scripts/log-rotate.sh /scripts/log-rotate.sh
COPY ./scripts/entrypoint-shared-httpd.sh /scripts/entrypoint-shared-httpd.sh COPY ./scripts/entrypoint-shared-httpd.sh /scripts/entrypoint-shared-httpd.sh
COPY ./scripts/stop-services.sh /scripts/stop-services.sh COPY ./scripts/stop-services.sh /scripts/stop-services.sh
COPY ./scripts/tune-mpm.sh /scripts/tune-mpm.sh COPY ./scripts/tune-mpm.sh /scripts/tune-mpm.sh
COPY ./scripts/httpd-h2-md-gate.sh /scripts/httpd-h2-md-gate.sh
RUN chmod +x /scripts/* RUN chmod +x /scripts/*
# Generate self-signed SSL cert (same as main CAC image) # Generate self-signed SSL cert (same as main CAC image)
@@ -44,6 +50,12 @@ RUN mkdir -p /etc/httpd/conf.d/vhosts
# Set up cron job for log rotation # Set up cron job for log rotation
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
# CVE-2026-119618 defense in depth: no HTTP/2 / mod_md in the image, build fails
# if they come back or the config no longer parses. scripts/httpd-h2-md-gate.sh.
# Placed after every other package step so nothing later can re-add them.
RUN /scripts/httpd-h2-md-gate.sh remove && /scripts/httpd-h2-md-gate.sh check
LABEL org.whp.httpd-h2-md="removed"
EXPOSE 80 443 EXPOSE 80 443
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
+6 -1
View File
@@ -17,7 +17,12 @@
ARG OLS_VERSION=1.8.4 ARG OLS_VERSION=1.8.4
ARG PHPVER=83 ARG PHPVER=83
FROM litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER} ## CI passes BASE_IMAGE=litespeedtech/openlitespeed@sha256:<digest> of the
## ${OLS_VERSION}-lsphp${PHPVER} tag, resolved DIRECTLY from Docker Hub in the same
## run (.gitea/scripts/resolve-base-image.sh), so the pkg-cache registry mirror can
## only serve content-addressed blobs. Local builds use the tag.
ARG BASE_IMAGE=litespeedtech/openlitespeed:${OLS_VERSION}-lsphp${PHPVER}
FROM ${BASE_IMAGE}
## OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40 ## OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40
## (CT130 pkg-cache, https only). Unset = upstream repositories. Release RPMs are ## (CT130 pkg-cache, https only). Unset = upstream repositories. Release RPMs are
+3 -3
View File
@@ -1,6 +1,6 @@
# Cloud Apache Container # Cloud Apache Container
This is a base container for running PHP-based applications, supporting multiple PHP versions (7.4, 8.0, 8.1, 8.2, 8.3, 8.4). The default is PHP 8.3. The container is based on AlmaLinux 9 and uses Apache with mod_ssl. It is designed for both development and production use. This is a base container for running PHP-based applications, supporting multiple PHP versions (7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6; 8.6 is cac and cac-fpm only, no LiteSpeed lsphp86 yet). The default is PHP 8.3. The container is based on AlmaLinux 9 and uses Apache with mod_ssl. It is designed for both development and production use.
**You must have Docker or compatible containerization software running.** **You must have Docker or compatible containerization software running.**
@@ -29,7 +29,7 @@ The easiest way to start a local development environment is with the provided `l
- `-p` HTTP port (default: 80) - `-p` HTTP port (default: 80)
- `-s` HTTPS port (default: 443) - `-s` HTTPS port (default: 443)
- `-r` Root path for files and database (default: current directory) - `-r` Root path for files and database (default: current directory)
- `-a` PHP version (default: 8.3; options: 74, 80, 81, 82, 83, 84) - `-a` PHP version (default: 8.3; options: 74, 80, 81, 82, 83, 84, 85, 86)
- `-v` Enable verbose mode - `-v` Enable verbose mode
- `-h` Show help - `-h` Show help
@@ -86,7 +86,7 @@ Then visit https://localhost (accept the SSL warning) to complete setup.
## Features ## Features
- **Multiple PHP Versions:** 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 (set with `PHPVER` or `-a` flag) - **Multiple PHP Versions:** 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6 (8.6: cac and cac-fpm only) (set with `PHPVER` or `-a` flag)
- **Pre-built Images:** Pull the image for your desired PHP version directly from the registry. No need to build locally unless customizing. - **Pre-built Images:** Pull the image for your desired PHP version directly from the registry. No need to build locally unless customizing.
- **Optimized Build:** Smaller, faster, and more secure images thanks to the improved Dockerfile and `.dockerignore`. - **Optimized Build:** Smaller, faster, and more secure images thanks to the improved Dockerfile and `.dockerignore`.
- **Automatic Database Setup:** MariaDB is started in DEV mode, credentials are auto-generated and stored in `/home/$user/mysql_creds`. - **Automatic Database Setup:** MariaDB is started in DEV mode, credentials are auto-generated and stored in `/home/$user/mysql_creds`.
+8
View File
@@ -0,0 +1,8 @@
# arm64 in build-push.yaml (cac, cac-fpm, shared-httpd)
The arm64 leg is best effort (QEMU on the x86 runner) but never silently lost:
- Matrix families run at most 2 legs at once (`max-parallel: 2`); 2026-11-19 showed that 8 concurrent QEMU legs fail on network steps.
- A failed arm64 leg is retried ONCE after 90 s (`Retry arm64`). Assemble uses the first success.
- Before publishing, `scripts/assemble-multiarch-index.sh --verify-bin` checks ELF machine types (amd64 = x86-64, arm64 = AArch64). A wrong arm64 counts as a failed leg; a wrong amd64 aborts.
- `--guard-existing-arm64`: if the build ends without arm64 (failed, skipped or cancelled leg) and the current tag has an arm64 entry, the assemble step FAILS and publishes nothing (the amd64 digest is in the error). Options: re-dispatch `only=<leg>`, or dispatch with `allow_amd64_only=true` (security rebuilds) and then restore arm64 with the `arm64-attach` workflow. Push-triggered runs have no input, so the guard is always on there.
+1 -1
View File
@@ -96,7 +96,7 @@ Each of the following fails the build:
| OpenPGP signature | `gpgv` rejects the `.asc` against `keys/php-src/php-keyring.asc`, or the signer's primary fingerprint is not listed for that branch in `keys/php-src/release-managers.txt`. | | OpenPGP signature | `gpgv` rejects the `.asc` against `keys/php-src/php-keyring.asc`, or the signer's primary fingerprint is not listed for that branch in `keys/php-src/release-managers.txt`. |
| Version sanity | The version is not X.Y.Z, is not in the PHPVER branch, or is not newer than the packaged version. | | Version sanity | The version is not X.Y.Z, is not in the PHPVER branch, or is not newer than the packaged version. |
| Configure | Replaying the packaged lsphp's own `Configure Command` fails. The usual cause is a `-dev` package missing from `DEVPKGS`. | | Configure | Replaying the packaged lsphp's own `Configure Command` fails. The usual cause is a `-dev` package missing from `DEVPKGS`. |
| LSAPI SAPI | `php-litespeed-8.3.tgz` does not match its pinned sha256, or the built lsphp's set of `LSAPI_*` names differs from the packaged binary's. | | LSAPI SAPI | `php-litespeed-8.4.tgz` (pinned 2026-11-19; was 8.3) does not match its pinned sha256, or the built lsphp's set of `LSAPI_*` names differs from the packaged binary's. |
| Compiled-in ini defaults | Any `php -n` ini default differs from the packaged binary. Directives that are new in the release are allowed and printed. | | Compiled-in ini defaults | Any `php -n` ini default differs from the packaged binary. Directives that are new in the release are allowed and printed. |
| ABI gate | A struct member's offset or size changed, or a non-`*_globals` struct changed size. See `scripts/lsphp-abi-gate.sh`. | | ABI gate | A struct member's offset or size changed, or a non-`*_globals` struct changed size. See `scripts/lsphp-abi-gate.sh`. |
| File replacement | A php-src ELF file owned by a package at the core version has no php.net counterpart. | | File replacement | A php-src ELF file owned by a package at the core version has no php.net counterpart. |
+71 -3
View File
@@ -21,6 +21,10 @@ On that day a build without the cache spent **1031 s** in its first dnf step. Th
| `https://192.168.1.40/ubuntu/` | `https://archive.ubuntu.com/ubuntu`, `https://us.archive.ubuntu.com/ubuntu` | | `https://192.168.1.40/ubuntu/` | `https://archive.ubuntu.com/ubuntu`, `https://us.archive.ubuntu.com/ubuntu` |
| `https://192.168.1.40/ubuntu-security/` | `https://security.ubuntu.com/ubuntu`, `https://archive.ubuntu.com/ubuntu` | | `https://192.168.1.40/ubuntu-security/` | `https://security.ubuntu.com/ubuntu`, `https://archive.ubuntu.com/ubuntu` |
| `https://192.168.1.40/litespeed/` | `https://rpms.litespeedtech.com`, then `http://rpms.litespeedtech.com` | | `https://192.168.1.40/litespeed/` | `https://rpms.litespeedtech.com`, then `http://rpms.litespeedtech.com` |
| `https://192.168.1.40/nodesource/` | `https://rpm.nodesource.com` (origin only; RPMs signed, repomd not) — added 2026-10-22 |
| `https://192.168.1.40/debian/` | `https://deb.debian.org/debian` (CDN origin; princeton was 6 h behind on trixie-updates) — added 2026-10-22 |
| `https://192.168.1.40/debian-security/` | `https://security.debian.org/debian-security`, `https://deb.debian.org/debian-security` — added 2026-10-22 |
| `https://192.168.1.40/goproxy/` | `https://proxy.golang.org` (Go module proxy; `/sumdb/` is 404 there, so `go` checks sum.golang.org directly) — added 2026-10-22 |
| `192.168.1.40:5000` (TLS, pkg-cache CA) | Docker Hub pull-through cache (`registry-1.docker.io`) | | `192.168.1.40:5000` (TLS, pkg-cache CA) | Docker Hub pull-through cache (`registry-1.docker.io`) |
Plain `http://192.168.1.40/` answers **403** to LAN clients. Plain `http://192.168.1.40/` answers **403** to LAN clients.
@@ -32,6 +36,7 @@ Cache rules:
- apt `dists/`, except `by-hash/` - apt `dists/`, except `by-hash/`
- `*-latest*.rpm` and `remi-release-N.rpm` - `*-latest*.rpm` and `remi-release-N.rpm`
- `RPM-GPG-KEY*` - `RPM-GPG-KEY*`
- Go proxy `/@v/list` and `/@latest`
- directory listings - directory listings
- **Packages** (`*.rpm`, `*.deb`, hash-named repodata, `by-hash/`) are cached for 30 days and evicted after 60 days unused. Total size is capped at 110 GB, with 15 GB kept free. - **Packages** (`*.rpm`, `*.deb`, hash-named repodata, `by-hash/`) are cached for 30 days and evicted after 60 days unused. Total size is capped at 110 GB, with 15 GB kept free.
- On a connect error, timeout or 5xx, the request falls through to the next tier. Only the **last** tier may answer from a stale copy, so the order is primary, then fallback, then stale. - On a connect error, timeout or 5xx, the request falls through to the next tier. Only the **last** tier may answer from a stale copy, so the order is primary, then fallback, then stale.
@@ -65,6 +70,18 @@ docker buildx build --build-arg PKG_CACHE=https://192.168.1.40 --build-arg PHPVE
- Requires `rpm -K` to report `digests signatures OK`. - Requires `rpm -K` to report `digests signatures OK`.
- Installs with `--setopt=localpkg_gpgcheck=1`. - Installs with `--setopt=localpkg_gpgcheck=1`.
**`nodesource MAJOR`** (added 2026-10-22) replaces `curl https://rpm.nodesource.com/setup_N.x | bash`:
- writes `/etc/yum.repos.d/nodesource-nodejs.repo` with the ORIGIN baseurl, `gpgcheck=1` and `gpgkey=file:///usr/local/share/pkg-cache/RPM-GPG-KEY-nodesource` (key committed in `keys/pkg-cache/`);
- with `PKG_CACHE` it is then rewritten like the other repos; `restore` puts the origin version back, so the shipped image keeps a normal NodeSource repo.
**`go-env`** (added 2026-10-22): `eval "$(pkg-cache-repos.sh go-env)"` inside the RUN that runs `go mod download`/`go build`. Prints `GOPROXY=<cache>/goproxy|https://proxy.golang.org|direct` (`|` = fall through on ANY error) and `SSL_CERT_FILE=<state>/ca-bundle.pem`; nothing without `PKG_CACHE`. Modules stay verified by `go.sum` + sum.golang.org. End the RUN with `restore` (removes the bundle).
**EL9**: `release-install epel|remi` picks the EL major from `rpm -E %rhel` (9 or 10); `RPM-GPG-KEY-EPEL-9` is committed.
**Debian** (`apt` mode): `deb.debian.org/debian`, `deb.debian.org/debian-security` and `security.debian.org` (classic and deb822 `.sources`) are rewritten to `<cache>/debian/` and `<cache>/debian-security/`.
**Not proxied, on purpose:** PyPI and the npm registry. Our pip/npm installs are not hash-locked (`pip install -r` without `--require-hashes`, `npm install -g pm2@latest`), so the client would trust whatever the cache served — a compromised cache would mean code execution in shipped images. Proxy them only after the installs are hash-pinned. GitHub-release downloads are likewise left direct.
**`restore`**: **`restore`**:
- Puts rewritten files back. - Puts rewritten files back.
- Deletes files the script created. - Deletes files the script created.
@@ -75,9 +92,31 @@ Every RUN that rewrites ends with `restore`, so no shipped layer carries the LAN
`PKG_CACHE` must start with `https://`. `http://` is refused. `PKG_CACHE` must start with `https://`. `http://` is refused.
`Dockerfile.litespeed` and `Dockerfile.lsphp` are **not wired yet**. Two things are needed first: `Dockerfile.litespeed` and `Dockerfile.lsphp` are wired since 2026-10-22 (normal apt path; the php.net EMERGENCY stage `lsphp-src` stays on upstream). `lsphp-apt-upgrade.sh`'s madison gate accepts `<PKG_CACHE>/litespeed/` only when `PKG_CACHE` is set.
- the multi-stage `lsphp-apt-upgrade.sh` flow needs a `PKG_CACHE` ARG in each stage;
- its madison check must accept the cache URL. It currently requires `*rpms.litespeedtech.com*`, and via the cache madison shows `https://192.168.1.40/litespeed/debian`. ## Repositories wired (2026-10-22)
The script and `keys/pkg-cache/` are **canonical here**; every other repo carries byte-identical copies (`sha256sum scripts/pkg-cache-repos.sh` to compare). Change it here first, then sync. Same for `.gitea/scripts/resolve-base-image.sh`.
| Repo | Image(s) | Bases | Through the cache | Base digest-pinned |
|---|---|---|---|---|
| cloud-apache-container | cac, cac-fpm, shared-httpd (almalinux/10-base); shared-ols, cac-litespeed, cac-lsphp (litespeedtech/openlitespeed) | Docker Hub | AlmaLinux/EPEL/Remi (rpm); Ubuntu + LiteSpeed (apt) | yes, all 6 jobs |
| cloud-node-container | cnoc:node18..26 | almalinux/10-base | AlmaLinux/EPEL + NodeSource (`nodesource N`) | yes |
| cloud-memcached-container | cmc | almalinux/9-base | AlmaLinux 9 + EPEL 9 | yes |
| cloud-haproxy-container | chc | almalinux/9-base | AlmaLinux 9 + EPEL 9 (inotify-tools GitHub tarball direct) | yes |
| whp-default-container | whp-default | httpd:alpine | nothing to install (mirror only) | yes |
| versitygw-container | versitygw | ubuntu:latest | Ubuntu (versitygw .deb from GitHub direct) | yes |
| haproxy-manager-base | haproxy-manager-base, coraza-spoa | repo.anhonesthost.net python:3.12-slim / golang:1.25 (not Docker Hub: no mirror); gcr.io distroless | Debian (apt) + Go modules (`go-env`); pip direct | n/a; `mirror-base-image.yaml` now copies Docker Hub images by the digest resolved directly from Docker Hub |
| cpanel-importer | cpanel-importer | almalinux:10-minimal | AlmaLinux/EPEL/Remi — **PR #1 open, not merged** (pending rebase onto the PHP 8.5 work) | in the PR |
Not image builds (nothing to wire): kb-anhonesthost, anhonesthost-blog, dao-mail-signup, renovate-runner. ols-mail-client builds images in CI only for scanning/smoke tests (never pushed), its bases are already digest-pinned, and they install no OS packages.
## Adding a new upstream
1. On CT130: back up, then add the prefix to `UPSTREAMS` in `/usr/local/sbin/pkgcache-gen-nginx` (origin first; add a mirror tier only if you measured it is as fresh as the origin). If its mutable metadata isn't covered by `META_RE`, extend it there AND in `/usr/local/sbin/pkgcache-refresh`. Add the prefix to the `location = /` text in `/etc/nginx/pkgcache/server-common.conf`.
2. `pkgcache-gen-nginx > /etc/nginx/sites-available/pkgcache && nginx -t && systemctl reload nginx` (`pct exec` has no /usr/local/sbin in PATH: use full paths). Verify old and new prefixes with `curl --cacert keys/pkg-cache/ca.crt https://192.168.1.40/<prefix>/...` (look at `X-Cache-Status`/`X-Pkgcache-Tier`). CT130 has no egress filter, so no firewall change is needed for new origins.
3. Only proxy upstreams whose content the CLIENT verifies end to end (GPG-signed packages/metadata, Go sumdb, content digests). Commit any signing key under `keys/pkg-cache/` with its fingerprint and provenance in the README.
4. Teach `scripts/pkg-cache-repos.sh` the rewrite (keep the origin as a fallback where the client supports it), test through the cache from a runner-network host, then sync the copies.
## Trust model ## Trust model
@@ -149,6 +188,35 @@ Remaining risks:
# /etc/docker/daemon.json: { "registry-mirrors": ["https://192.168.1.40:5000"] } then restart docker # /etc/docker/daemon.json: { "registry-mirrors": ["https://192.168.1.40:5000"] } then restart docker
``` ```
## Base-image digest pinning (2026-10-22)
Gap closed (security review): with the BuildKit mirror on, `FROM almalinux/10-base`
was resolved **by tag through the cache**, so a compromised cache could hand out a
different image for that tag.
Now every job that uses the mirror first runs **"Resolve base image digest (Docker
Hub, direct)"**:
- `.gitea/scripts/resolve-base-image.sh IMAGE:TAG` gets an anonymous pull token from
`auth.docker.io` and sends a `HEAD /v2/<repo>/manifests/<tag>` to
`registry-1.docker.io` over HTTPS (never the mirror; HEADs don't count against the
pull rate limit). It prints `IMAGE@sha256:<index digest>`. Input and output are
regex-validated; values reach `run:` only via `env:`.
- The job passes `BASE_IMAGE=<that>` as a build arg; the Dockerfiles say
`ARG BASE_IMAGE=<tag>` / `FROM ${BASE_IMAGE}`. The mirror can then only serve
content-addressed manifests/blobs, which BuildKit verifies against the digest.
- **Lookup fails:** `BASE_IMAGE` falls back to the tag, the probe step does **not**
enable the registry mirror (`registry-mirror=<not used: Docker Hub direct>`), and
the tag is pulled straight from Docker Hub, as before the cache existed. The
package-repo cache (`PKG_CACHE`) is unaffected, since its content is GPG-checked.
- Freshness is automatic: the digest is looked up on every run, nothing is
hard-coded. Local builds without the arg use the tag.
- Log lines to look for: `base-image: almalinux/10-base:latest -> almalinux/10-base@sha256:...`
and `pkg-cache: repos=https://192.168.1.40 registry-mirror=192.168.1.40:5000`.
Applied to every job here (Build-and-Push, FPM, Shared-httpd, Shared-OLS, LiteSpeed, LSPHP) and to every other repo with a Docker Hub base (see "Repositories wired").
The script is canonical here (`.gitea/scripts/resolve-base-image.sh`); other repos
carry byte-identical copies.
## WHP hosts (`scripts/host/pkgcache-host-repos.sh`) ## WHP hosts (`scripts/host/pkgcache-host-repos.sh`)
`pkgcache-host-repos.sh apply https://192.168.1.40` does the following: `pkgcache-host-repos.sh apply https://192.168.1.40` does the following:
+15 -1
View File
@@ -9,5 +9,19 @@
# binary has the same LSAPI_* feature/env-name set as the packaged lsphp, so a # binary has the same LSAPI_* feature/env-name set as the packaged lsphp, so a
# LiteSpeed SAPI upgrade we have not pinned yet fails the build instead of # LiteSpeed SAPI upgrade we have not pinned yet fails the build instead of
# shipping an older SAPI. # shipping an older SAPI.
#
# RE-PINNED 2026-11-19 (emergency run 5686): LiteSpeed's lsphp 8.2-8.5 `-2+noble`
# packages (e.g. lsphp85 8.5.12-2) now carry LSAPI_ENABLE_ADMIN_OVERRIDE and the
# string "LiteSpeed V8.4" (the 8.3 tgz above this line had neither; the name-set gate
# caught it). php-litespeed-8.4.tgz (Last-Modified Tue, 17 Nov 2026 17:12:52 GMT)
# is the SAPI with that knob (hardening: admin overrides off by default, 64-bit safe
# writes). Measured against the packaged binaries before re-pinning. The previous
# pin was php-litespeed-8.3.tgz cd616b82cc853e5e3187fccd060228b9cd1a2009ce72d8da5950eef950ac29b1.
#
# RE-PINNED AGAIN 2026-11-19 (run 5692, lsphp/84): LiteSpeed republished the SAME URL
# at Thu, 19 Nov 2026 17:39:07 GMT (60487 bytes; only lsapi_main.c changed, 09:37 PST
# per the tar timestamps; it still has LSAPI_ENABLE_ADMIN_OVERRIDE and "LiteSpeed V8.4").
# Previous pin d88e90ef010e06e368da6919b700a589a9a4f478ebb7b2dc41f8d87b4e3f9b8f. The
# LSAPI name-set gate against the packaged lsphp still runs on every build.
# <url> <sha256> # <url> <sha256>
https://www.litespeedtech.com/packages/lsapi/php-litespeed-8.3.tgz cd616b82cc853e5e3187fccd060228b9cd1a2009ce72d8da5950eef950ac29b1 https://www.litespeedtech.com/packages/lsapi/php-litespeed-8.4.tgz 10c1e7f7b19c6be195083ba8684316f167581e2d3b7a4fc39eab4c46190ede5c
+12
View File
@@ -18,3 +18,15 @@ RPM-GPG-KEY-remi2024 Remi's RPM repository 2024 CF1D F005 7CE8 5DFF 5B2F 2A37
Remi rotates keys (remi2025, ...): when remi-release starts being Remi rotates keys (remi2025, ...): when remi-release starts being
signed by a new key, `release-install remi` fails loudly - add the signed by a new key, `release-install remi` fails loudly - add the
new key here (and to pkg-cache-repos.sh). new key here (and to pkg-cache-repos.sh).
RPM-GPG-KEY-EPEL-9 Fedora (epel9) FF8A D134 4597 106E CE81 3B91 8A38 72BF 3228 467C
fetched 2026-10-22 over HTTPS from dl.fedoraproject.org and
mirror.math.princeton.edu (identical); used by `release-install epel`
on EL9 images (cloud-memcached-container, cloud-haproxy-container).
RPM-GPG-KEY-nodesource Nodesource Operations <operations@nodesource.com>
242B 8138 31AF 0956 2B6C 46F7 6B88 DA4E 3AF2 8A14 (rsa4096, 2023-12-22)
fetched 2026-10-22 over HTTPS from
https://rpm.nodesource.com/gpgkey/ns-operations-public.key (the key
NodeSource's own setup_N.x scripts reference); verified by dnf
gpgcheck against the nodejs RPMs. Not on keys.openpgp.org /
keyserver.ubuntu.com - confirm out of band. Used by
`pkg-cache-repos.sh nodesource MAJOR` (cloud-node-container).
+29
View File
@@ -0,0 +1,29 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGE3mOsBEACsU+XwJWDJVkItBaugXhXIIkb9oe+7aadELuVo0kBmc3HXt/Yp
CJW9hHEiGZ6z2jwgPqyJjZhCvcAWvgzKcvqE+9i0NItV1rzfxrBe2BtUtZmVcuE6
2b+SPfxQ2Hr8llaawRjt8BCFX/ZzM4/1Qk+EzlfTcEcpkMf6wdO7kD6ulBk/tbsW
DHX2lNcxszTf+XP9HXHWJlA2xBfP+Dk4gl4DnO2Y1xR0OSywE/QtvEbN5cY94ieu
n7CBy29AleMhmbnx9pw3NyxcFIAsEZHJoU4ZW9ulAJ/ogttSyAWeacW7eJGW31/Z
39cS+I4KXJgeGRI20RmpqfH0tuT+X5Da59YpjYxkbhSK3HYBVnNPhoJFUc2j5iKy
XLgkapu1xRnEJhw05kr4LCbud0NTvfecqSqa+59kuVc+zWmfTnGTYc0PXZ6Oa3rK
44UOmE6eAT5zd/ToleDO0VesN+EO7CXfRsm7HWGpABF5wNK3vIEF2uRr2VJMvgqS
9eNwhJyOzoca4xFSwCkc6dACGGkV+CqhufdFBhmcAsUotSxe3zmrBjqA0B/nxIvH
DVgOAMnVCe+Lmv8T0mFgqZSJdIUdKjnOLu/GRFhjDKIak4jeMBMTYpVnU+HhMHLq
uDiZkNEvEEGhBQmZuI8J55F/a6UURnxUwT3piyi3Pmr2IFD7ahBxPzOBCQARAQAB
tCdGZWRvcmEgKGVwZWw5KSA8ZXBlbEBmZWRvcmFwcm9qZWN0Lm9yZz6JAk4EEwEI
ADgWIQT/itE0RZcQbs6BO5GKOHK/MihGfAUCYTeY6wIbDwULCQgHAgYVCgkICwIE
FgIDAQIeAQIXgAAKCRCKOHK/MihGfFX/EACBPWv20+ttYu1A5WvtHJPzwbj0U4yF
3zTQpBglQ2UfkRpYdipTlT3Ih6j5h2VmgRPtINCc/ZE28adrWpBoeFIS2YAKOCLC
nZYtHl2nCoLq1U7FSttUGsZ/t8uGCBgnugTfnIYcmlP1jKKA6RJAclK89evDQX5n
R9ZD+Cq3CBMlttvSTCht0qQVlwycedH8iWyYgP/mF0W35BIn7NuuZwWhgR00n/VG
4nbKPOzTWbsP45awcmivdrS74P6mL84WfkghipdmcoyVb1B8ZP4Y/Ke0RXOnLhNe
CfrXXvuW+Pvg2RTfwRDtehGQPAgXbmLmz2ZkV69RGIr54HJv84NDbqZovRTMr7gL
9k3ciCzXCiYQgM8yAyGHV0KEhFSQ1HV7gMnt9UmxbxBE2pGU7vu3CwjYga5DpwU7
w5wu1TmM5KgZtZvuWOTDnqDLf0cKoIbW8FeeCOn24elcj32bnQDuF9DPey1mqcvT
/yEo/Ushyz6CVYxN8DGgcy2M9JOsnmjDx02h6qgWGWDuKgb9jZrvRedpAQCeemEd
fhEs6ihqVxRFl16HxC4EVijybhAL76SsM2nbtIqW1apBQJQpXWtQwwdvgTVpdEtE
r4ArVJYX5LrswnWEQMOelugUG6S3ZjMfcyOa/O0364iY73vyVgaYK+2XtT2usMux
VL469Kj5m13T6w==
=Mjs/
-----END PGP PUBLIC KEY BLOCK-----
+52
View File
@@ -0,0 +1,52 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGWFsqMBEAC4YlSuNpHjOiQVTC8StolVx3J8E9SC6G4wmVWbytMD1Zivfanj
3LKDqdy7vpbViXA9whpyGQgQYdOlPKaNHWw4GSeGTnP1FbvaK1NJ9MnAzUysh49R
cqoktYeIQbqgOgZHw5/gVH5bYObf1KJQ2LY/je9WTlW3QMRe1TaW0F0AZnJMBIOG
JllE33QIpxDnOQHnvdUGq+HscUOTrW4Q3AdzwsQxU4GX82d9qFFr8HjAmUjlUKyh
PgvMpb8VDvR7NE6et+wWh6BMYILo3VJFP7/gTXGiy3WWs5GW/PNXIXw5/f2w1B+e
Dh5tlfGG4q/4P8mbv7C6RPHoF2Lq+W69HLqSq/l42WUL41tHlFTsluCIKpeeMxAu
olxx3Z5momHMMyh7rbZtQDqFMTAqxNjT1NinKkWyj7KP5WE9hVosyd3UMR4UYDMm
Zb6LI4N7Hht887+CY7grxTJ9cGQhMFfvLyvlf/FWQY4S6G7sEaUV71N9StvXBNG/
iNoIMzhwjBmrmvT/UGPkLSi0SIBOxeGw2rwngnYikIJxuTQ4V40lm8o6eMFca7rW
BQvAEncV8pvi/3FqrUBZ/U53s7NO24hBDoaQPzFbVCw0GHHf9GD7KoQb5c9ONoCZ
Qu2YWo7ajPLzl/h2pJ2Kn29Ywev9MpuuPTGvifiKilcBVLYP3ZJg4ZfRBwARAQAB
tDFOb2Rlc291cmNlIE9wZXJhdGlvbnMgPG9wZXJhdGlvbnNAbm9kZXNvdXJjZS5j
b20+iQJOBBMBCgA4FiEEJCuBODGvCVYrbEb3a4jaTjryihQFAmWFsqMCGwMFCwkI
BwIGFQoJCAsCBBYCAwECHgECF4AACgkQa4jaTjryihTD+hAAtTU155ke7xmnT0ph
odbGjm3mOGdkdaDH+xmWtPtufiPncgHMCYh4aIDRloog8rFE+pP3qfwJmUKxthwD
drrLAzfUwOrGxPnYH3MWwg66RVVoiiU+Hh42gJTez+P/K0VMQZXH0XTZD96TiwT/
S0+WvQPuJ9pda2L4cjV+YP2+m0ERUG9QPj0Shgw+/PWCGWKD6J9DRToiwfwCTOvc
DNolF1EcRlfPMTsqI2Bdc+TQywqU1Py1MUDSAPXxdK6nW2oM7eC5l3XXefcQ6JOS
AuNdEDIsaf+H76j6/wSGsuIcJjUo9wmKjEV1iJYwT6jLbjaVQxXgEPHBSb+kzanx
FWyrYP6TZpeY2gT4bBMsOKd7ay1I3/nIHwe6x8Yzkqzz+7YVhNpMbybH72NTxDWQ
UmiboJs9r7j1lkHlBjxU9RLF5laYSeCIXD62KQVoP5ao1LSPKsCXFqcdpUgLYtRv
CXxdriiHp4m9eGzbS7RW1TLm6tMOKbI4LzOtMm4DoZzGD2FTfsUtn6ALx9FSgvl/
VMlzqZes+rclcukACtutvtB8e0yRhuzPUN56ctLEZfI1XzQFoN8Vdj6HWtiXWRiJ
EohuufE2cEebmX90NRsbh4KAFXNEQROlMeMf7ufuSsk7QXLTutxmWSQvWwyS+P5/
ZqCapIDlRCJFZX4N9a1IXo0OgCC5Ag0EZYWyowEQAKz7sA6WBKFVcmzcyr6y9TI5
RemnzotRUdqXj8tD70xvV1nBEf+BfTw3hsiV019ZboPBae+cRaD4plQbNb0du/+Q
UFq4ja055ZEld01RqE49L562pWvA5cwSmjs9+ZMI1ja0HbTb2K4razpzX3be+Zul
TbH20X5FHTz+Jyfmw+G3Y9okw3OIzuYo16Lv/Qs8VoBmj01PItzq8dX5wJiIlVxU
8wKHKy1kiKGCgyPnvqcXCGen0EoUS9wsWK1QHfryscYGVF9y1TBQvJa9HIpWPrIZ
slSiVS4tQhGHfLDVlaDsYFrH9SIUkvW7peSEiPE1TKQjvbMS3CcUZRaMcGfgyDPe
gXwnNwZbJ2/cisXbdAJaGT49V1Y+Sc1oKSGSG4FaGUNhS3p3cB7qlX2zS/sR2ael
90fXR6nhjvhMAS98i7663pCUv9q0Z/NXNZwdXjbSF4W8gq3PVt7hCnJrngsGSkGu
Qz0dc227/sAjh9CxYm8kQqUuQtiPVfKwkcUUT+O7jr2/6eAXZbTYVZbvaLEGMrKA
bdWKpZMMOKAI45f+ZAcEmJG4D68N0jzVrLCXMuuLq/yqqyEmxDjSOH0qVutl8jxg
vfxPxKYX8nnAzJZJHGHmV/ihjfClSdYePKExHuFVVhvc4BxE1XfPUeCZG4JpB9/B
gNCiDPsg4JIw6GO5LS2xABEBAAGJAjYEGAEKACAWIQQkK4E4Ma8JVitsRvdriNpO
OvKKFAUCZYWyowIbDAAKCRBriNpOOvKKFOTKD/40WN6ZRfP6hVLAX26DdyN9Bqzg
D+0hJilmHL1YFeLt9U/YPhOZJxPaDGrMfldC0FSXKKr7H5C7FQErl936108wGohz
53KGbNid0crNeaWrQuWk3QjaMF62Yc+NVB8b5LoEk0TEt9KPO6kveYDtW6Ygkw9i
5aaS/AC+8GChOH6lWhLHcO91T7+Hi5qRez7qyme/AlHUTV9/jE6JgFJ7thCCAqBQ
AfX3mGFlTwSTMHDeYq81MMl9UhYgoFJtx8PuqmSV7Eb29ccJofz3J+b5OJvpmLSZ
Hu22Csa8k2V/1ojeL0DjQHD06V75F7BerxLR/rbJ64GkIiOdm4ntXC4a335gjQfM
5tI6LtGsIpr+Le4C068eDj7YpzS0ql3g6o4A1TbtapLccgEj4iw95H4KKh0Ro5r0
0s6LoSLu9uva3LiLVn6xXvpw3iv8FnhTr5PEiPnorXvxcCnUrB3Rkk6Wh1SKjpxa
u6KiFzH0CXR1AgUdWSC0rAmvEdFjXgaoQd+Z2eJFHEAsg91URd9NtdeDsyMwdbHh
iBZPGX5ddPjJA7nwKbkibCv7xiodd9ph8NmGLqD/2SDU1rqvPuCDMqLuxc89Gvhs
3CeLTSJK9Uzb3oNdZLxL8CECip1ZkowVfTL+jY23phS9+Z0Db/yZqot3ZZJAAG8g
oSVkzT/Mwp9zFVQu5w==
=drMP
-----END PGP PUBLIC KEY BLOCK-----
+136
View File
@@ -0,0 +1,136 @@
#!/usr/bin/env bash
# Assemble the multi-arch index tag(s) from per-platform images that were
# already pushed BY DIGEST (no tag). Used by the trusted x86 publish job
# (copied verbatim from haproxy-manager-base PR #17; see its build-push-coraza.yaml; template for the other WHP
# image repos, docs/arm64/IMAGE-PIPELINE-PLAN.md section 4.1/4.4).
#
# assemble-multiarch-index.sh \
# --amd64 sha256:<digest> \
# --arm64 sha256:<digest> --arm64-outcome success|failure|cancelled|skipped \
# --repo <registry/path> [--repo <other registry/path> ...] \
# --tag <tag> [--tag <tag> ...] [--builder <buildx builder>] \
# [--verify-bin PATH ...] [--guard-existing-arm64]
#
# Rules (all enforced here so the workflow stays thin and these are testable):
# * amd64 is mandatory. A missing/malformed amd64 digest, or an amd64 digest
# that does not inspect as linux/amd64, aborts with exit 1 and publishes
# NOTHING (the same "build failed, no tag" outcome as before multi-arch).
# * arm64 is attached ONLY when its step outcome is exactly "success" AND the
# digest is well-formed AND it inspects as linux/arm64. Otherwise the tag is
# published amd64-only (warning, exit 0). The arm64 digest must come from
# THIS run's step output - the workflow never reads it from a registry tag,
# so a previous build's arm64 can never be re-attached to a newer amd64.
# * --verify-bin (repeatable): before anything is published, the amd64 entry must hold x86-64
# and (if it would be attached) the arm64 entry AArch64 binaries at those paths
# (scripts/verify-image-arch.py, nothing is executed). Wrong/unverifiable amd64 = exit 1,
# nothing published. Wrong/unverifiable arm64 = treated as a failed arm64 leg.
# * --guard-existing-arm64: if the result would be amd64-only and a CURRENT tag already has a
# linux/arm64 entry, exit 1 and publish nothing (never silently drop arm64), unless
# env ALLOW_AMD64_ONLY=true. An unreadable tag fails closed; a missing tag is fine.
# * every --tag is created in every --repo from <repo>@<digest> sources in
# that same repo (both digests were pushed to every --repo by the build).
#
# Env: ALLOW_AMD64_ONLY=true lets the guard pass; VERIFY_ARCH overrides the verifier command
# (tests use a stub); IMAGETOOLS overrides the command (default: "docker buildx imagetools");
# the test suite points it at a stub.
set -euo pipefail
IMAGETOOLS=${IMAGETOOLS:-docker buildx imagetools}
amd64=""; arm64=""; outcome="skipped"; builder=""
repos=(); tags=(); vbins=(); guard=0
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
die() { echo "assemble-multiarch-index: $*" >&2; exit 1; }
warn() { echo "::warning::assemble-multiarch-index: $*"; }
while [ $# -gt 0 ]; do
case "$1" in
--amd64) amd64=${2-}; shift 2 ;;
--arm64) arm64=${2-}; shift 2 ;;
--arm64-outcome) outcome=${2-}; shift 2 ;;
--repo) repos+=("${2-}"); shift 2 ;;
--tag) tags+=("${2-}"); shift 2 ;;
--builder) builder=${2-}; shift 2 ;;
--verify-bin) vbins+=("${2-}"); shift 2 ;;
--guard-existing-arm64) guard=1; shift ;;
*) die "unknown argument: $1" ;;
esac
done
re='^sha256:[0-9a-f]{64}$'
[ ${#repos[@]} -gt 0 ] || die "need at least one --repo"
[ ${#tags[@]} -gt 0 ] || die "need at least one --tag"
[[ $amd64 =~ $re ]] || die "amd64 digest missing or malformed ('$amd64'); refusing to publish"
bflag=(); [ -n "$builder" ] && bflag=(--builder "$builder")
# arch_of <ref>: prints the image config's architecture ("" on any failure).
arch_of() {
# shellcheck disable=SC2086
$IMAGETOOLS inspect "${bflag[@]}" "$1" --format '{{json .Image}}' 2>/dev/null \
| python3 -I -c 'import json,sys; print(json.load(sys.stdin).get("architecture",""))' 2>/dev/null || true
}
for r in "${repos[@]}"; do
[ "$(arch_of "$r@$amd64")" = amd64 ] || die "$r@$amd64 does not inspect as linux/amd64; refusing to publish"
done
use_arm64=0
if [ "$outcome" != success ]; then
warn "arm64 step outcome is '$outcome': publishing amd64-only (no arm64 digest is carried over)"
elif ! [[ $arm64 =~ $re ]]; then
warn "arm64 step reported success but its digest is missing/malformed: publishing amd64-only"
elif [ "$arm64" = "$amd64" ]; then
warn "arm64 digest equals the amd64 digest: publishing amd64-only"
else
use_arm64=1
for r in "${repos[@]}"; do
if [ "$(arch_of "$r@$arm64")" != arm64 ]; then
warn "$r@$arm64 does not inspect as linux/arm64: publishing amd64-only"
use_arm64=0; break
fi
done
fi
# ELF machine-type check (labels alone do not prove the binaries are of that architecture).
if [ ${#vbins[@]} -gt 0 ]; then
# shellcheck disable=SC2206
verify=(${VERIFY_ARCH:-python3 -I "$HERE/verify-image-arch.py"})
vargs=(); for b in "${vbins[@]}"; do vargs+=(--bin "$b"); done
for r in "${repos[@]}"; do
"${verify[@]}" --image "$r@$amd64" --platform linux/amd64 "${vargs[@]}" \
|| die "$r@$amd64 failed the x86-64 ELF check; refusing to publish"
if [ "$use_arm64" = 1 ]; then
if ! "${verify[@]}" --image "$r@$arm64" --platform linux/arm64 "${vargs[@]}"; then
warn "$r@$arm64 failed the AArch64 ELF check: publishing amd64-only"
use_arm64=0; break
fi
fi
done
fi
# Never silently replace a multi-arch tag by an amd64-only one.
if [ "$guard" = 1 ] && [ "$use_arm64" = 0 ] && [ "${ALLOW_AMD64_ONLY:-false}" != true ]; then
for r in "${repos[@]}"; do for t in "${tags[@]}"; do
rc=0; info=$(IMAGETOOLS=$IMAGETOOLS "$HERE/index-platforms.sh" "$r:$t") || rc=$?
case "$rc" in
0) ;;
3) info="not found" ;;
*) echo "::error::assemble-multiarch-index: cannot tell whether $r:$t is multi-arch; refusing to overwrite it (fail closed)" >&2; exit 1 ;;
esac
case "$info" in
*linux/arm64*)
echo "::error::assemble-multiarch-index: $r:$t has an arm64 entry but this build has none (arm64 outcome '$outcome'); publishing amd64-only would drop it. Nothing published. amd64 digest of this build: $amd64. Fix: re-dispatch only=<leg>, or re-run with allow_amd64_only=true and then restore arm64 with the arm64-attach workflow." >&2
exit 1 ;;
esac
done; done
fi
for r in "${repos[@]}"; do
targs=(); for t in "${tags[@]}"; do targs+=(-t "$r:$t"); done
srcs=("$r@$amd64"); [ "$use_arm64" = 1 ] && srcs+=("$r@$arm64")
echo "assemble-multiarch-index: $r tags=${tags[*]} sources=${#srcs[@]} ($([ "$use_arm64" = 1 ] && echo 'amd64+arm64' || echo 'amd64-only'))"
# shellcheck disable=SC2086
$IMAGETOOLS create "${bflag[@]}" "${targs[@]}" "${srcs[@]}"
done
echo "platforms=$([ "$use_arm64" = 1 ] && echo linux/amd64,linux/arm64 || echo linux/amd64)"
+197
View File
@@ -0,0 +1,197 @@
#!/usr/bin/env bash
# Attach an arm64 image to an EXISTING tag without touching its amd64 content.
#
# Why: a build whose arm64 leg failed publishes the tag amd64-only (assemble-multiarch-index.sh).
# Re-running the whole build to get arm64 back would also rebuild amd64 (new digest, new PHP
# layers). This only re-creates the tag's INDEX: the existing amd64 manifest (and its attestation
# manifest) are carried over by digest, the new arm64 (pushed by digest, never tagged) is added.
#
# attach-arm64-index.sh --repo <registry/path> --tag <tag> --arm64 sha256:<digest> \
# [--expect-index sha256:<digest>] [--force] [--follow-tag <tag>] [--builder <buildx builder>]
# attach-arm64-index.sh --repo <registry/path> --tag <tag> --plan-only [--force] (no --arm64 needed)
#
# Rules (all enforced here so the workflow stays thin and these are testable):
# * The tag must exist, be an image index (or a plain amd64 manifest) and contain exactly one
# linux/amd64 entry. Anything else: exit 1, nothing written.
# * If the tag already has a linux/arm64 entry: exit 3, nothing written, unless --force (then the
# old arm64 entry is replaced; the amd64 manifest is still carried over unchanged).
# * --expect-index: the digest of the tag's current index as read by an earlier step. If the tag
# moved since (a build published meanwhile) exit 1: we never overwrite a newer publish with an
# index derived from an older one.
# * The new arm64 digest must inspect as linux/arm64 and differ from the amd64 digest.
# * After the create the tag is re-read: its linux/amd64 manifest digest MUST be identical to the
# one before and an arm64 entry MUST be present. Otherwise exit 1. The previous index is
# re-created ONLY if our create lost the amd64 entry; a tag that now has a different amd64 (a
# concurrent publish) is never rolled back. Residual window: registry has no conditional PUT,
# so a publish landing between the last read and the create is still overwritten: do not run
# this while build-push runs for the same family.
# * --follow-tag T (e.g. latest for php85): if <repo>:T currently has the very same index digest as
# <tag> had BEFORE the attach (i.e. it is an alias of it), it is re-pointed to the new index so
# the alias keeps equalling the tag. If it differs it is left alone (warning). Never created.
# * --plan-only: run every check above, print the plan, create nothing (an already multi-arch
# tag still exits 3, so a pre-check step fails before an expensive build).
#
# Output (stdout, key=value, also appended to $GITHUB_OUTPUT when set):
# before_index= amd64= after_index= platforms=
# Env: IMAGETOOLS overrides the command (default: "docker buildx imagetools"); tests use a stub.
set -euo pipefail
IMAGETOOLS=${IMAGETOOLS:-docker buildx imagetools}
repo=""; tag=""; arm64=""; expect=""; force=0; plan_only=0; builder=""; follow=""
die() { echo "attach-arm64-index: $1" >&2; exit "${2:-1}"; }
note() { echo "attach-arm64-index: $*"; }
while [ $# -gt 0 ]; do
case "$1" in
--repo) repo=${2-}; shift 2 ;;
--tag) tag=${2-}; shift 2 ;;
--arm64) arm64=${2-}; shift 2 ;;
--expect-index) expect=${2-}; shift 2 ;;
--force) force=1; shift ;;
--plan-only) plan_only=1; shift ;;
--follow-tag) follow=${2-}; shift 2 ;;
--builder) builder=${2-}; shift 2 ;;
*) die "unknown argument: $1" 2 ;;
esac
done
dre='^sha256:[0-9a-f]{64}$'
[[ $repo =~ ^[a-z0-9][a-z0-9._:/-]*$ ]] || die "bad --repo '$repo'" 2
[[ $tag =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]] || die "bad --tag '$tag'" 2
if [ "$plan_only" = 1 ] && [ -z "$arm64" ]; then :; else
[[ $arm64 =~ $dre ]] || die "--arm64 digest missing or malformed ('$arm64')" 2
fi
if [ -n "$follow" ]; then
[[ $follow =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]] || die "bad --follow-tag '$follow'" 2
[ "$follow" != "$tag" ] || die "--follow-tag equals --tag" 2
fi
if [ -n "$expect" ]; then [[ $expect =~ $dre ]] || die "bad --expect-index '$expect'" 2; fi
if [ "$plan_only" != 1 ] && [ -z "$expect" ]; then die "--expect-index is required (the digest the plan step read)" 2; fi
bflag=(); [ -n "$builder" ] && bflag=(--builder "$builder")
# shellcheck disable=SC2086
it() { $IMAGETOOLS "$1" "${bflag[@]}" "${@:2}"; }
# tag_digest <ref>: manifest (index) digest of a ref; empty on failure.
tag_digest() {
it inspect "$1" --format '{{.Manifest.Digest}}' 2>>"${ATTACH_STDERR:-/dev/stderr}" | tail -n 1 | tr -d '[:space:]' || true
}
# arch_of <ref>: image config architecture; empty on failure.
arch_of() {
it inspect "$1" --format '{{json .Image}}' 2>/dev/null \
| python3 -I -c 'import json,sys; print(json.load(sys.stdin).get("architecture",""))' 2>/dev/null || true
}
# parse <raw-json>: prints "kind=index|single", "amd64=<digests, space separated>", "arm64=<digests>".
parse_index() {
python3 -I -c '
import json, sys
try:
d = json.loads(sys.argv[1])
except Exception:
print("kind=bad"); sys.exit(0)
if isinstance(d, dict) and isinstance(d.get("manifests"), list):
a, r = [], []
for m in d["manifests"]:
p = m.get("platform") if isinstance(m, dict) else None
if not isinstance(p, dict) or "vnd.docker.reference.type" in (m.get("annotations") or {}):
continue
if p.get("os") != "linux":
continue
if p.get("architecture") == "amd64":
a.append(m.get("digest", ""))
elif p.get("architecture") == "arm64":
r.append(m.get("digest", ""))
print("kind=index"); print("amd64=" + " ".join(a)); print("arm64=" + " ".join(r))
elif isinstance(d, dict) and isinstance(d.get("config"), dict):
print("kind=single")
else:
print("kind=bad")
' "$1"
}
# read_tag <ref>: sets g_digest, g_kind, g_amd64, g_arm64 for the tag as currently published.
read_tag() {
local raw out
g_digest=$(tag_digest "$1")
[[ $g_digest =~ $dre ]] || die "cannot read the manifest digest of $1 (does the tag exist?)"
raw=$(it inspect --raw "$1" 2>/dev/null) || die "cannot read $1"
out=$(parse_index "$raw")
g_kind=$(sed -n 's/^kind=//p' <<<"$out"); g_amd64=$(sed -n 's/^amd64=//p' <<<"$out"); g_arm64=$(sed -n 's/^arm64=//p' <<<"$out")
[ "$(tag_digest "$1")" = "$g_digest" ] || die "$1 changed while it was being read; try again"
}
ref="$repo:$tag"
read_tag "$ref"
before_index=$g_digest; kind=$g_kind; amd64=$g_amd64; had_arm64=$g_arm64
case "$kind" in
index) ;;
single)
[ "$(arch_of "$repo@$before_index")" = amd64 ] || die "$ref is a single manifest that is not linux/amd64"
amd64=$before_index ;;
*) die "$ref is neither an index nor an image manifest" ;;
esac
[ "$(wc -w <<<"$amd64")" -eq 1 ] || die "$ref has '$(wc -w <<<"$amd64")' linux/amd64 entries, want exactly one"
[[ $amd64 =~ $dre ]] || die "$ref: malformed amd64 digest '$amd64'"
note "$ref index=$before_index amd64=$amd64 existing-arm64='${had_arm64:-none}'"
if [ -n "$expect" ] && [ "$expect" != "$before_index" ]; then
die "$ref is now $before_index but the plan was made for $expect: the tag moved, refusing to overwrite it"
fi
if [ -n "$had_arm64" ] && [ "$force" != 1 ]; then
die "$ref already has a linux/arm64 entry ($had_arm64); use --force to replace it" 3
fi
if [ -n "$arm64" ]; then
[ "$arm64" != "$amd64" ] || die "arm64 digest equals the amd64 digest"
[ "$(arch_of "$repo@$arm64")" = arm64 ] || die "$repo@$arm64 does not inspect as linux/arm64; refusing to publish"
fi
emit() { # key=value to stdout and $GITHUB_OUTPUT
echo "$1"; if [ -n "${GITHUB_OUTPUT:-}" ]; then echo "$1" >>"$GITHUB_OUTPUT"; fi
}
emit "before_index=$before_index"; emit "amd64=$amd64"
if [ "$plan_only" = 1 ]; then emit "platforms=plan-only"; exit 0; fi
# Sources: keep the whole current index (amd64 + its attestation, byte-identical descriptors),
# unless the arm64 entry is being replaced (--force): then only the amd64 manifest is carried over.
if [ "$kind" = index ] && [ -z "$had_arm64" ]; then src_old="$repo@$before_index"; else src_old="$repo@$amd64"; fi
note "creating $ref from $src_old + $repo@$arm64"
it create -t "$ref" "$src_old" "$repo@$arm64" || { echo "::error::attach-arm64-index: create failed; tag state unverified (was $before_index)" >&2; exit 1; }
read_tag "$ref"
after_index=$g_digest
ok=1
[ "$g_kind" = index ] || ok=0
[ "$g_amd64" = "$amd64" ] || ok=0
[ "$(wc -w <<<"$g_arm64")" -eq 1 ] || ok=0
if [ "$ok" != 1 ]; then
echo "::error::attach-arm64-index: $ref after create: kind=$g_kind amd64='$g_amd64' arm64='$g_arm64' (want amd64 $amd64 unchanged + one arm64)" >&2
# Restore ONLY when our create demonstrably lost the amd64 entry. If the tag now carries a
# different amd64 (a build-push published meanwhile) it is newer than anything we hold: never
# roll it back.
if [ "$kind" = index ] && [ -z "$g_amd64" ]; then
echo "::error::attach-arm64-index: amd64 entry lost; restoring $before_index" >&2
it create -t "$ref" "$repo@$before_index" || echo "::error::attach-arm64-index: RESTORE FAILED, $ref needs manual repair (previous index $before_index)" >&2
if [ "$(tag_digest "$ref")" = "$before_index" ]; then echo "attach-arm64-index: restored $before_index" >&2
else echo "::error::attach-arm64-index: after restore $ref is NOT $before_index; manual repair needed" >&2; fi
elif [ "$g_amd64" != "$amd64" ]; then
echo "::error::attach-arm64-index: $ref moved to a different amd64 ($g_amd64) while attaching; NOT restoring (it is newer). Re-check the tag and re-run." >&2
else
echo "::error::attach-arm64-index: tag state unexpected; NOT restoring automatically. Previous index was $before_index." >&2
fi
exit 1
fi
note "$ref now index=$after_index (was $before_index); amd64 manifest unchanged $amd64; arm64=$g_arm64"
emit "after_index=$after_index"; emit "platforms=linux/amd64,linux/arm64"
# Alias tag (e.g. latest == php85): re-point only if it was an exact alias of the tag before.
if [ -n "$follow" ]; then
fdig=$(tag_digest "$repo:$follow")
if [ "$fdig" = "$before_index" ]; then
note "$repo:$follow was an alias of $tag ($before_index): re-pointing it to $after_index"
it create -t "$repo:$follow" "$repo@$after_index"
[ "$(tag_digest "$repo:$follow")" = "$after_index" ] || die "$repo:$follow does not equal $after_index after the re-point"
emit "followed_tag=$follow"
else
echo "::warning::attach-arm64-index: $repo:$follow is '${fdig:-missing}', not an alias of $tag ($before_index): left untouched"
fi
fi
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
# CVE-2026-119618 (mod_http2 assign_headers heap corruption, httpd 2.4.55-2.4.70)
# defense in depth. Nothing in WHP needs HTTP/2 or mod_md inside a container: the
# HAProxy edge terminates h2/h3 and speaks HTTP/1.1 to backends, and certificates
# come from the edge, not mod_md. So the modules are removed from every
# Alma-based Apache image and this gate fails the build if they ever come back.
#
# httpd-h2-md-gate.sh remove uninstall mod_http2 / mod_md RPMs (if present)
# httpd-h2-md-gate.sh check fail unless the modules cannot load, `httpd -t`
# passes, and record the httpd version
#
# Both are idempotent and safe on images with no Apache at all (a no-op).
set -euo pipefail
BAD_MODULES='http2_module|proxy_http2_module|md_module'
MOD_PKGS='mod_http2 mod_md'
cmd_remove() {
local p present=()
for p in $MOD_PKGS; do
rpm -q "$p" >/dev/null 2>&1 && present+=("$p")
done
if [ "${#present[@]}" -gt 0 ]; then
dnf remove -y "${present[@]}"
fi
# Belt and braces if a package was removed but a module file was left behind.
rm -f /etc/httpd/conf.modules.d/10-h2.conf /etc/httpd/conf.modules.d/10-proxy_h2.conf \
/etc/httpd/conf.modules.d/*-md.conf \
/usr/lib64/httpd/modules/mod_http2.so /usr/lib64/httpd/modules/mod_proxy_http2.so \
/usr/lib64/httpd/modules/mod_md.so
}
cmd_check() {
local p mods v fail=0
command -v httpd >/dev/null 2>&1 || { echo "gate: no httpd binary" >&2; exit 1; }
for p in $MOD_PKGS; do
if rpm -q "$p" >/dev/null 2>&1; then echo "gate FAIL: RPM $p is installed" >&2; fail=1; fi
done
# Anchored on the module name column ("systemd_module" must NOT match md_module).
mods=$(httpd -M 2>/dev/null) || { echo "gate FAIL: httpd -M failed" >&2; exit 1; }
if printf '%s\n' "$mods" | grep -E "^ (${BAD_MODULES}) "; then
echo "gate FAIL: HTTP/2 or mod_md module still loadable" >&2; fail=1
fi
[ "$fail" -eq 0 ] || exit 1
httpd -t
v=$(rpm -q --qf '%{VERSION}-%{RELEASE}' httpd-core)
printf '%s\n' "$v" > /etc/whp-httpd-version
echo "gate OK: httpd-core ${v}; no http2/proxy_http2/md modules; httpd -t passes"
}
case "${1:-}" in
remove) cmd_remove ;;
check) cmd_check ;;
*) echo "usage: $0 remove|check" >&2; exit 2 ;;
esac
+103
View File
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
## image-label-amd64.sh REF LABEL [LABEL...]
##
## Prints the value of each LABEL (one per line, empty line if the label is
## absent) from the *linux/amd64* image behind REF, whether REF is a plain
## single-platform manifest, an OCI image index (attestation children are
## ignored) or a Docker manifest list.
##
## Why: `imagetools inspect REF --format '{{ index .Image.Config.Labels ... }}'`
## is only meaningful for a single-platform image; on a multi-arch index `.Image`
## is platform-keyed / unavailable depending on the buildx version, and the old
## callers swallowed the error (fail-open). This resolves the amd64 child
## digest from the raw index, then inspects that child directly.
##
## Exit: 0 labels printed; 3 REF does not exist in the registry (not found);
## 1 anything else (network/auth error, malformed manifest, no amd64
## image, config is not amd64, ...) with a clear message on stderr.
## Env: IMAGETOOLS overrides "docker buildx imagetools" (tests use a stub).
set -euo pipefail
IMAGETOOLS=${IMAGETOOLS:-docker buildx imagetools}
die() { echo "image-label-amd64: $*" >&2; exit 1; }
[ $# -ge 2 ] || die "usage: image-label-amd64.sh REF LABEL [LABEL...]"
ref=$1; shift
# Run an imagetools command; map "tag/manifest does not exist" to exit 3.
it() {
local out err rc=0
err=$(mktemp); trap 'rm -f "$err"' RETURN
# shellcheck disable=SC2086
out=$($IMAGETOOLS "$@" 2>"$err") || rc=$?
if [ "$rc" -ne 0 ]; then
if grep -qiE 'not found|manifest unknown|name unknown|: 404' "$err"; then
echo "image-label-amd64: $ref: not found ($(head -c 300 "$err" | tr '\n' ' '))" >&2
return 3
fi
echo "image-label-amd64: imagetools $1 failed (rc=$rc): $(head -c 300 "$err" | tr '\n' ' ')" >&2
return 1
fi
printf '%s' "$out"
}
rc=0; raw=$(it inspect --raw "$ref") || rc=$?
[ "$rc" -eq 0 ] || exit "$rc"
# Classify and, for an index, pick the single linux/amd64 child digest.
rc=0
verdict=$(printf '%s' "$raw" | python3 -I -c '
import json, sys
try:
d = json.load(sys.stdin)
except Exception as e:
print("ERR not JSON: %s" % e); sys.exit(0)
if not isinstance(d, dict):
print("ERR manifest is not a JSON object"); sys.exit(0)
mt = d.get("mediaType", "")
if isinstance(d.get("manifests"), list):
kids = [m for m in d["manifests"] if isinstance(m, dict)
and isinstance(m.get("platform"), dict)
and m["platform"].get("os") == "linux"
and m["platform"].get("architecture") == "amd64"
and "vnd.docker.reference.type" not in (m.get("annotations") or {})]
digs = [m.get("digest", "") for m in kids]
if len(digs) != 1:
print("ERR index has %d linux/amd64 images (need exactly 1)" % len(digs)); sys.exit(0)
if not digs[0].startswith("sha256:") or len(digs[0]) != 71:
print("ERR malformed amd64 child digest %r" % digs[0]); sys.exit(0)
print("INDEX " + digs[0])
elif isinstance(d.get("config"), dict) and isinstance(d.get("layers"), list):
print("SINGLE")
else:
print("ERR neither an image index nor an image manifest (mediaType=%r)" % mt)
') || rc=$?
[ "$rc" -eq 0 ] || die "could not parse manifest of $ref"
case "$verdict" in
ERR*) die "$ref: ${verdict#ERR }" ;;
SINGLE) target=$ref ;;
INDEX\ *)
base=${ref%%@*}
last=${base##*/}
[[ $last == *:* ]] && base=${base%:"${last#*:}"}
target="$base@${verdict#INDEX }" ;;
*) die "$ref: unexpected parser output" ;;
esac
rc=0; cfg=$(it inspect "$target" --format '{{json .Image}}') || rc=$?
[ "$rc" -eq 0 ] || { [ "$rc" -eq 3 ] && die "$target: not found although listed by the index"; exit "$rc"; }
printf '%s' "$cfg" | python3 -I -c '
import json, sys
try:
c = json.load(sys.stdin)
except Exception as e:
sys.stderr.write("image-label-amd64: image config is not JSON: %s\n" % e); sys.exit(1)
if not isinstance(c, dict) or c.get("architecture") != "amd64":
sys.stderr.write("image-label-amd64: image config is not linux/amd64 (architecture=%r)\n" % (c.get("architecture") if isinstance(c, dict) else None)); sys.exit(1)
cfg = c.get("config") or {}
labels = cfg.get("Labels") or {}
if not isinstance(labels, dict):
sys.stderr.write("image-label-amd64: Labels is not an object\n"); sys.exit(1)
for name in sys.argv[1:]:
v = labels.get(name, "")
print(v if isinstance(v, str) else "")
' "$@"
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
## index-platforms.sh REF
## Prints "index <os/arch> ..." (real platforms only, attestation children
## excluded) when REF is an image index / manifest list, or "single" when it is
## a plain single-platform manifest. Exit 3 = REF not found, 1 = any other
## failure (fail closed). Used by lsphp-source-emergency.yaml to refuse to
## replace a multi-arch tag with an amd64-only one.
## Env: IMAGETOOLS overrides "docker buildx imagetools" (tests use a stub).
set -euo pipefail
IMAGETOOLS=${IMAGETOOLS:-docker buildx imagetools}
ref=${1:?usage: index-platforms.sh REF}
err=$(mktemp); trap 'rm -f "$err"' EXIT
rc=0
# shellcheck disable=SC2086
raw=$($IMAGETOOLS inspect --raw "$ref" 2>"$err") || rc=$?
if [ "$rc" -ne 0 ]; then
if grep -qiE 'not found|manifest unknown|name unknown|: 404' "$err"; then echo "index-platforms: $ref not found" >&2; exit 3; fi
echo "index-platforms: imagetools failed: $(head -c 300 "$err" | tr '\n' ' ')" >&2; exit 1
fi
printf '%s' "$raw" | python3 -I -c '
import json, sys
try:
d = json.load(sys.stdin)
except Exception as e:
sys.stderr.write("index-platforms: not JSON: %s\n" % e); sys.exit(1)
if isinstance(d, dict) and isinstance(d.get("manifests"), list):
ps = []
for m in d["manifests"]:
p = m.get("platform") if isinstance(m, dict) else None
if not isinstance(p, dict) or "vnd.docker.reference.type" in (m.get("annotations") or {}):
continue
if p.get("os") in (None, "", "unknown") or p.get("architecture") in (None, "", "unknown"):
continue
ps.append("%s/%s" % (p["os"], p["architecture"]))
print("index " + " ".join(sorted(set(ps))))
elif isinstance(d, dict) and isinstance(d.get("config"), dict):
print("single")
else:
sys.stderr.write("index-platforms: neither index nor image manifest\n"); sys.exit(1)
'
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# PHP 8.6 (Remi EL10 modular php:remi-8.6). Same package set as install-php85.sh.
# php-pecl-geoip is provided on 8.6 by Remi's maintained fork php-rlerdorf-geoip.
# Fails loudly (set -e) instead of the older scripts' "exit 0".
set -euo pipefail
dnf module enable php:remi-8.6 -y
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
php-mysqlnd php-mbstring php-intl php-gd php-pgsql libzip php-cli
# A silently missing extension must fail the build, not ship.
loaded=$(php -m)
for ext in mysqlnd gd intl soap sodium zip mbstring xml pgsql redis memcached memcache imagick ip2location xmlrpc geoip; do
grep -qix "$ext" <<<"$loaded" || { echo "FATAL: PHP 8.6 extension '$ext' not loaded" >&2; exit 1; }
done
exit 0
+13 -2
View File
@@ -18,7 +18,8 @@
## Fails LOUDLY — never ships the base image's PHP by accident: ## Fails LOUDLY — never ships the base image's PHP by accident:
## * `apt-get update --error-on=any`: plain `apt-get update` only WARNS when a ## * `apt-get update --error-on=any`: plain `apt-get update` only WARNS when a
## repo is unreachable and carries on with no/old lists, exit 0. ## repo is unreachable and carries on with no/old lists, exit 0.
## * the LiteSpeed repo must be the candidate source for lsphp${PHPVER}. ## * the LiteSpeed repo must be the candidate source for lsphp${PHPVER}
## (rpms.litespeedtech.com, or ${PKG_CACHE}/litespeed/ when PKG_CACHE is set).
## * after upgrading, no lsphp${PHPVER}* package may remain upgradable. ## * after upgrading, no lsphp${PHPVER}* package may remain upgradable.
## * if CI passed the version it resolved from the repo index (EXPECT_LSPHP_PKG, ## * if CI passed the version it resolved from the repo index (EXPECT_LSPHP_PKG,
## EXPECT_PHP_VERSION), the installed package / running PHP must match it; ## EXPECT_PHP_VERSION), the installed package / running PHP must match it;
@@ -52,8 +53,18 @@ echo "lsphp-apt-upgrade: base image lsphp${PHPVER}=$(dpkg-query -W -f='${Version
# Read each output into a variable and match in the shell: piping into an # Read each output into a variable and match in the shell: piping into an
# early-exit reader (grep -q, awk ... exit) under pipefail can SIGPIPE the writer # early-exit reader (grep -q, awk ... exit) under pipefail can SIGPIPE the writer
# and report "missing" for a package that is there (scripts/tests/lsphp-info-probe.test.sh). # and report "missing" for a package that is there (scripts/tests/lsphp-info-probe.test.sh).
# With the internal package cache (PKG_CACHE build-arg, scripts/pkg-cache-repos.sh
# apt) the LiteSpeed source reads ${PKG_CACHE}/litespeed/... instead; that URL is
# accepted ONLY when PKG_CACHE is set, and only under its /litespeed/ path.
MADISON=$(apt-cache madison "lsphp${PHPVER}") MADISON=$(apt-cache madison "lsphp${PHPVER}")
if [[ "$MADISON" != *rpms.litespeedtech.com* ]]; then LS_REPO_OK=0
if [[ "$MADISON" == *rpms.litespeedtech.com* ]]; then
LS_REPO_OK=1
elif [ -n "${PKG_CACHE:-}" ] && [[ "$MADISON" == *"${PKG_CACHE%/}/litespeed/"* ]]; then
LS_REPO_OK=1
echo "lsphp-apt-upgrade: LiteSpeed repo via package cache ${PKG_CACHE%/}/litespeed/"
fi
if [ "$LS_REPO_OK" != 1 ]; then
apt-cache policy "lsphp${PHPVER}" >&2 || true apt-cache policy "lsphp${PHPVER}" >&2 || true
die "the LiteSpeed apt repo does not offer lsphp${PHPVER} (repo missing from sources, or its index is empty)." die "the LiteSpeed apt repo does not offer lsphp${PHPVER} (repo missing from sources, or its index is empty)."
fi fi
+59
View File
@@ -0,0 +1,59 @@
#!/bin/bash
## lsphp-pin-resolve.sh — BUILD-TIME ONLY. Run (Dockerfile RUN is dash, so this is
## a bash executable) or source it:
## lsphp-pin-resolve.sh resolve PKG WANT # prints the version to pin PKG at
## lsphp-pin-resolve.sh ok INSTALLED WANT # exit 0 if INSTALLED is an acceptable pin
##
## Why: stage 2 of Dockerfile.lsphp pins lsphpNN, lsphpNN-common and
## lsphpNN-ldap to the ONE version ext-build compiled against. LiteSpeed's repo
## is occasionally published inconsistently (2026-11-19: lsphp84 8.4.27-2+noble
## but lsphp84-common 8.4.27-3+noble only), so a single shared pin makes apt say
## "Version '8.4.27-2+noble' for 'lsphp84-common' was not found".
##
## Rule (fail closed, nothing weakened):
## 1. WANT itself is offered for PKG -> WANT (the normal case; 82/83/85).
## 2. else the highest version that has the SAME upstream PHP version (the
## text before the first '-') and the same distro suffix (after '+') as
## WANT and is >= WANT (a packaging-revision bump; every lsphp package
## Depends on -common only as ">= WANT", so >= is always satisfiable).
## 3. else exit 1 — a different PHP release is never silently substituted.
## The caller still asserts lsphpNN (the binary the extension was built for)
## equals WANT exactly and -common has the same upstream version and is >= WANT.
##
## LSPHP_MADISON_CMD (default "apt-cache madison") is overridable for tests.
lsphp_resolve_pin() {
local pkg="$1" want="$2" cmd="${LSPHP_MADISON_CMD:-apt-cache madison}"
local out v best="" up="${want%%-*}" suf=""
[[ "$want" == *+* ]] && suf="+${want#*+}"
out=$($cmd "$pkg") || { echo "lsphp-pin-resolve: '$cmd $pkg' failed" >&2; return 1; }
while read -r v; do
[ -n "$v" ] || continue
if [ "$v" = "$want" ]; then printf '%s\n' "$want"; return 0; fi
[ "${v%%-*}" = "$up" ] || continue
[ "$suf" = "" ] || [[ "$v" == *"$suf" ]] || continue
dpkg --compare-versions "$v" ge "$want" || continue
if [ -z "$best" ] || dpkg --compare-versions "$v" gt "$best"; then best="$v"; fi
done < <(awk -F'|' '{gsub(/ /,"",$2); print $2}' <<<"$out")
if [ -z "$best" ]; then
echo "lsphp-pin-resolve: $pkg offers no version of PHP $up compatible with $want" >&2
return 1
fi
printf '%s\n' "$best"
}
## lsphp_pin_ok INSTALLED WANT — post-install assertion for the -common/-ldap
## packages: same upstream PHP version as WANT and not older than it.
lsphp_pin_ok() {
local inst="$1" want="$2"
[ "${inst%%-*}" = "${want%%-*}" ] && dpkg --compare-versions "$inst" ge "$want"
}
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
set -u
case "${1:-}" in
resolve) lsphp_resolve_pin "${2:?pkg}" "${3:?want}" ;;
ok) lsphp_pin_ok "${2:?installed}" "${3:?want}" ;;
*) echo "usage: $0 resolve PKG WANT | ok INSTALLED WANT" >&2; exit 2 ;;
esac
fi
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
## lsphp-repo-version.sh PHPVER [ARCH] — print the newest lsphpPHPVER package
## version in LiteSpeed's noble apt index for ARCH (amd64 | arm64; default
## $LSPHP_ARCH, else amd64, so callers that pass nothing behave as before).
## The awk/sort pipeline is byte-for-byte the one that used to be inlined in
## build-push.yaml and lsphp-source-emergency.yaml.
## Test hook: LSPHP_INDEX_FILE=<path> reads that Packages file instead of curl.
## Exit 1 (message on stderr) if the arch is unknown or the package is absent.
set -euo pipefail
phpver="${1:?usage: lsphp-repo-version.sh PHPVER [ARCH]}"
arch="${2:-${LSPHP_ARCH:-amd64}}"
case "$arch" in amd64|arm64) ;; *) echo "unsupported lsphp arch '$arch' (amd64|arm64)" >&2; exit 1 ;; esac
[[ "$phpver" =~ ^[0-9]+$ ]] || { echo "malformed PHPVER '$phpver'" >&2; exit 1; }
if [ -n "${LSPHP_INDEX_FILE:-}" ]; then
idx=$(cat "$LSPHP_INDEX_FILE")
else
idx=$(curl -fsS --proto '=https' --retry 3 --max-time 60 "https://rpms.litespeedtech.com/debian/dists/noble/main/binary-${arch}/Packages")
fi
printf '%s\n' "$idx" | awk -v p="lsphp${phpver}" '/^Package: /{n=$2} /^Version: / && n==p {print $2}' | sort -V | tail -n1
+15
View File
@@ -173,6 +173,21 @@ if [ -n "$PKG_SAVE_PATH" ]; then
log "compiled-in session.save_path default set to '$PKG_SAVE_PATH' (as the packaged lsphp${PHPVER})" log "compiled-in session.save_path default set to '$PKG_SAVE_PATH' (as the packaged lsphp${PHPVER})"
fi fi
## Measured 2026-11-19 (emergency from-source run 5683, all 4 versions): the
## packaged lsphp82-85 report session.upload_progress.enabled='1' under `php -n`;
## php.net's source default is "0" (the value sits on the line AFTER the name in
## ext/session/session.c). That was the ONLY difference the 4b gate listed. Follow
## the packaged binary; per-site php.ini hardening can still turn it off.
PKG_UP=$("$P/bin/php" -n -r 'echo ini_get("session.upload_progress.enabled");')
if [ "$PKG_UP" = "1" ]; then
sed -i -E '/STD_PHP_INI_BOOLEAN\("session\.upload_progress\.enabled",/{n;s/"0"/"1"/}' "$SRC/ext/session/session.c"
grep -A1 -F '"session.upload_progress.enabled"' "$SRC/ext/session/session.c" | grep -F '"1"' >/dev/null \
|| die "could not apply the packaged session.upload_progress.enabled default '1' to ext/session/session.c (source layout changed?)."
log "compiled-in session.upload_progress.enabled default set to '1' (as the packaged lsphp${PHPVER})"
elif [ "$PKG_UP" != "0" ]; then
die "unexpected packaged session.upload_progress.enabled default '$PKG_UP'."
fi
## ---- 3. replay the packaged configure line ----------------------------------- ## ---- 3. replay the packaged configure line -----------------------------------
CFG_LINE=$("$P/bin/php" -i | awk -F' => ' '$1 == "Configure Command " || $1 == "Configure Command" {sub(/^[^=]*=> /, ""); print}') CFG_LINE=$("$P/bin/php" -i | awk -F' => ' '$1 == "Configure Command " || $1 == "Configure Command" {sub(/^[^=]*=> /, ""); print}')
[ -n "$CFG_LINE" ] || die "could not read 'Configure Command' from the packaged $P/bin/php -i." [ -n "$CFG_LINE" ] || die "could not read 'Configure Command' from the packaged $P/bin/php -i."
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
## php-emergency-guard.sh REF NEW_PHP
##
## "Do not roll back a newer php.net emergency image." REF is the published
## :phpNN tag a normal build is about to overwrite; NEW_PHP is the PHP version
## the normal build packages. Exit 0 = go ahead, 1 = refuse (or cannot tell).
##
## Decision (same predicate as the old inline step, evaluated on the amd64
## image only, so it is correct for a single-platform image AND a multi-arch
## index):
## REF does not exist yet (registry "not found") -> proceed (nothing to protect)
## labels read, source != php.net -> proceed
## labels read, source = php.net, cur == new -> proceed
## labels read, source = php.net, cur > new (sort -V) -> REFUSE
## labels read, source = php.net, cur < new -> proceed
## labels absent (older image without them) -> proceed (as before)
## ANYTHING ELSE (registry/auth/network error, malformed manifest, index
## without exactly one linux/amd64 image, non-amd64 config) -> REFUSE
## (FAIL CLOSED; the old step failed open and silently disabled the guard).
## Env: LABEL_SCRIPT (tests), IMAGETOOLS passed through.
set -euo pipefail
ref=${1:?usage: php-emergency-guard.sh REF NEW_PHP}
new=${2-}
here=$(cd "$(dirname "$0")" && pwd)
labeler=${LABEL_SCRIPT:-$here/image-label-amd64.sh}
rc=0
out=$("$labeler" "$ref" org.whp.lsphp-source org.whp.php-version) || rc=$?
if [ "$rc" -eq 3 ]; then
echo "published $ref: not found (first build); this build: packaged $new. Nothing to protect."
exit 0
fi
if [ "$rc" -ne 0 ]; then
echo "::error::cannot read the php.net-emergency labels of the amd64 image behind $ref (rc=$rc). Refusing to overwrite it blind (fail closed). Retry the run; if it persists check registry access and the manifest."
exit 1
fi
src=$(printf '%s\n' "$out" | sed -n 1p)
cur=$(printf '%s\n' "$out" | sed -n 2p)
echo "published $ref (amd64): source=${src:-?} php=${cur:-?}; this build: packaged $new"
if [ "$src" = "php.net" ] && [ "$cur" != "$new" ] && [ "$(printf '%s\n%s\n' "$cur" "$new" | sort -V | tail -n1)" = "$cur" ]; then
echo "::error::$ref is a php.net emergency build of PHP $cur; LiteSpeed still ships $new. Not overwriting it with an older PHP. Re-run lsphp-source-emergency.yaml for a newer fix, or wait for LiteSpeed."
exit 1
fi
exit 0
+90 -17
View File
@@ -4,11 +4,16 @@
## when PKG_CACHE is set; without it the repo files are left alone and builds ## when PKG_CACHE is set; without it the repo files are left alone and builds
## use the upstream repositories as before. ## use the upstream repositories as before.
## ##
## PKG_CACHE=https://192.168.1.40 pkg-cache-repos.sh rpm # AlmaLinux/EPEL/Remi ## PKG_CACHE=https://192.168.1.40 pkg-cache-repos.sh rpm # AlmaLinux/EPEL/Remi/NodeSource
## PKG_CACHE=https://192.168.1.40 pkg-cache-repos.sh apt # Ubuntu + LiteSpeed ## PKG_CACHE=https://192.168.1.40 pkg-cache-repos.sh apt # Ubuntu, Debian, LiteSpeed
## pkg-cache-repos.sh release-install epel [remi] # GPG-verified release RPMs ## pkg-cache-repos.sh release-install epel [remi] # GPG-verified release RPMs (EL9/EL10)
## pkg-cache-repos.sh nodesource MAJOR # NodeSource repo file + pinned key
## eval "$(pkg-cache-repos.sh go-env)" # GOPROXY via the cache (go.sum/sumdb verified)
## pkg-cache-repos.sh restore # undo everything above ## pkg-cache-repos.sh restore # undo everything above
## ##
## CANONICAL copy: cloud-apache-container/scripts/pkg-cache-repos.sh (docs/pkg-cache.md
## there). Other repos carry byte-identical copies - change it there first.
##
## Every RUN that rewrites must `restore` before it ends: it puts rewritten files ## Every RUN that rewrites must `restore` before it ends: it puts rewritten files
## back, deletes files this script created, deletes any NEW repo/apt file that ## back, deletes files this script created, deletes any NEW repo/apt file that
## still references the cache, then FAILS if any reference is left — so no shipped ## still references the cache, then FAILS if any reference is left — so no shipped
@@ -43,7 +48,7 @@
## cache (with the CA), and a build without PKG_CACHE uses upstream sources. ## cache (with the CA), and a build without PKG_CACHE uses upstream sources.
set -euo pipefail set -euo pipefail
MODE="${1:?usage: pkg-cache-repos.sh rpm|apt|release-install NAME...|restore}" MODE="${1:?usage: pkg-cache-repos.sh rpm|apt|release-install NAME...|nodesource MAJOR|go-env|restore}"
shift || true shift || true
STATE=/var/lib/pkg-cache-repos # saved originals + manifest + created files STATE=/var/lib/pkg-cache-repos # saved originals + manifest + created files
SHARE="${PKG_CACHE_SHARE:-/usr/local/share/pkg-cache}" # ca.crt + RPM-GPG-KEY-* SHARE="${PKG_CACHE_SHARE:-/usr/local/share/pkg-cache}" # ca.crt + RPM-GPG-KEY-*
@@ -57,10 +62,22 @@ if [ -n "$C" ]; then
https://*) ;; https://*) ;;
*) die "PKG_CACHE must be an https:// URL (plain http is refused), got '$C'" ;; *) die "PKG_CACHE must be an https:// URL (plain http is refused), got '$C'" ;;
esac esac
[[ "$C" =~ ^https://[A-Za-z0-9.-]+(:[0-9]+)?(/[A-Za-z0-9._/-]*)?$ ]] || die "PKG_CACHE has unexpected characters: '$C'"
HOSTPORT="${C#https://}"; HOSTPORT="${HOSTPORT%%/*}" HOSTPORT="${C#https://}"; HOSTPORT="${HOSTPORT%%/*}"
[ -s "$SHARE/ca.crt" ] || die "PKG_CACHE set but $SHARE/ca.crt (pkg-cache CA) is missing" [ -s "$SHARE/ca.crt" ] || die "PKG_CACHE set but $SHARE/ca.crt (pkg-cache CA) is missing"
fi fi
# System CA bundle (EL vs Debian/Ubuntu path); the pkg-cache CA is appended to a
# copy in the state dir, never to the system store.
sys_bundle() {
local b
for b in /etc/pki/tls/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt; do
[ -s "$b" ] && { echo "$b"; return 0; }
done
die "no system CA bundle found"
}
make_bundle() { cat "$(sys_bundle)" "$SHARE/ca.crt" > "$STATE/ca-bundle.pem"; }
# Files that may hold repo configuration; restore re-checks all of them. # Files that may hold repo configuration; restore re-checks all of them.
repo_files() { repo_files() {
find /etc/yum.repos.d /etc/dnf /etc/apt -type f 2>/dev/null | sort || true find /etc/yum.repos.d /etc/dnf /etc/apt -type f 2>/dev/null | sort || true
@@ -83,13 +100,17 @@ created() { printf '%s\n' "$1" >> "$STATE/created"; }
if [ "$MODE" = restore ]; then if [ "$MODE" = restore ]; then
[ -d "$STATE" ] || exit 0 [ -d "$STATE" ] || exit 0
host=$(cat "$STATE/host") host=$(cat "$STATE/host")
(cd "$STATE/orig" && find . -type f) | while read -r rel; do # mapfile from a process substitution, not `cmd | while read`: no pipeline,
# so nothing for pipefail to misreport (scripts/tests/lsphp-info-probe.test.sh).
mapfile -t saved < <(cd "$STATE/orig" && find . -type f)
for rel in "${saved[@]}"; do
cat "$STATE/orig/$rel" > "/${rel#./}" cat "$STATE/orig/$rel" > "/${rel#./}"
done done
while read -r f; do [ -n "$f" ] && rm -f -- "$f"; done < "$STATE/created" while read -r f; do [ -n "$f" ] && rm -f -- "$f"; done < "$STATE/created"
# A repo/apt file that appeared during this RUN and still names the cache # A repo/apt file that appeared during this RUN and still names the cache
# (e.g. written by a package from the rewritten repos) is removed too. # (e.g. written by a package from the rewritten repos) is removed too.
repo_files | while read -r f; do mapfile -t current < <(repo_files)
for f in "${current[@]}"; do
if ! grep -qxF -- "$f" "$STATE/manifest" && grep -qF -- "$host" "$f"; then if ! grep -qxF -- "$f" "$STATE/manifest" && grep -qF -- "$host" "$f"; then
echo "pkg-cache-repos: removing new file that references the cache: $f" echo "pkg-cache-repos: removing new file that references the cache: $f"
rm -f -- "$f" rm -f -- "$f"
@@ -108,18 +129,20 @@ if [ "$MODE" = release-install ]; then
curl_opts=(-fsS --proto '=https' --retry 5 --retry-all-errors --max-time 120) curl_opts=(-fsS --proto '=https' --retry 5 --retry-all-errors --max-time 120)
if [ -n "$C" ]; then if [ -n "$C" ]; then
start_session start_session
cat /etc/pki/tls/certs/ca-bundle.crt "$SHARE/ca.crt" > "$STATE/ca-bundle.pem" make_bundle
curl_opts+=(--cacert "$STATE/ca-bundle.pem") curl_opts+=(--cacert "$STATE/ca-bundle.pem")
fi fi
files=() files=()
el=$(rpm -E '%{?rhel}' 2>/dev/null || true)
case "$el" in 9|10) ;; *) die "release-install supports EL9/EL10 only (rpm -E %rhel = '$el')" ;; esac
for name in "$@"; do for name in "$@"; do
case "$name" in case "$name" in
epel) pkg=epel-release key=RPM-GPG-KEY-EPEL-10 epel) pkg=epel-release key=RPM-GPG-KEY-EPEL-$el
path=/epel/epel-release-latest-10.noarch.rpm path=/epel/epel-release-latest-$el.noarch.rpm
origin=https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm ;; origin=https://dl.fedoraproject.org/pub/epel/epel-release-latest-$el.noarch.rpm ;;
remi) pkg=remi-release key=RPM-GPG-KEY-remi2024 remi) pkg=remi-release key=RPM-GPG-KEY-remi2024
path=/remi/enterprise/remi-release-10.rpm path=/remi/enterprise/remi-release-$el.rpm
origin=https://rpms.remirepo.net/enterprise/remi-release-10.rpm ;; origin=https://rpms.remirepo.net/enterprise/remi-release-$el.rpm ;;
*) die "unknown release package '$name'" ;; *) die "unknown release package '$name'" ;;
esac esac
url="$origin"; [ -n "$C" ] && url="$C$path" url="$origin"; [ -n "$C" ] && url="$C$path"
@@ -138,14 +161,14 @@ if [ "$MODE" = release-install ]; then
exit 0 exit 0
fi fi
if [ -z "$C" ]; then if [ -z "$C" ] && [ "$MODE" != nodesource ] && [ "$MODE" != go-env ]; then
echo "pkg-cache-repos($MODE): PKG_CACHE not set - using upstream repositories" echo "pkg-cache-repos($MODE): PKG_CACHE not set - using upstream repositories"
exit 0 exit 0
fi fi
rewrite_rpm() { rewrite_rpm() {
local f="$1" local f="$1"
grep -q -E '^#? ?baseurl=https?://(repo\.almalinux\.org|download\.example|rpms\.remirepo\.net)/' "$f" || return 0 grep -q -E '^#? ?baseurl=https?://(repo\.almalinux\.org|download\.example|rpms\.remirepo\.net|rpm\.nodesource\.com)/' "$f" || return 0
save "$f" save "$f"
# Per [section]: a (commented or live) baseurl on a known origin becomes # Per [section]: a (commented or live) baseurl on a known origin becomes
# "baseurl=<cache>/<prefix>/<path> <origin>/<path>"; that section's # "baseurl=<cache>/<prefix>/<path> <origin>/<path>"; that section's
@@ -181,6 +204,8 @@ rewrite_rpm() {
l = rw(l, "^#? ?baseurl=https?://repo\\.almalinux\\.org/almalinux/", "almalinux", "https://repo.almalinux.org/almalinux", 1) l = rw(l, "^#? ?baseurl=https?://repo\\.almalinux\\.org/almalinux/", "almalinux", "https://repo.almalinux.org/almalinux", 1)
l = rw(l, "^#? ?baseurl=https?://download\\.example/pub/epel/", "epel", "https://dl.fedoraproject.org/pub/epel", 0) l = rw(l, "^#? ?baseurl=https?://download\\.example/pub/epel/", "epel", "https://dl.fedoraproject.org/pub/epel", 0)
l = rw(l, "^#? ?baseurl=https?://rpms\\.remirepo\\.net/", "remi", "https://rpms.remirepo.net", 1) l = rw(l, "^#? ?baseurl=https?://rpms\\.remirepo\\.net/", "remi", "https://rpms.remirepo.net", 1)
# NodeSource signs its RPMs but not repomd.xml (404): gpgcheck only.
l = rw(l, "^#? ?baseurl=https?://rpm\\.nodesource\\.com/", "nodesource", "https://rpm.nodesource.com", 0)
} }
buf[++n] = l buf[++n] = l
} }
@@ -190,19 +215,65 @@ rewrite_rpm() {
rewrite_apt() { rewrite_apt() {
local f="$1" local f="$1"
grep -q -E 'https?://([a-z]{2}\.)?(archive|security)\.ubuntu\.com/|https?://rpms\.litespeedtech\.com/' "$f" || return 0 grep -q -E 'https?://([a-z]{2}\.)?(archive|security)\.ubuntu\.com/|https?://rpms\.litespeedtech\.com/|https?://(deb|security)\.debian\.org/' "$f" || return 0
save "$f" save "$f"
# Debian: debian-security first, and "debian" only as a whole path segment,
# so .../debian-security is never rewritten as /debian/.
sed -i -E \ sed -i -E \
-e "s%https?://(archive|[a-z]{2}\.archive)\.ubuntu\.com/ubuntu/?%$C/ubuntu/%g" \ -e "s%https?://(archive|[a-z]{2}\.archive)\.ubuntu\.com/ubuntu/?%$C/ubuntu/%g" \
-e "s%https?://security\.ubuntu\.com/ubuntu/?%$C/ubuntu-security/%g" \ -e "s%https?://security\.ubuntu\.com/ubuntu/?%$C/ubuntu-security/%g" \
-e "s%https?://rpms\.litespeedtech\.com/%$C/litespeed/%g" \ -e "s%https?://rpms\.litespeedtech\.com/%$C/litespeed/%g" \
-e "s%https?://(deb|security)\.debian\.org/debian-security/?([[:space:]]|\$)%$C/debian-security/\\2%g" \
-e "s%https?://security\.debian\.org/?([[:space:]]|\$)%$C/debian-security/\\1%g" \
-e "s%https?://deb\.debian\.org/debian/?([[:space:]]|\$)%$C/debian/\\1%g" \
"$f" "$f"
} }
if [ "$MODE" = go-env ]; then
# Prints shell exports for `eval`. Without PKG_CACHE: nothing (Go defaults).
# GOPROXY "a|b" falls through on ANY error, so a dead cache costs one
# failed request, not the build. GOSUMDB stays the default sum.golang.org,
# reached directly: modules are still verified against go.sum + the sumdb.
[ -n "$C" ] || { echo "pkg-cache-repos(go-env): PKG_CACHE not set - default GOPROXY" >&2; exit 0; }
start_session
make_bundle
printf "export GOPROXY='%s/goproxy|https://proxy.golang.org|direct' SSL_CERT_FILE='%s'\n" "$C" "$STATE/ca-bundle.pem"
echo "pkg-cache-repos(go-env): GOPROXY via $C/goproxy (fallback proxy.golang.org)" >&2
exit 0
fi
if [ "$MODE" = nodesource ]; then
# Replaces `curl https://rpm.nodesource.com/setup_N.x | bash` (unverified
# remote script): writes the same nodesource-nodejs repo (origin URL, so the
# shipped image keeps a normal repo file) with gpgcheck=1 and the signing key
# committed in keys/pkg-cache/; with PKG_CACHE it is then rewritten like any
# other repo and `restore` puts the origin version back.
major="${1:?usage: pkg-cache-repos.sh nodesource MAJOR}"
[[ "$major" =~ ^[0-9]{1,3}$ ]] || die "bad Node major '$major'"
key="$SHARE/RPM-GPG-KEY-nodesource"
[ -s "$key" ] || die "missing $key"
rpm --import "$key" || die "cannot import $key"
rm -f /etc/yum.repos.d/nodesource*.repo
f=/etc/yum.repos.d/nodesource-nodejs.repo
printf '%s\n' "[nodesource-nodejs]" \
"name=Node.js Packages for Linux RPM based distros - \$basearch" \
"baseurl=https://rpm.nodesource.com/pub_${major}.x/nodistro/nodejs/\$basearch" \
"priority=9" "enabled=1" "gpgcheck=1" \
"gpgkey=file://$key" "module_hotfixes=1" > "$f"
echo "pkg-cache-repos: wrote $f (Node ${major}.x, key $(basename "$key"))"
if [ -n "$C" ]; then
start_session
make_bundle
rewrite_rpm "$f"
grep -h '^baseurl=' "$f" | sed 's/^/ /'
fi
exit 0
fi
case "$MODE" in case "$MODE" in
rpm) rpm)
start_session start_session
cat /etc/pki/tls/certs/ca-bundle.crt "$SHARE/ca.crt" > "$STATE/ca-bundle.pem" make_bundle
for f in /etc/yum.repos.d/*.repo; do [ -f "$f" ] && rewrite_rpm "$f"; done for f in /etc/yum.repos.d/*.repo; do [ -f "$f" ] && rewrite_rpm "$f"; done
echo "pkg-cache-repos(rpm): repos now via $C:" echo "pkg-cache-repos(rpm): repos now via $C:"
grep -h '^baseurl=' /etc/yum.repos.d/*.repo | grep -F "$C/" | sort -u | sed 's/^/ /' grep -h '^baseurl=' /etc/yum.repos.d/*.repo | grep -F "$C/" | sort -u | sed 's/^/ /'
@@ -217,7 +288,9 @@ case "$MODE" in
[ -f "$f" ] && rewrite_apt "$f" [ -f "$f" ] && rewrite_apt "$f"
done done
echo "pkg-cache-repos(apt): sources now via $C:" echo "pkg-cache-repos(apt): sources now via $C:"
grep -h -E '^(deb|URIs:)' /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null | grep -F "$C/" | sort -u | sed 's/^/ /' # (|| true: Debian 13 images have no /etc/apt/sources.list; grep's exit 2
# for the missing file must not fail the build under pipefail)
{ grep -h -E '^(deb|URIs:)' /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null || true; } | grep -F "$C/" | sort -u | sed 's/^/ /' || true
;; ;;
*) die "unknown mode '$MODE'" ;; *) die "unknown mode '$MODE'" ;;
esac esac
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
## assemble-guard.test.sh - --guard-existing-arm64 and --verify-bin of scripts/assemble-multiarch-index.sh
## against a stub IMAGETOOLS (registry state in files) and a stub ELF verifier.
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
fail=0
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
d() { local c=$1; printf 'sha256:'; printf "$c%.0s" {1..64}; }
A=$(d a); B=$(d b); R=reg/x
cat >"$T/it" <<'STUB'
#!/usr/bin/env bash
# create -> logged. inspect --raw REF -> $FIX/<ref with /:@ as _> (err_ prefix = failure text).
# inspect REF --format .. -> architecture from $ARCHES (ref=arch lines).
if [ "$1" = create ]; then echo "create $*" >>"$LOG"; exit 0; fi
if [ "$2" = --raw ]; then
k=$(printf '%s' "$3" | tr '/:@' '___')
if [ -f "$FIX/err_$k" ]; then cat "$FIX/err_$k" >&2; exit 1; fi
[ -f "$FIX/$k" ] || { echo "ERROR: $3: not found" >&2; exit 1; }
cat "$FIX/$k"; exit 0
fi
a=$(grep -F -m1 "$2=" "$ARCHES" | cut -d= -f2); [ -n "$a" ] || exit 1
printf '{"architecture":"%s"}' "$a"
STUB
cat >"$T/ver" <<'STUB'
#!/usr/bin/env bash
echo "verify $*" >>"$LOG"
case "$*" in *linux/arm64*) [ "${FAIL_ARM:-0}" = 1 ] && exit 1 ;; *linux/amd64*) [ "${FAIL_AMD:-0}" = 1 ] && exit 1 ;; esac
exit 0
STUB
chmod +x "$T/it" "$T/ver"
export IMAGETOOLS="$T/it" VERIFY_ARCH="$T/ver" FIX=$T LOG=$T/log ARCHES=$T/arches
printf '%s\n' "$R@$A=amd64" "$R@$B=arm64" >"$ARCHES"
w() { printf '%s' "$2" >"$T/$(printf '%s' "$1" | tr '/:@' '___')"; }
MULTI='{"manifests":[{"digest":"x","platform":{"os":"linux","architecture":"amd64"}},{"digest":"y","platform":{"os":"linux","architecture":"arm64"}}]}'
AMDONLY='{"manifests":[{"digest":"x","platform":{"os":"linux","architecture":"amd64"}}]}'
run() { : >"$LOG"; "$HERE/assemble-multiarch-index.sh" "$@" >"$T/out" 2>"$T/err"; echo $?; }
creates() { grep -c '^create' "$LOG" || true; }
base=(--amd64 "$A" --repo "$R" --tag php82)
w $R:php82 "$MULTI"
chk "amd64-only result over a multi-arch tag, guard on -> 1" "$(run "${base[@]}" --arm64-outcome failure --guard-existing-arm64)" 1
chk " nothing published" "$(creates)" 0
chk " error names the amd64 digest" "$(grep -c "$A" "$T/err")" 1
chk "arm64 leg skipped, guard on -> 1" "$(run "${base[@]}" --guard-existing-arm64)" 1
chk "ALLOW_AMD64_ONLY=true overrides -> 0" "$(ALLOW_AMD64_ONLY=true run "${base[@]}" --arm64-outcome failure --guard-existing-arm64)" 0
chk " amd64-only index created" "$(creates)" 1
chk "ALLOW_AMD64_ONLY=false does not override" "$(ALLOW_AMD64_ONLY=false run "${base[@]}" --arm64-outcome failure --guard-existing-arm64)" 1
chk "without --guard-existing-arm64 old behaviour (publish) -> 0" "$(run "${base[@]}" --arm64-outcome failure)" 0
chk "arm64 present in this build: guard irrelevant -> 0" "$(run "${base[@]}" --arm64 "$B" --arm64-outcome success --guard-existing-arm64)" 0
chk " 2 sources" "$(grep -c "$R@$A $R@$B\$" "$LOG")" 1
w $R:php82 "$AMDONLY"
chk "existing tag amd64-only, guard on -> 0" "$(run "${base[@]}" --arm64-outcome failure --guard-existing-arm64)" 0
rm -f "$T/reg_x_php82"
chk "tag not found (first publish) -> 0" "$(run "${base[@]}" --arm64-outcome failure --guard-existing-arm64)" 0
printf 'ERROR: denied\n' >"$T/err_reg_x_php82"
chk "tag unreadable -> fail closed 1" "$(run "${base[@]}" --arm64-outcome failure --guard-existing-arm64)" 1
chk " nothing published" "$(creates)" 0
rm -f "$T/err_reg_x_php82"
w $R:php82 "$AMDONLY"; w $R:latest "$MULTI"
chk "second tag multi-arch is caught too -> 1" "$(run --amd64 "$A" --repo $R --tag php82 --tag latest --arm64-outcome failure --guard-existing-arm64)" 1
chk " nothing published" "$(creates)" 0
# ---- ELF verification
w $R:php82 "$AMDONLY"
vb=(--verify-bin /usr/sbin/httpd --verify-bin /usr/bin/php)
chk "both verify -> 0, both platforms checked" "$(run "${base[@]}" --arm64 "$B" --arm64-outcome success "${vb[@]}")" 0
chk " amd64 and arm64 verified with both bins" "$(grep -c "^verify --image $R@$A --platform linux/amd64 --bin /usr/sbin/httpd --bin /usr/bin/php\$\|^verify --image $R@$B --platform linux/arm64 --bin /usr/sbin/httpd --bin /usr/bin/php\$" "$LOG")" 2
chk " arm64 index created" "$(grep -c "$R@$A $R@$B\$" "$LOG")" 1
chk "wrong amd64 -> refuse 1" "$(FAIL_AMD=1 run "${base[@]}" --arm64 "$B" --arm64-outcome success "${vb[@]}")" 1
chk " nothing published" "$(creates)" 0
chk "wrong arm64, tag amd64-only -> amd64-only publish 0" "$(FAIL_ARM=1 run "${base[@]}" --arm64 "$B" --arm64-outcome success "${vb[@]}" --guard-existing-arm64)" 0
chk " no arm64 digest in create" "$(grep -c "$B" <(grep '^create' "$LOG") || true)" 0
w $R:php82 "$MULTI"
chk "wrong arm64 over multi-arch tag, guard -> 1 (falls into guard)" "$(FAIL_ARM=1 run "${base[@]}" --arm64 "$B" --arm64-outcome success "${vb[@]}" --guard-existing-arm64)" 1
chk " nothing published" "$(creates)" 0
chk "arm64 failed: arm64 not verified at all" "$(run "${base[@]}" --arm64-outcome failure "${vb[@]}" >/dev/null; grep -c 'linux/arm64' "$LOG" || true)" 0
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo FAILURES; exit 1; }
+230
View File
@@ -0,0 +1,230 @@
#!/usr/bin/env bash
## attach-arm64-index.test.sh - scripts/attach-arm64-index.sh against a stateful stub IMAGETOOLS
## that models the registry (tags, digests, index flattening on `create`).
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
fail=0
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
d() { local c=$1; printf 'sha256:'; printf "$c%.0s" {1..64}; } # d a -> sha256:aaaa...
A=$(d a); AT=$(d e); B=$(d b); BT=$(d f); C=$(d c); OLD=$(d 1)
R=reg/cac
cat >"$T/stub.py" <<'PY'
import hashlib, json, os, sys
S = os.environ['STATE']
def load(n):
p = os.path.join(S, n)
return json.load(open(p)) if os.path.exists(p) else {}
def save(n, d):
json.dump(d, open(os.path.join(S, n), 'w'))
def dig(c):
return 'sha256:' + hashlib.sha256(json.dumps(c, sort_keys=True).encode()).hexdigest()
tags, blobs, arch = load('tags.json'), load('blobs.json'), load('arch.json')
args = sys.argv[1:]
with open(os.path.join(S, 'log'), 'a') as f:
f.write(' '.join(args) + '\n')
cmd = args[0]
rest = [a for i, a in enumerate(args[1:]) if a != '--builder' and (i == 0 or args[i] != '--builder')]
def resolve(ref):
if '@' in ref:
d = ref.split('@', 1)[1]
if d not in blobs: sys.exit(1)
return d, blobs[d]
if ref not in tags: sys.stderr.write('ERROR: %s: not found\n' % ref); sys.exit(1)
c = tags[ref]; return dig(c), c
if cmd == 'inspect':
raw = '--raw' in rest
ref = [a for a in rest if not a.startswith('--') and not a.startswith('{{')][0] if not raw else rest[rest.index('--raw') + 1]
if raw:
print(json.dumps(resolve(ref)[1]))
elif '{{.Manifest.Digest}}' in rest:
print(resolve(ref)[0])
elif '{{json .Image}}' in rest:
d, c = resolve(ref)
if d not in arch: sys.exit(1)
print(json.dumps({'architecture': arch[d]}))
elif cmd == 'create':
ts = []; srcs = []; i = 0
while i < len(rest):
if rest[i] == '-t': ts.append(rest[i + 1]); i += 2
else: srcs.append(rest[i]); i += 1
ms = []
for s in srcs:
d, c = resolve(s)
if 'manifests' in c: ms.extend(c['manifests'])
else: ms.append({'digest': d, 'platform': {'os': 'linux', 'architecture': arch[d]}})
if os.environ.get('MANGLE') == 'drop-amd64' and len(srcs) == 2:
ms = [m for m in ms if m['platform'].get('architecture') != 'amd64']
if os.environ.get('MANGLE') == 'fail' and len(srcs) == 2:
sys.exit(1)
idx = {'mediaType': 'application/vnd.oci.image.index.v1+json', 'manifests': ms}
for t in ts:
tags[t] = idx
blobs[dig(idx)] = idx
save('tags.json', tags); save('blobs.json', blobs)
PY
export IMAGETOOLS="python3 $T/stub.py" STATE=$T/st
# mk_state <tag-content-kind>: writes the registry fixture. Digests: A amd64 image, AT its attestation,
# B arm64 image (new build, pushed by digest, not in any tag), C a second amd64 child.
mk() {
rm -rf "$T/st"; mkdir -p "$T/st"; : >"$T/st/log"
python3 -I - "$1" "$A" "$AT" "$B" "$BT" "$C" "$OLD" "$R" "$T/st" <<'PY'
import json, sys, os
kind, A, AT, B, BT, C, OLD, R, S = sys.argv[1:]
att = lambda d, of: {'digest': d, 'platform': {'os': 'unknown', 'architecture': 'unknown'}, 'annotations': {'vnd.docker.reference.type': 'attestation-manifest', 'vnd.docker.reference.digest': of}}
pl = lambda d, a: {'digest': d, 'platform': {'os': 'linux', 'architecture': a}}
idx = lambda ms: {'mediaType': 'application/vnd.oci.image.index.v1+json', 'manifests': ms}
tags, blobs = {}, {}
arch = {A: 'amd64', B: 'arm64', C: 'amd64'}
newb = idx([pl(B, 'arm64'), att(BT, B)]) # the arm64 build output (index with attestation)
blobs[B] = newb; arch[B] = 'arm64'
blobs[A] = {'config': {'digest': 'sha256:' + '9' * 64}, 'layers': []}
if kind == 'amd64only': tags[R + ':php82'] = idx([pl(A, 'amd64'), att(AT, A)])
elif kind == 'both': tags[R + ':php82'] = idx([pl(A, 'amd64'), att(AT, A), pl(OLD, 'arm64')]); arch[OLD] = 'arm64'
elif kind == 'noamd': tags[R + ':php82'] = idx([pl(OLD, 'arm64')]); arch[OLD] = 'arm64'
elif kind == 'twoamd': tags[R + ':php82'] = idx([pl(A, 'amd64'), pl(C, 'amd64')])
elif kind == 'single': tags[R + ':php82'] = blobs[A]
elif kind == 'missing': pass
for t, c in list(tags.items()):
import hashlib
d = 'sha256:' + hashlib.sha256(json.dumps(c, sort_keys=True).encode()).hexdigest()
blobs[d] = c
if kind == 'single': arch[d] = 'amd64'
json.dump(tags, open(S + '/tags.json', 'w')); json.dump(blobs, open(S + '/blobs.json', 'w')); json.dump(arch, open(S + '/arch.json', 'w'))
PY
}
EXP=sha256:$(printf '0%.0s' {1..64})
tagdig() { python3 -I -c '
import json,hashlib,sys
t=json.load(open(sys.argv[1]))[sys.argv[2]]
print("sha256:"+hashlib.sha256(json.dumps(t,sort_keys=True).encode()).hexdigest())' "$T/st/tags.json" "$R:php82"; }
plats() { python3 -I -c '
import json,sys
t=json.load(open(sys.argv[1]))[sys.argv[2]]
print(" ".join("%s=%s" % (m["platform"]["architecture"], m["digest"]) for m in t["manifests"] if "annotations" not in m))' "$T/st/tags.json" "$R:php82"; }
run() { "$HERE/attach-arm64-index.sh" "$@" >"$T/out" 2>"$T/err"; echo $?; }
creates() { grep -c '^create' "$T/st/log" || true; }
# ---- happy path: amd64-only tag + new arm64 -> index with amd64 UNCHANGED + arm64
mk amd64only; before=$(tagdig)
chk "attach to amd64-only tag -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$before")" 0
chk " amd64 manifest digest unchanged, arm64 added" "$(plats)" "amd64=$A arm64=$B"
chk " amd64 attestation carried over" "$(python3 -I -c 'import json,sys;print(sum(1 for m in json.load(open(sys.argv[1]))[sys.argv[2]]["manifests"] if m["digest"]==sys.argv[3]))' "$T/st/tags.json" "$R:php82" "$AT")" 1
chk " exactly one create, from the old index + the arm64 digest" "$(grep -c "^create -t $R:php82 $R@$before $R@$B\$" "$T/st/log")" 1
chk " prints before/after/amd64" "$(grep -c "^before_index=$before\$\|^amd64=$A\$\|^after_index=sha256:" "$T/out")" 3
[ "$(tagdig)" != "$before" ] && chk " new index digest differs" ok ok || chk " new index digest differs" same differs
# ---- already multi-arch: refuse (3), nothing written
mk both; before=$(tagdig)
chk "tag already has arm64 -> rc 3" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$before")" 3
chk " no create" "$(creates)" 0
chk " tag untouched" "$(tagdig)" "$before"
# ---- --force replaces the arm64 entry, amd64 manifest untouched
chk "--force on multi-arch -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --force --expect-index "$(tagdig)")" 0
chk " arm64 replaced, amd64 same" "$(plats)" "amd64=$A arm64=$B"
chk " create used the amd64 child only (old arm64 not a source)" "$(grep -c "^create -t $R:php82 $R@$A $R@$B\$" "$T/st/log")" 1
# ---- tag moved since the plan
mk amd64only
chk "--expect-index mismatch -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$C")" 1
chk " no create" "$(creates)" 0
# ---- --plan-only
chk "--plan-only -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --plan-only)" 0
chk " no create" "$(creates)" 0
mk both
chk "--plan-only on multi-arch tag still refuses (3)" "$(run --repo $R --tag php82 --arm64 "$B" --plan-only)" 3
# ---- bad inputs / bad tags
mk amd64only
chk "arm64 digest that is not arm64 -> rc 1" "$(run --repo $R --tag php82 --arm64 "$C" --expect-index "$EXP")" 1
chk "arm64 digest == amd64 digest -> rc 1" "$(run --repo $R --tag php82 --arm64 "$A" --expect-index "$EXP")" 1
chk "arm64 digest unknown to registry -> rc 1" "$(run --repo $R --tag php82 --arm64 "$(d 7)" --expect-index "$EXP")" 1
chk "malformed --arm64 -> rc 2" "$(run --repo $R --tag php82 --arm64 nope)" 2
chk "--arm64 missing without --plan-only -> rc 2" "$(run --repo $R --tag php82)" 2
chk "malformed --expect-index -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index x)" 2
chk "bad tag (injection) -> rc 2" "$(run --repo $R --tag 'a b;c' --arm64 "$B")" 2
chk "unknown argument -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --bogus)" 2
chk " none of those created anything" "$(creates)" 0
mk missing
chk "missing tag -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$EXP")" 1
mk noamd
chk "tag without amd64 -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$EXP")" 1
mk twoamd
chk "tag with two amd64 entries -> rc 1" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$EXP")" 1
chk " no create" "$(creates)" 0
# ---- plain single amd64 manifest tag
mk single; before=$(tagdig)
chk "single amd64 manifest tag -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$before")" 0
chk " create from the manifest digest + arm64" "$(grep -c "^create -t $R:php82 $R@$before $R@$B\$" "$T/st/log")" 1
# ---- post-create verification: a create that loses amd64 is detected and rolled back
mk amd64only; before=$(tagdig)
rc=$(MANGLE=drop-amd64 run --repo $R --tag php82 --arm64 "$B" --expect-index "$before"); chk "create dropped amd64 -> rc 1" "$rc" 1
chk " restored: tag is the previous index again" "$(plats)" "amd64=$A"
chk " second create was the restore from the old index" "$(grep -c "^create -t $R:php82 $R@$before\$" "$T/st/log")" 1
mk amd64only
rc=$(MANGLE=fail run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)"); chk "create failing -> rc != 0" "$([ "$rc" != 0 ] && echo yes)" yes
chk " tag untouched" "$(plats)" "amd64=$A"
chk "missing --expect-index -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B")" 2
# concurrent publish during attach: tag ends with a different amd64 -> never rolled back
mk amd64only; before=$(tagdig)
cat >"$T/race.sh" <<'RS'
#!/usr/bin/env bash
python3 "$STUBPY" "$@"; rc=$?
if [ "$1" = create ] && [ ! -f "$STATE/raced" ]; then touch "$STATE/raced"; python3 - <<'PY'
import json, os
S = os.environ['STATE']; t = json.load(open(S + '/tags.json'))
k = [x for x in t if x.endswith(':php82')][0]
t[k] = {'manifests': [{'digest': 'sha256:' + 'd' * 64, 'platform': {'os': 'linux', 'architecture': 'amd64'}}]}
json.dump(t, open(S + '/tags.json', 'w'))
PY
fi
exit $rc
RS
chmod +x "$T/race.sh"
rc=$(STUBPY=$T/stub.py IMAGETOOLS="$T/race.sh" run --repo $R --tag php82 --arm64 "$B" --expect-index "$before"); chk "publish raced in during attach -> rc 1" "$rc" 1
chk " newer amd64 NOT rolled back" "$(plats)" "amd64=sha256:$(printf 'd%.0s' {1..64})"
chk " no restore create" "$(grep -c "^create -t $R:php82 $R@$before\$" "$T/st/log" || true)" 0
# ---- --follow-tag: an alias (latest == php85) follows; a different latest is left alone
mk amd64only
python3 -I - "$T/st/tags.json" "$R" <<'PY'
import json, sys
t = json.load(open(sys.argv[1])); t[sys.argv[2] + ':latest'] = t[sys.argv[2] + ':php82']; json.dump(t, open(sys.argv[1], 'w'))
PY
chk "--follow-tag latest (alias) -> rc 0" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag latest)" 0
chk " latest now equals the new php82 index" "$(python3 -I -c '
import json,sys
t=json.load(open(sys.argv[1])); print(t[sys.argv[2]+":latest"]==t[sys.argv[2]+":php82"])' "$T/st/tags.json" "$R")" True
chk " latest has amd64 unchanged + arm64" "$(python3 -I -c '
import json,sys
t=json.load(open(sys.argv[1])); print(" ".join(m["platform"]["architecture"]+"="+m["digest"] for m in t[sys.argv[2]+":latest"]["manifests"] if "annotations" not in m))' "$T/st/tags.json" "$R")" "amd64=$A arm64=$B"
mk amd64only
python3 -I - "$T/st/tags.json" "$R" "$A" <<'PY'
import json, sys
t = json.load(open(sys.argv[1])); t[sys.argv[2] + ':latest'] = {'manifests': [{'digest': sys.argv[3], 'platform': {'os': 'linux', 'architecture': 'amd64'}}]}; json.dump(t, open(sys.argv[1], 'w'))
PY
lbefore=$(python3 -I -c '
import json,hashlib,sys
t=json.load(open(sys.argv[1]))[sys.argv[2]+":latest"]
print("sha256:"+hashlib.sha256(json.dumps(t,sort_keys=True).encode()).hexdigest())' "$T/st/tags.json" "$R")
chk "--follow-tag latest (not an alias) -> rc 0, tag attached" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag latest)" 0
chk " latest untouched" "$(python3 -I -c '
import json,hashlib,sys
t=json.load(open(sys.argv[1]))[sys.argv[2]+":latest"]
print("sha256:"+hashlib.sha256(json.dumps(t,sort_keys=True).encode()).hexdigest())' "$T/st/tags.json" "$R")" "$lbefore"
mk amd64only
chk "--follow-tag with missing latest -> rc 0, left alone" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag latest)" 0
chk "bad --follow-tag -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag 'x y')" 2
chk "--follow-tag == --tag -> rc 2" "$(run --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" --follow-tag php82)" 2
# ---- GITHUB_OUTPUT
mk amd64only; GITHUB_OUTPUT=$T/gho "$HERE/attach-arm64-index.sh" --repo $R --tag php82 --arm64 "$B" --expect-index "$(tagdig)" >/dev/null 2>&1
chk "GITHUB_OUTPUT has after_index and platforms" "$(grep -c '^after_index=\|^platforms=linux/amd64,linux/arm64$' "$T/gho")" 2
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo FAILURES; exit 1; }
+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env bash
## image-label-amd64.test.sh — fixtures for scripts/image-label-amd64.sh and
## scripts/php-emergency-guard.sh, driven through a stub IMAGETOOLS.
## Proves: index-safe (two-platform OCI index WITH attestation children, Docker
## manifest list, single-platform manifest), fail-closed on malformed/ambiguous
## input, "not found" = proceed, and that for single-platform images the guard
## makes the SAME decision as the old inline step on every (src,cur,new) case.
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
mkdir -p "$T/raw" "$T/cfg" "$T/err"
fail=0
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
# ---- stub: inspect --raw REF / inspect REF --format ... ; fixtures keyed by ref
key() { printf '%s' "$1" | tr '/:@' '___'; }
cat >"$T/it" <<'STUB'
#!/usr/bin/env bash
# args: inspect --raw REF | inspect REF --format F
d=$FIXDIR
[ "$1" = inspect ] || exit 2
if [ "$2" = --raw ]; then ref=$3; kind=raw; else ref=$2; kind=cfg; fi
k=$(printf '%s' "$ref" | tr '/:@' '___')
if [ -f "$d/err/$k" ]; then cat "$d/err/$k" >&2; exit 1; fi
[ -f "$d/$kind/$k" ] || { echo "ERROR: $ref: not found" >&2; exit 1; }
cat "$d/$kind/$k"
STUB
chmod +x "$T/it"
export FIXDIR=$T IMAGETOOLS="$T/it"
A=sha256:$(printf 'a%.0s' {1..64}); B=sha256:$(printf 'b%.0s' {1..64})
C=sha256:$(printf 'c%.0s' {1..64}); D=sha256:$(printf 'd%.0s' {1..64})
REPO=reg.example/org/img
put() { printf '%s' "$3" >"$T/$1/$(key "$2")"; }
cfg() { # arch src php -> image config json
printf '{"architecture":"%s","os":"linux","config":{"Labels":{"org.whp.lsphp-source":"%s","org.whp.php-version":"%s"}}}' "$1" "$2" "$3"; }
# 1. OCI index: amd64 + arm64 + two attestation children (unknown/unknown)
put raw $REPO:php85 '{"schemaVersion":2,"mediaType":"application/vnd.oci.image.index.v1+json","manifests":[
{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"'$A'","platform":{"architecture":"amd64","os":"linux"}},
{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"'$C'","platform":{"architecture":"unknown","os":"unknown"},"annotations":{"vnd.docker.reference.type":"attestation-manifest","vnd.docker.reference.digest":"'$A'"}},
{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"'$B'","platform":{"architecture":"arm64","os":"linux"}},
{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"'$D'","platform":{"architecture":"unknown","os":"unknown"},"annotations":{"vnd.docker.reference.type":"attestation-manifest","vnd.docker.reference.digest":"'$B'"}}]}'
put cfg $REPO@$A "$(cfg amd64 php.net 8.5.12)"
put cfg $REPO@$B "$(cfg arm64 php.net 8.5.99)" # must never be read
printf '%s\n%s\n' php.net 8.5.12 >"$T/want"
chk "index+attestations: amd64 labels" "$("$HERE/image-label-amd64.sh" $REPO:php85 org.whp.lsphp-source org.whp.php-version)" "$(cat "$T/want")"
# 2. Docker manifest list (no attestations)
put raw $REPO:ml '{"schemaVersion":2,"mediaType":"application/vnd.docker.distribution.manifest.list.v2+json","manifests":[
{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"'$B'","platform":{"architecture":"arm64","os":"linux","variant":"v8"}},
{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"'$A'","platform":{"architecture":"amd64","os":"linux"}}]}'
chk "docker manifest list" "$("$HERE/image-label-amd64.sh" $REPO:ml org.whp.php-version)" "8.5.12"
# 3. Single-platform manifest (today's amd64-only images); ref with digest too
put raw $REPO:single '{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"digest":"'$A'"},"layers":[]}'
put cfg $REPO:single "$(cfg amd64 litespeed 8.5.1)"
chk "single-platform manifest" "$("$HERE/image-label-amd64.sh" $REPO:single org.whp.lsphp-source org.whp.php-version | tr '\n' ,)" "litespeed,8.5.1,"
chk "absent label prints empty" "$("$HERE/image-label-amd64.sh" $REPO:single org.whp.nope)" ""
put raw $REPO:nolabels '{"mediaType":"x","config":{},"layers":[]}'
put cfg $REPO:nolabels '{"architecture":"amd64","config":{}}'
chk "config without Labels" "$("$HERE/image-label-amd64.sh" $REPO:nolabels org.whp.php-version)" ""
# 4. failures: each must exit non-zero (1) with nothing on stdout
bad() { # name ref
local out rc=0; out=$("$HERE/image-label-amd64.sh" "$2" org.whp.php-version 2>/dev/null) || rc=$?
chk "$1 -> rc $3" "$rc" "$3"; chk "$1 -> no stdout" "$out" ""
}
bad "tag not found" $REPO:nosuch 3
put raw $REPO:garbage 'this is not json'; bad "malformed JSON" $REPO:garbage 1
put raw $REPO:arr '[1,2]'; bad "JSON not an object" $REPO:arr 1
put raw $REPO:unk '{"foo":"bar"}'; bad "neither index nor manifest" $REPO:unk 1
put raw $REPO:armonly '{"manifests":[{"digest":"'$B'","platform":{"architecture":"arm64","os":"linux"}}]}'; bad "index without amd64" $REPO:armonly 1
put raw $REPO:two '{"manifests":[{"digest":"'$A'","platform":{"architecture":"amd64","os":"linux"}},{"digest":"'$D'","platform":{"architecture":"amd64","os":"linux"}}]}'; bad "ambiguous amd64" $REPO:two 1
put raw $REPO:baddig '{"manifests":[{"digest":"sha256:short","platform":{"architecture":"amd64","os":"linux"}}]}'; bad "malformed child digest" $REPO:baddig 1
put raw $REPO:badcfg '{"manifests":[{"digest":"'$D'","platform":{"architecture":"amd64","os":"linux"}}]}'
put cfg $REPO@$D 'not json'; bad "malformed config" $REPO:badcfg 1
put raw $REPO:wrongarch '{"manifests":[{"digest":"'$C'","platform":{"architecture":"amd64","os":"linux"}}]}'
put cfg $REPO@$C "$(cfg arm64 php.net 8.5.12)"; bad "amd64 slot with arm64 config" $REPO:wrongarch 1
printf 'ERROR: denied: requested access to the resource is denied\n' >"$T/err/$(key $REPO:denied)"; bad "auth/network error is NOT 'not found'" $REPO:denied 1
put raw $REPO:orphan '{"manifests":[{"digest":"'$B'","platform":{"architecture":"amd64","os":"linux"}}]}'; bad "child listed but missing" $REPO:orphan 1
# 5. Guard == old inline logic on single-platform fixtures, all combos
old() { # src cur new -> proceed|refuse (verbatim predicate of the old step)
local src=$1 cur=$2 new=$3
if [ "$src" = "php.net" ] && [ "$cur" != "$new" ] && [ "$(printf '%s\n%s\n' "$cur" "$new" | sort -V | tail -n1)" = "$cur" ]; then echo refuse; else echo proceed; fi; }
n=0
for src in php.net litespeed ""; do for cur in "" 8.5.11 8.5.12 8.5.13 8.4.99 8.10.0; do for new in 8.5.12 8.5.9 8.6.0; do
put raw $REPO:g '{"mediaType":"x","config":{},"layers":[]}'
put cfg $REPO:g "$(cfg amd64 "$src" "$cur")"
rc=0; "$HERE/php-emergency-guard.sh" $REPO:g "$new" >/dev/null 2>&1 || rc=$?
got=proceed; [ "$rc" -ne 0 ] && got=refuse
w=$(old "$src" "$cur" "$new"); n=$((n+1))
[ "$got" = "$w" ] || { echo "FAIL guard vs old: src='$src' cur='$cur' new='$new' got=$got old=$w"; fail=1; }
done; done; done
echo "ok guard == old inline logic on $n single-platform combos"
# 6. Guard on a multi-arch index: refuses the rollback (old logic could not even read it)
rc=0; "$HERE/php-emergency-guard.sh" $REPO:php85 8.5.9 >/dev/null 2>&1 || rc=$?; chk "index: emergency 8.5.12 vs packaged 8.5.9 refused" "$rc" 1
rc=0; "$HERE/php-emergency-guard.sh" $REPO:php85 8.6.0 >/dev/null 2>&1 || rc=$?; chk "index: packaged newer proceeds" "$rc" 0
# 7. fail closed vs first build
rc=0; "$HERE/php-emergency-guard.sh" $REPO:nosuch 8.5.9 >/dev/null 2>&1 || rc=$?; chk "tag absent: proceed (first build)" "$rc" 0
for t in garbage denied armonly orphan wrongarch; do
rc=0; "$HERE/php-emergency-guard.sh" $REPO:$t 8.5.9 >/dev/null 2>&1 || rc=$?; chk "unreadable ($t): FAIL CLOSED" "$rc" 1
done
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo "FAILURES"; exit 1; }
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
## index-platforms.test.sh — scripts/index-platforms.sh and
## scripts/assemble-multiarch-index.sh (copy of haproxy-manager-base's) against a stub IMAGETOOLS.
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
fail=0
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
A=sha256:$(printf 'a%.0s' {1..64}); B=sha256:$(printf 'b%.0s' {1..64}); C=sha256:$(printf 'c%.0s' {1..64})
cat >"$T/it" <<'STUB'
#!/usr/bin/env bash
# index-platforms mode: serves $FIX/<ref-with-/:@ as _> for "inspect --raw REF".
# assemble mode (STUB_LOG set): "inspect REF --format .." -> arch from $ARCHES (ref=arch lines);
# "create ..." -> appended to $STUB_LOG.
if [ -n "${STUB_LOG:-}" ]; then
if [ "$1" = create ]; then echo "create $*" >>"$STUB_LOG"; exit 0; fi
ref=$2; a=$(grep -F -m1 "$ref=" "$ARCHES" | cut -d= -f2); [ -n "$a" ] || exit 1
printf '{"architecture":"%s"}' "$a"; exit 0
fi
[ "$2" = --raw ] || exit 2
k=$(printf '%s' "$3" | tr '/:@' '___')
if [ -f "$FIX/err_$k" ]; then cat "$FIX/err_$k" >&2; exit 1; fi
[ -f "$FIX/$k" ] || { echo "ERROR: $3: not found" >&2; exit 1; }
cat "$FIX/$k"
STUB
chmod +x "$T/it"; export IMAGETOOLS="$T/it" FIX=$T
w() { printf '%s' "$2" >"$T/$(printf '%s' "$1" | tr '/:@' '___')"; }
w r/i:idx '{"mediaType":"application/vnd.oci.image.index.v1+json","manifests":[{"digest":"'$A'","platform":{"os":"linux","architecture":"amd64"}},{"digest":"'$B'","platform":{"os":"linux","architecture":"arm64"}},{"digest":"'$C'","platform":{"os":"unknown","architecture":"unknown"},"annotations":{"vnd.docker.reference.type":"attestation-manifest"}}]}'
w r/i:amd '{"manifests":[{"digest":"'$A'","platform":{"os":"linux","architecture":"amd64"}},{"digest":"'$C'","platform":{"os":"unknown","architecture":"unknown"},"annotations":{"vnd.docker.reference.type":"attestation-manifest"}}]}'
w r/i:one '{"config":{"digest":"'$A'"},"layers":[]}'
w r/i:bad 'garbage'
printf 'ERROR: denied\n' >"$T/err_r_i_den"
chk "two-platform index" "$("$HERE/index-platforms.sh" r/i:idx)" "index linux/amd64 linux/arm64"
chk "amd64 index with attestation" "$("$HERE/index-platforms.sh" r/i:amd)" "index linux/amd64"
chk "single manifest" "$("$HERE/index-platforms.sh" r/i:one)" "single"
for pair in "nosuch 3" "bad 1" "den 1"; do set -- $pair
rc=0; "$HERE/index-platforms.sh" r/i:$1 >/dev/null 2>&1 || rc=$?; chk "$1 -> rc $2" "$rc" "$2"; done
# ---- assemble-multiarch-index.sh (arm64 attach rules)
export STUB_LOG=$T/log ARCHES=$T/arches
R=reg/x
printf '%s\n' "$R@$A=amd64" "$R@$B=arm64" >"$ARCHES"
run() { : >"$STUB_LOG"; "$HERE/assemble-multiarch-index.sh" "$@" >/dev/null 2>&1; echo $?; }
chk "both ok -> rc 0" "$(run --amd64 $A --arm64 $B --arm64-outcome success --repo $R --tag t1 --tag t2)" 0
chk "both ok -> 1 create with 2 sources, 2 tags" "$(grep -c "create create -t $R:t1 -t $R:t2 $R@$A $R@$B\$" "$STUB_LOG")" 1
chk "arm64 failed (digest present, stale) -> amd64 only" "$(run --amd64 $A --arm64 $B --arm64-outcome failure --repo $R --tag t1)" 0
chk " ... create has no arm64 digest" "$(grep -c "$B" "$STUB_LOG" || true)" 0
run --amd64 $A --repo $R --tag t1 >/dev/null
chk "arm64 skipped -> amd64 only" "$(grep -c "$B" "$STUB_LOG" || true)" "0"
chk "malformed amd64 digest -> refuse" "$(run --amd64 nope --repo $R --tag t1)" 1
chk " ... nothing created" "$(grep -c create "$STUB_LOG" || true)" 0
printf '%s\n' "$R@$A=arm64" >"$ARCHES"
chk "amd64 digest that is not amd64 -> refuse" "$(run --amd64 $A --repo $R --tag t1)" 1
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo FAILURES; exit 1; }
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
## lsphp-pin-resolve.test.sh — fixture test for scripts/lsphp-pin-resolve.sh.
## Fake `apt-cache madison` outputs model (a) a consistent repo (82/83/85: the
## pin must stay EXACTLY the lsphp version), (b) the 2026-11-19 lsphp84 set
## (lsphp84 -2, -common -3 only), (c) cases that must FAIL closed.
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
R="$HERE/lsphp-pin-resolve.sh"
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
fail=0
ok() { echo "ok - $1"; }
bad() { echo "FAIL - $1"; fail=1; }
mk() { # file, then lines "pkg|version"
local f="$1"; shift
: >"$f"
for l in "$@"; do printf '%s | %s | http://rpms.litespeedtech.com/debian noble/main amd64 Packages\n' "${l%%|*}" "${l#*|}" >>"$f"; done
}
cat >"$T/apt-cache" <<'EOS'
#!/bin/sh
[ "$1" = madison ] || exit 2
grep -E "^ *$2 \|" "$FIX" || true
EOS
chmod +x "$T/apt-cache"
export LSPHP_MADISON_CMD="$T/apt-cache madison"
res() { FIX="$1" "$R" resolve "$2" "$3" 2>/dev/null; }
expect() { # name want fixture pkg ver
local got; got=$(res "$3" "$4" "$5") || got=FAIL
[ "$got" = "$2" ] && ok "$1" || bad "$1 (got '$got', want '$2')"
}
mk "$T/consistent" "lsphp85-common|8.5.12-2+noble" "lsphp85-ldap|8.5.12-2+noble"
expect "consistent repo: -common stays exact" "8.5.12-2+noble" "$T/consistent" lsphp85-common 8.5.12-2+noble
expect "consistent repo: -ldap stays exact" "8.5.12-2+noble" "$T/consistent" lsphp85-ldap 8.5.12-2+noble
mk "$T/incons" "lsphp84-common|8.4.27-3+noble" "lsphp84-ldap|8.4.27-2+noble"
expect "inconsistent: -common resolves to -3" "8.4.27-3+noble" "$T/incons" lsphp84-common 8.4.27-2+noble
expect "inconsistent: -ldap stays -2" "8.4.27-2+noble" "$T/incons" lsphp84-ldap 8.4.27-2+noble
mk "$T/two" "lsphp84-common|8.4.27-3+noble" "lsphp84-common|8.4.27-2+noble"
expect "exact version preferred over newer revision" "8.4.27-2+noble" "$T/two" lsphp84-common 8.4.27-2+noble
mk "$T/otherphp" "lsphp84-common|8.4.28-1+noble"
expect "different PHP version is never substituted" FAIL "$T/otherphp" lsphp84-common 8.4.27-2+noble
mk "$T/older" "lsphp84-common|8.4.27-1+noble"
expect "older revision is never substituted" FAIL "$T/older" lsphp84-common 8.4.27-2+noble
mk "$T/otherdist" "lsphp84-common|8.4.27-3+jammy"
expect "different distro suffix is never substituted" FAIL "$T/otherdist" lsphp84-common 8.4.27-2+noble
: >"$T/empty"
expect "package absent fails" FAIL "$T/empty" lsphp84-common 8.4.27-2+noble
okc() { "$R" ok "$1" "$2" 2>/dev/null; }
okc 8.4.27-3+noble 8.4.27-2+noble && ok "post-check accepts -3 for want -2" || bad "post-check accepts -3"
okc 8.4.27-2+noble 8.4.27-2+noble && ok "post-check accepts equal" || bad "post-check equal"
okc 8.4.28-1+noble 8.4.27-2+noble && bad "post-check must reject other PHP version" || ok "post-check rejects other PHP version"
okc 8.4.27-1+noble 8.4.27-2+noble && bad "post-check must reject older" || ok "post-check rejects older"
exit $fail
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
## lsphp-repo-version.test.sh — fixture test for scripts/lsphp-repo-version.sh.
## Asserts: amd64 (explicit and default) equals the OLD inline pipeline on the
## same fixture; arm64 picks from the arm64 index (fixtures deliberately differ);
## bad arch is refused.
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
S="$HERE/lsphp-repo-version.sh"
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
mk() { # file, version-for-lsphp85
cat >"$T/$1" <<EOT
Package: lsphp84
Version: 8.4.20-1+ubuntu24.04.1+deb.sury.org+1
Architecture: x
Package: lsphp85
Version: 8.5.1-1+ubuntu24.04.1+deb.sury.org+1
Architecture: x
Package: lsphp85
Version: $2
Architecture: x
Package: lsphp85-common
Version: 9.9.9-1
Architecture: x
EOT
}
mk amd64.Packages 8.5.12-1+ubuntu24.04.1+deb.sury.org+1
mk arm64.Packages 8.5.11-1+ubuntu24.04.1+deb.sury.org+1
old() { printf '%s\n' "$(cat "$1")" | awk -v p="lsphp${2}" '/^Package: /{n=$2} /^Version: / && n==p {print $2}' | sort -V | tail -n1; }
fail=0
chk() { if [ "$2" = "$3" ]; then echo "ok $1: $2"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
for v in 84 85; do
chk "amd64 explicit lsphp$v == old inline" "$(LSPHP_INDEX_FILE=$T/amd64.Packages "$S" $v amd64)" "$(old "$T/amd64.Packages" $v)"
chk "default arch lsphp$v == old inline" "$(LSPHP_INDEX_FILE=$T/amd64.Packages "$S" $v)" "$(old "$T/amd64.Packages" $v)"
done
chk "arm64 reads arm64 index" "$(LSPHP_INDEX_FILE=$T/arm64.Packages "$S" 85 arm64)" "8.5.11-1+ubuntu24.04.1+deb.sury.org+1"
chk "LSPHP_ARCH env" "$(LSPHP_ARCH=arm64 LSPHP_INDEX_FILE=$T/arm64.Packages "$S" 85)" "8.5.11-1+ubuntu24.04.1+deb.sury.org+1"
chk "missing pkg is empty" "$(LSPHP_INDEX_FILE=$T/amd64.Packages "$S" 99)" ""
if "$S" 85 s390x >/dev/null 2>&1; then echo "FAIL bad arch accepted"; fail=1; else echo "ok bad arch refused"; fi
exit $fail
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
## Fixture test: the step-2c upload_progress patch in lsphp-src-build.sh flips only
## session.upload_progress.enabled (value on the line after the name), is a no-op
## when already "1", and the script keeps its 4b gate + fails closed if not found.
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
S="$HERE/lsphp-src-build.sh"
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
fail=0
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
cat >"$T/session.c" <<'EOT'
STD_PHP_INI_BOOLEAN("session.upload_progress.enabled",
"0", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_enabled, php_ps_globals, ps_globals)
STD_PHP_INI_BOOLEAN("session.upload_progress.cleanup",
"0", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_cleanup, php_ps_globals, ps_globals)
EOT
## Run the exact sed expression from the script.
## Plain loop, not a grep|grep|head pipeline: an early-exit reader under pipefail
## can SIGPIPE its writer (see lsphp-info-probe.test.sh structural scan).
SEDLINE=""
while IFS= read -r line; do
case "$line" in *'session\.upload_progress\.enabled'*) ;; *) continue ;; esac
case "$line" in ' '*'sed -i'*|'sed -i'*) SEDLINE="$line"; break ;; esac
done <"$S"
[ -n "$SEDLINE" ] || { echo "FAIL: sed line not found in script"; exit 1; }
export SRC="$T" # referenced by the eval'd sed line
sed() { command sed "$@"; }
eval "${SEDLINE//\$SRC\/ext\/session\/session.c/$T/session.c}"
chk "enabled flipped to 1" "$(grep -A1 'upload_progress.enabled' "$T/session.c" | grep -c '"1"')" 1
chk "cleanup untouched" "$(grep -A1 'upload_progress.cleanup' "$T/session.c" | grep -c '"0"')" 1
eval "${SEDLINE//\$SRC\/ext\/session\/session.c/$T/session.c}"
chk "idempotent" "$(grep -A1 'upload_progress.enabled' "$T/session.c" | grep -c '"1"')" 1
grep -q 'ini defaults differ from the packaged' "$S" && echo "ok 4b gate still present" || { echo "FAIL 4b gate missing"; fail=1; }
grep -q 'could not apply the packaged session.upload_progress.enabled' "$S" && echo "ok fail-closed verify present" || { echo "FAIL verify missing"; fail=1; }
exit $fail
+462
View File
@@ -0,0 +1,462 @@
#!/usr/bin/env python3
"""Static wiring checks for the multi-arch publish jobs in .gitea/workflows/build-push.yaml
(Build-and-Push = cac, Build-FPM-Images = cac-fpm, Build-Shared-httpd = shared-httpd).
No YAML library (the Shell-Checks runner has none): jobs/steps are split on their indentation.
Env WORKFLOW overrides the file under test (used to show the tests fail on the old workflow).
Run: python3 -I scripts/tests/multiarch-workflow.test.py
"""
import os, re, subprocess, tempfile, unittest, stat
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.normpath(os.path.join(HERE, '..', '..'))
WF = os.environ.get('WORKFLOW') or os.path.join(ROOT, '.gitea', 'workflows', 'build-push.yaml')
with open(WF) as _f:
TEXT = _f.read()
REG = 'repo.anhonesthost.net/cloud-hosting-platform'
SLICE = { # job -> (image repo, dockerfile arg or None, matrix?)
'Build-and-Push': ('cac', None, True),
'Build-FPM-Images': ('cac-fpm', './Dockerfile.fpm', True),
'Build-Shared-httpd': ('shared-httpd', './Dockerfile.shared-httpd', False),
}
OUT_OF_SLICE = ['Build-LiteSpeed-Images', 'Build-LSPHP-Images', 'Build-Shared-OLS']
def jobs():
m = re.search(r'^jobs:\n', TEXT, re.M)
body = TEXT[m.end():]
parts = re.split(r'^ ([A-Za-z0-9_-]+):\n', body, flags=re.M)
return {parts[i]: parts[i + 1] for i in range(1, len(parts), 2)}
def steps(job):
s = re.split(r'^ - name: ', job, flags=re.M)[1:]
out = []
for blk in s:
name = blk.split('\n', 1)[0].strip()
out.append((name, blk))
return out
def step(job, prefix):
hits = [(n, b) for n, b in steps(job) if n.startswith(prefix)]
assert len(hits) == 1, (prefix, [n for n, _ in hits])
return hits[0][1]
class Wiring(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.jobs = jobs()
def test_triggers_unchanged(self):
head = TEXT.split('jobs:')[0]
self.assertRegex(head, r'on:\n push:\n branches:\n - trunk\n workflow_dispatch:')
def test_slice_jobs_exist_and_keep_matrix_and_no_fail_fast(self):
for j, (_, _, matrix) in SLICE.items():
self.assertIn(j, self.jobs, j)
if matrix:
self.assertIn('fail-fast: false', self.jobs[j], j)
self.assertRegex(self.jobs[j], r'phpver: \$\{\{ fromJSON\(needs\.plan\.outputs\.\w+\) \}\}', j)
def test_job_timeout_bounds_the_arm64_step(self):
for j in SLICE:
job = self.jobs[j]
jt = int(re.search(r'^ timeout-minutes: (\d+)$', job, re.M).group(1))
at = int(re.search(r'timeout-minutes: (\d+)', step(job, 'Build arm64')).group(1))
self.assertGreaterEqual(at, 20, j) # T3: arm64 under qemu took 7m47s
self.assertGreater(jt, at + 20, j) # room for setup + amd64 + assemble
self.assertLessEqual(jt, 150, j)
# the retry must fit: 2 arm64 attempts + 90 s pause + amd64 + verify/assemble margin
self.assertGreater(jt, 2 * at + 2 + {'Build-and-Push': 20, 'Build-FPM-Images': 20, 'Build-Shared-httpd': 10}[j] + 15, j)
def test_step_order_and_ids(self):
for j in SLICE:
names = [n for n, _ in steps(self.jobs[j])]
a = [i for i, n in enumerate(names) if n.startswith('Build amd64')]
r = [i for i, n in enumerate(names) if n.startswith('Build arm64')]
s = [i for i, n in enumerate(names) if n.startswith('Assemble')]
self.assertEqual((len(a), len(r), len(s)), (1, 1, 1), j)
self.assertLess(a[0], r[0], j)
self.assertLess(r[0], s[0], j)
self.assertIn('id: amd64', step(self.jobs[j], 'Build amd64'))
self.assertIn('id: arm64', step(self.jobs[j], 'Build arm64'))
self.assertLess(names.index('Login to Gitea'), a[0], j)
def test_arm64_non_fatal_amd64_fatal(self):
for j in SLICE:
self.assertIn('continue-on-error: true', step(self.jobs[j], 'Build arm64'), j)
self.assertNotIn('continue-on-error', step(self.jobs[j], 'Build amd64'), j)
self.assertNotIn('continue-on-error', step(self.jobs[j], 'Assemble'), j)
def test_platforms_and_qemu(self):
for j in SLICE:
self.assertIn('platforms: linux/amd64\n', step(self.jobs[j], 'Build amd64'), j)
self.assertIn('platforms: linux/arm64\n', step(self.jobs[j], 'Build arm64'), j)
self.assertRegex(step(self.jobs[j], 'Set up QEMU'), r'platforms: arm64', j)
def test_both_push_by_digest_untagged_to_gitea_only(self):
for j, (repo, _, _) in SLICE.items():
for which in ('Build amd64', 'Build arm64'):
st = step(self.jobs[j], which)
self.assertIn('type=image,name=%s/%s,push-by-digest=true,name-canonical=true,push=true' % (REG, repo), st, j)
self.assertNotRegex(st, r'^\s+tags:', j)
self.assertNotRegex(st, r'^\s+push: true', j)
self.assertNotIn('ghcr.io', self.jobs[j], j) # CAC has never pushed to GHCR; do not widen
def test_same_build_args_and_dockerfile_for_both_platforms(self):
for j, (_, dockerfile, _) in SLICE.items():
a = step(self.jobs[j], 'Build amd64'); r = step(self.jobs[j], 'Build arm64')
ba = lambda s: re.search(r'build-args: \|\n((?: .*\n)+)', s).group(1)
self.assertEqual(ba(a), ba(r), j)
for need in (('PKG_CACHE=${{ steps.pkgcache.outputs.url }}', 'BASE_IMAGE=${{ steps.base.outputs.image }}')):
for n in need:
self.assertIn(n, ba(a), j)
if SLICE[j][2]:
for n in ('PHPVER=${{ matrix.phpver }}', 'CACHE_BUST=${{ steps.bust.outputs.value }}',
'EXPECT_PHP_MIN=${{ steps.phpmin.outputs.min }}'):
self.assertIn(n, ba(a), j)
if dockerfile:
self.assertIn('file: %s\n' % dockerfile, a, j)
self.assertIn('file: %s\n' % dockerfile, r, j)
def test_assemble_uses_this_runs_outputs_and_repo(self):
for j, (repo, _, _) in SLICE.items():
st = step(self.jobs[j], 'Assemble')
self.assertIn('${{ steps.amd64.outputs.digest }}', st, j)
self.assertIn("${{ steps.arm64.outcome == 'success' && steps.arm64.outputs.digest || steps.arm64_retry.outputs.digest }}", st, j)
self.assertIn("steps.arm64.outcome == 'success' || steps.arm64_retry.outcome == 'success'", st, j)
self.assertIn('scripts/assemble-multiarch-index.sh', st, j)
self.assertIn('--repo %s/%s' % (REG, repo), st, j)
self.assertEqual(st.count('--repo '), 1, j)
def test_one_retry_of_a_failed_arm64_leg(self):
for j in SLICE:
job = self.jobs[j]
names = [n for n, _ in steps(job)]
i = [k for k, n in enumerate(names) if n.startswith('Build arm64')][0]
self.assertTrue(names[i + 1].startswith('Wait before arm64 retry'), j)
self.assertTrue(names[i + 2].startswith('Retry arm64'), j)
self.assertLess(i + 2, [k for k, n in enumerate(names) if n.startswith('Assemble')][0], j)
first, retry = step(job, 'Build arm64'), step(job, 'Retry arm64')
self.assertIn("if: steps.arm64.outcome == 'failure'", step(job, 'Wait before'), j)
self.assertIn("if: steps.arm64.outcome == 'failure'", retry, j)
self.assertIn('id: arm64_retry', retry, j)
self.assertIn('continue-on-error: true', retry, j)
self.assertEqual(len(re.findall(r'Retry arm64', job)), 1, j) # exactly one retry
for key in ('timeout-minutes', 'platforms', 'file', 'outputs'):
a = re.search(r'(?m)^\s+%s: .*$' % key, first)
b = re.search(r'(?m)^\s+%s: .*$' % key, retry)
self.assertEqual(a and a.group(0), b and b.group(0), (j, key))
ba = lambda x: re.search(r'build-args: \|\n((?: .*\n)+)', x).group(1)
self.assertEqual(ba(first), ba(retry), j)
def test_matrix_families_cap_parallel_qemu_legs(self):
for j, (_, _, matrix) in SLICE.items():
if matrix:
self.assertRegex(self.jobs[j], r'(?m)^ max-parallel: [12]$', j)
def test_assemble_guard_verify_and_override_wiring(self):
want = {'Build-and-Push': ['/usr/sbin/httpd', '/usr/bin/php'],
'Build-FPM-Images': ['/usr/sbin/php-fpm', '/usr/bin/php'],
'Build-Shared-httpd': ['/usr/sbin/httpd']}
for j, bins in want.items():
st = step(self.jobs[j], 'Assemble')
self.assertIn('--guard-existing-arm64', st, j)
self.assertEqual(re.findall(r'--verify-bin (\S+)', st), bins, j)
self.assertIn('ALLOW_AMD64_ONLY: ${{ github.event.inputs.allow_amd64_only }}', st, j)
run = re.search(r'run: \|\n((?: .*\n?)+)', st).group(1)
self.assertNotIn('${{', run, j)
def test_allow_amd64_only_input_is_a_string_default_false(self):
head = TEXT.split('jobs:')[0]
m = re.search(r'(?m)^ allow_amd64_only:\n((?: .*\n)+)', head)
self.assertIsNotNone(m)
self.assertIn("default: 'false'", m.group(1))
self.assertIn('type: string', m.group(1))
def test_tag_scheme_unchanged(self):
"""Run the assemble step's shell with a recording stub: exact tags per version."""
for j, (repo, _, matrix) in SLICE.items():
st = step(self.jobs[j], 'Assemble')
script = re.search(r'run: \|\n((?: .*\n?)+)', st).group(1)
script = '\n'.join(l[10:] for l in script.split('\n'))
for ver in (['82', '83', '84', '85', '86'] if matrix else ['']):
with tempfile.TemporaryDirectory() as d:
os.makedirs(os.path.join(d, 'scripts'))
stub = os.path.join(d, 'scripts', 'assemble-multiarch-index.sh')
with open(stub, 'w') as f:
f.write('#!/usr/bin/env bash\nprintf "%s\\n" "$@" > "$LOG"\n')
os.chmod(stub, 0o755)
log = os.path.join(d, 'log')
env = dict(os.environ, LOG=log, AMD64_DIGEST='sha256:' + 'a' * 64,
ARM64_DIGEST='sha256:' + 'b' * 64, ARM64_OUTCOME='success', PHPVER=ver)
subprocess.run(['bash', '-c', script], cwd=d, env=env, check=True)
with open(log) as f:
args = f.read().split('\n')[:-1]
tags = [args[i + 1] for i, x in enumerate(args) if x == '--tag']
want = ['latest'] if not matrix else (['php' + ver] + (['latest'] if ver == '85' else []))
self.assertEqual(tags, want, (j, ver))
self.assertEqual(args[args.index('--repo') + 1], '%s/%s' % (REG, repo))
self.assertEqual(args[args.index('--arm64-outcome') + 1], 'success')
def test_arm64_never_added_outside_the_first_slice(self):
for j in OUT_OF_SLICE:
self.assertIn(j, self.jobs, j)
job = self.jobs[j]
self.assertIn('platforms: linux/amd64', job, j)
self.assertNotIn('linux/arm64', job, j)
self.assertNotIn('push-by-digest', job, j)
self.assertNotIn('assemble-multiarch-index', job, j)
def test_only_the_assemble_script_creates_tags_in_slice(self):
for j in SLICE:
self.assertNotIn('imagetools create', self.jobs[j], j) # only via the tested script
# ---- single-leg dispatch (workflow_dispatch input `only`, plan job) ----------------------
PLAN = os.path.join(ROOT, '.gitea', 'scripts', 'plan-legs.sh')
FULL = '[82,83,84,85]' # LiteSpeed families
FULL86 = '[82,83,84,85,86]' # cac / cac-fpm (Remi) also ship 8.6
# image job -> (plan output, matrix?)
LEGS = {
'Build-and-Push': ('cac', True),
'Build-FPM-Images': ('cac_fpm', True),
'Build-LiteSpeed-Images': ('cac_litespeed', True),
'Build-LSPHP-Images': ('cac_lsphp', True),
'Build-Shared-httpd': ('shared_httpd', False),
'Build-Shared-OLS': ('shared_ols', False),
}
EMPTY = {'cac': '[]', 'cac_fpm': '[]', 'cac_litespeed': '[]', 'cac_lsphp': '[]',
'shared_httpd': 'false', 'shared_ols': 'false'}
EVERYTHING = {'cac': FULL86, 'cac_fpm': FULL86, 'cac_litespeed': FULL, 'cac_lsphp': FULL,
'shared_httpd': 'true', 'shared_ols': 'true'}
def plan(only):
"""Run plan-legs.sh like the runner does. Returns (exit code, outputs dict, stderr)."""
with tempfile.TemporaryDirectory() as d:
out = os.path.join(d, 'out')
open(out, 'w').close()
env = dict(os.environ, GITHUB_OUTPUT=out)
if only is None:
env.pop('ONLY', None) # push event: the input does not exist
else:
env['ONLY'] = only
r = subprocess.run(['bash', PLAN], env=env, capture_output=True, text=True, timeout=30)
with open(out) as f:
kv = dict(l.rstrip('\n').split('=', 1) for l in f if '=' in l)
return r.returncode, kv, r.stderr
class SingleLegDispatch(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.jobs = jobs()
def test_trigger_still_trunk_push_only_and_dispatch_has_string_input(self):
head = TEXT.split('jobs:')[0]
self.assertEqual(re.findall(r'^ branches:\n((?: - .*\n)+)', head, re.M), [' - trunk\n'])
m = re.search(r'^ workflow_dispatch:\n inputs:\n only:\n((?: .*\n)+)', head, re.M)
self.assertIsNotNone(m, 'workflow_dispatch needs an `only` input')
self.assertIn("default: ''", m.group(1))
self.assertIn('required: false', m.group(1))
self.assertIn('type: string', m.group(1))
def test_plan_job_wiring(self):
plan_job = self.jobs['plan']
# input goes through env, never interpolated into the shell script
self.assertRegex(plan_job, r'env:\n ONLY: \$\{\{ github\.event\.inputs\.only \}\}')
run = re.search(r'run: (.*)\n', step(plan_job, 'Plan legs')).group(1)
self.assertNotIn('${{', run)
self.assertIn('.gitea/scripts/plan-legs.sh', run)
for _, (out, _) in LEGS.items():
self.assertIn(' %s: ${{ steps.plan.outputs.%s }}' % (out, out), plan_job, out)
self.assertIn('id: plan', step(plan_job, 'Plan legs'))
def test_every_image_job_depends_on_plan_with_its_own_output(self):
for j, (out, matrix) in LEGS.items():
job = self.jobs[j]
self.assertRegex(job, r'(?m)^ needs: plan$', j)
want = ("if: needs.plan.outputs.%s != '[]'" if matrix else "if: needs.plan.outputs.%s == 'true'") % out
self.assertRegex(job, r'(?m)^ ' + re.escape(want) + r'$', j)
if matrix:
self.assertIn('phpver: ${{ fromJSON(needs.plan.outputs.%s) }}' % out, job, j)
self.assertNotRegex(job, r'if:.*matrix\.', j) # job-level if cannot see matrix
self.assertNotRegex(job, r'phpver: \[', j) # no literal list left behind
outs = [o for o, _ in LEGS.values()]
self.assertEqual(len(outs), len(set(outs)))
def test_every_job_but_shell_checks_and_plan_is_gated(self):
for j in self.jobs:
if j in ('Shell-Checks', 'plan'):
continue
self.assertIn(j, LEGS, 'new job %s must be gated by the plan job' % j)
sc = self.jobs['Shell-Checks']
self.assertNotRegex(sc, r'^ (needs|if):', 'Shell-Checks must stay ungated')
self.assertIn('.gitea/scripts/plan-legs.sh', sc) # shellchecked
self.assertIn('multiarch-workflow.test.py', sc) # this suite still runs
def test_plan_outputs_match_what_the_script_emits(self):
rc, kv, _ = plan('')
self.assertEqual(rc, 0)
self.assertEqual(sorted(kv), sorted(o for o, _ in LEGS.values()))
def test_push_and_empty_input_plan_everything(self):
for only in (None, '', ' ', '\t'):
rc, kv, err = plan(only)
self.assertEqual((rc, kv), (0, EVERYTHING), (only, err))
def test_full_matrix_equals_the_old_literal(self):
# the pre-86 matrix was `phpver: [82, 83, 84, 85]`; the LiteSpeed families keep it
rc, kv, _ = plan(None)
self.assertEqual([int(x) for x in kv['cac'].strip('[]').split(',')], [82, 83, 84, 85, 86])
for fam in ('cac_litespeed', 'cac_lsphp'):
self.assertEqual([int(x) for x in kv[fam].strip('[]').split(',')], [82, 83, 84, 85], fam)
def test_single_leg(self):
rc, kv, _ = plan('cac:php85')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac='[85]')))
rc, kv, _ = plan('cac-fpm:php84')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac_fpm='[84]')))
rc, kv, _ = plan('cac-litespeed:php82')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac_litespeed='[82]')))
rc, kv, _ = plan('cac-lsphp:php83')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac_lsphp='[83]')))
rc, kv, _ = plan('shared-httpd')
self.assertEqual((rc, kv), (0, dict(EMPTY, shared_httpd='true')))
rc, kv, _ = plan('shared-ols')
self.assertEqual((rc, kv), (0, dict(EMPTY, shared_ols='true')))
def test_cac_does_not_pull_in_cac_fpm(self):
rc, kv, _ = plan('cac:php85')
self.assertEqual(kv['cac_fpm'], '[]')
self.assertEqual(kv['cac_litespeed'], '[]')
def test_family_name_means_every_version(self):
rc, kv, _ = plan('cac-fpm')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac_fpm=FULL86)))
rc, kv, _ = plan('cac-lsphp')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac_lsphp=FULL)))
rc, kv, _ = plan('cac-litespeed')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac_litespeed=FULL)))
def test_php86_only_for_remi_families(self):
rc, kv, _ = plan('cac:php86')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac='[86]')))
rc, kv, _ = plan('cac-fpm:php86')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac_fpm='[86]')))
for fam in ('cac-litespeed', 'cac-lsphp'):
rc, kv, err = plan(fam + ':php86')
self.assertEqual((rc, kv), (2, {}), fam)
self.assertIn('plan-legs:', err)
def test_comma_list_spaces_duplicates_and_ordering(self):
rc, kv, _ = plan(' cac:php85 , cac:php82,cac:php85, shared-httpd ,')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac='[82,85]', shared_httpd='true')))
rc, kv, _ = plan('cac:php85,cac-fpm:php84')
self.assertEqual((rc, kv), (0, dict(EMPTY, cac='[85]', cac_fpm='[84]')))
def test_unknown_values_fail_loudly_and_emit_nothing(self):
bad = ['foo', 'cac:php99', 'cac:php87', 'cac-lsphp:php86', 'cac-litespeed:php86', 'cac:85', 'cac:php8', 'CAC:php85', 'cac:', 'cac:php85:x', 'php85',
'shared-httpd:php85', 'shared-ols:latest', ',', ' , ', 'cac:php85,nope',
'cac:php85;rm -rf x', '$(id)', 'all', 'latest']
for only in bad:
rc, kv, err = plan(only)
self.assertEqual(rc, 2, only)
self.assertEqual(kv, {}, only) # nothing half-planned
self.assertIn('plan-legs:', err, only)
# ---- arm64-attach.yaml: restore arm64 on an existing tag without touching amd64 --------------
ATTACH_WF = os.path.join(ROOT, '.gitea', 'workflows', 'arm64-attach.yaml')
class AttachWorkflow(unittest.TestCase):
@classmethod
def setUpClass(cls):
with open(ATTACH_WF) as f:
cls.text = f.read()
cls.job = cls.text.split('\njobs:\n', 1)[1]
def test_manual_only_never_on_push_or_pr(self):
head = self.text.split('\njobs:\n')[0]
self.assertRegex(head, r'(?m)^on:\n workflow_dispatch:\n inputs:')
self.assertNotRegex(head, r'(?m)^ (push|pull_request|schedule|workflow_run)\b')
def test_inputs_are_strings_and_runs_are_serialised(self):
head = self.text.split('\njobs:\n')[0]
for name in ('image', 'phpver', 'force'):
self.assertRegex(head, r'(?m)^ %s:\n(?: .*\n)*? type: string' % name)
self.assertRegex(head, r'(?m)^concurrency:\n group: arm64-attach\n cancel-in-progress: false$')
def test_inputs_never_interpolated_into_shell(self):
for blk in re.findall(r'(?ms)^ run: .*?(?=^ - |\Z)', self.job):
self.assertNotIn('${{', blk) # everything reaches the script through env:
self.assertNotIn('github.event.inputs', self.job.split('Validate inputs', 1)[1].split('Login to Gitea', 1)[1])
def test_only_images_cac_and_cac_fpm_and_php82_to_86(self):
v = step(self.job, 'Validate inputs')
self.assertRegex(v, r'cac\)\s+dockerfile=Dockerfile;')
self.assertRegex(v, r'cac-fpm\)\s+dockerfile=Dockerfile\.fpm;')
self.assertIn('^8[2-6]$', v)
self.assertEqual(re.findall(r'(?m)^ ([a-z-]+)\)', v), ['cac', 'cac-fpm'])
self.assertNotIn('litespeed', v)
self.assertNotIn('lsphp', v)
def test_arm64_only_push_by_digest_no_tags(self):
self.assertEqual(len(re.findall(r'platforms: linux/', self.job)), 1)
st = step(self.job, 'Build arm64')
self.assertIn('platforms: linux/arm64\n', st)
self.assertIn('push-by-digest=true,name-canonical=true,push=true', st)
self.assertNotRegex(st, r'(?m)^\s+tags:')
self.assertNotRegex(st, r'(?m)^\s+push: true')
self.assertNotIn('continue-on-error', st) # the run exists only for this build
self.assertNotIn('linux/amd64', st)
self.assertNotIn('Build amd64', self.job)
def test_nothing_but_the_script_writes_a_tag(self):
for bad in ('imagetools create', 'docker push', 'docker tag', '/cac:latest', '/cac-fpm:latest', 'ghcr.io', 'docker buildx build'):
self.assertNotIn(bad, self.job, bad)
self.assertEqual(self.job.count('scripts/attach-arm64-index.sh'), 2) # plan (read-only) + attach
self.assertIn('--plan-only', step(self.job, 'Plan'))
self.assertNotIn('--arm64', step(self.job, 'Plan'))
def test_step_order(self):
names = [n for n, _ in steps(self.job)]
order = ['Validate inputs', 'Login to Gitea', 'Plan', 'Build arm64', 'Verify ELF', 'PHP version parity', 'Attach']
idx = [next(i for i, n in enumerate(names) if n.startswith(o)) for o in order]
self.assertEqual(idx, sorted(idx))
def test_attach_step_guards(self):
st = step(self.job, 'Attach')
for need in ('--expect-index "$BEFORE"', '--arm64 "$ARM64_DIGEST"', '${{ steps.plan.outputs.before_index }}',
'${{ steps.arm64.outputs.digest }}'):
self.assertIn(need, st)
self.assertNotIn('continue-on-error', st)
def test_both_platforms_elf_checked_before_attach(self):
st = step(self.job, 'Verify ELF')
self.assertIn('--platform linux/arm64', st)
self.assertIn('--platform linux/amd64', st)
self.assertIn('verify-image-arch.py', st)
self.assertIn('/usr/sbin/httpd /usr/bin/php', step(self.job, 'Validate inputs'))
self.assertIn('/usr/sbin/php-fpm /usr/bin/php', step(self.job, 'Validate inputs'))
def test_secrets_only_in_login_action(self):
self.assertEqual(self.text.count('secrets.'), 2)
lg = step(self.job, 'Login to Gitea')
self.assertIn('secrets.CI_USER', lg)
self.assertIn('secrets.CI_TOKEN', lg)
self.assertNotIn('echo', lg)
def test_job_timeout_covers_the_leg_timeout(self):
jt = int(re.search(r'(?m)^ timeout-minutes: (\d+)$', self.job).group(1))
at = int(re.search(r'timeout-minutes: (\d+)', step(self.job, 'Build arm64')).group(1))
self.assertGreater(jt, at + 20)
if __name__ == '__main__':
unittest.main(verbosity=2)
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
## verify-image-arch.test.sh - scripts/verify-image-arch.py against a stub `docker` that serves
## fabricated ELF headers through `docker cp -L ctr:path -` (a tar stream), like the real one.
set -euo pipefail
HERE=$(cd "$(dirname "$0")/.." && pwd)
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
fail=0
chk() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1: got '$2' want '$3'"; fail=1; fi; }
cat >"$T/mktar.py" <<'PY'
import io, os, struct, sys, tarfile
path = sys.argv[1]
spec = dict(l.rstrip('\n').split('=', 1) for l in open(os.environ['FIX']) if '=' in l).get(path)
if spec is None or spec == 'missing':
sys.stderr.write('Error response from daemon: Could not find the file %s in container\n' % path); sys.exit(1)
if spec == 'notelf': head = b'#!/bin/sh\necho hi\n' + b'\0' * 64
elif spec == 'elf32': head = b'\x7fELF\x01\x01\x01' + b'\0' * 11 + struct.pack('<H', 0x3E) + b'\0' * 60
elif spec == 'be': head = b'\x7fELF\x02\x02\x01' + b'\0' * 11 + struct.pack('>H', 0xB7) + b'\0' * 60
elif spec == 'dir':
t = tarfile.open(fileobj=sys.stdout.buffer, mode='w|'); ti = tarfile.TarInfo('d'); ti.type = tarfile.DIRTYPE; t.addfile(ti); t.close(); sys.exit(0)
else: head = b'\x7fELF\x02\x01\x01' + b'\0' * 11 + struct.pack('<H', int(spec, 16)) + b'\0' * 60
body = head + b'\0' * 200000 # bigger than the pipe buffer: reader must stop early
t = tarfile.open(fileobj=sys.stdout.buffer, mode='w|')
ti = tarfile.TarInfo(os.path.basename(path)); ti.size = len(body); t.addfile(ti, io.BytesIO(body)); t.close()
PY
cat >"$T/dk" <<'STUB'
#!/usr/bin/env bash
echo "$*" >>"$LOG"
case "$1" in
pull) exit "${PULL_RC:-0}" ;;
create) [ "${CREATE_RC:-0}" = 0 ] || { echo "no such image" >&2; exit 1; }; echo cid1 ;;
rm|image) ;;
cp) python3 -I "$MKTAR" "${3#*:}" ;;
esac
STUB
chmod +x "$T/dk"
export DOCKER="$T/dk" FIX=$T/fix LOG=$T/log MKTAR=$T/mktar.py
V="python3 -I $HERE/verify-image-arch.py"
run() { : >"$LOG"; $V "$@" >"$T/out" 2>"$T/err"; echo $?; }
printf '%s\n' /usr/bin/php=b7 /usr/sbin/httpd=b7 >"$T/fix"
chk "arm64 image with aarch64 binaries -> 0" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/sbin/httpd --bin /usr/bin/php)" 0
chk " pulled with the platform flag, container removed" "$(grep -c '^pull --quiet --platform linux/arm64 r/x@sha256:1$\|^rm -f cid1$' "$LOG")" 2
chk " prints AArch64" "$(grep -c 'e_machine=0xB7 (AArch64)' "$T/out")" 2
printf '%s\n' /usr/bin/php=3e >"$T/fix"
chk "arm64 image carrying an x86-64 binary -> 1" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php)" 1
chk " says x86-64 was found" "$(grep -c 'FAIL.*e_machine=0x3E (x86-64), want 0xB7 (AArch64)' "$T/out")" 1
chk "amd64 image with x86-64 binary -> 0" "$(run --image r/x@sha256:1 --platform linux/amd64 --bin /usr/bin/php)" 0
printf '%s\n' /usr/bin/php=b7 >"$T/fix"
chk "amd64 image carrying an aarch64 binary -> 1" "$(run --image r/x@sha256:1 --platform linux/amd64 --bin /usr/bin/php)" 1
printf '%s\n' /usr/bin/php=b7 /usr/sbin/httpd=3e >"$T/fix"
chk "one good + one wrong binary -> 1 (all are checked)" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php --bin /usr/sbin/httpd)" 1
chk " the good one is still reported OK" "$(grep -c '^OK ' "$T/out")" 1
printf '%s\n' /bin/a=notelf /bin/b=elf32 /bin/c=be /bin/d=dir /bin/e=missing >"$T/fix"
for b in a b c d e; do chk "bad binary /bin/$b -> 1" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /bin/$b)" 1; done
chk "binary absent from the fixture -> 1" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/nothere)" 1
printf '%s\n' /usr/bin/php=b7 >"$T/fix"
chk "docker pull fails (3 attempts) -> 4, not an arch verdict" "$(VERIFY_PULL_SLEEP=0 PULL_RC=1 run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php)" 4
chk " pull was tried 3 times" "$(grep -c '^pull' "$LOG")" 3
chk "docker create fails -> 1" "$(CREATE_RC=1 run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php)" 1
chk "pulled image is removed afterwards" "$(run --image r/x@sha256:1 --platform linux/arm64 --bin /usr/bin/php >/dev/null; grep -c '^image rm r/x@sha256:1$' "$LOG")" 1
chk "--no-pull skips the pull" "$(run --image r/x@sha256:1 --platform linux/arm64 --no-pull --bin /usr/bin/php; grep -c '^pull' "$LOG" || true)" "0
0"
chk "usage: no --bin -> 2" "$(run --image r/x --platform linux/arm64)" 2
chk "usage: bad platform -> 2" "$(run --image r/x --platform linux/s390x --bin /usr/bin/php)" 2
[ "$fail" -eq 0 ] && echo "ALL PASS" || { echo FAILURES; exit 1; }
+125
View File
@@ -0,0 +1,125 @@
#!/usr/bin/env python3
"""verify-image-arch.py - prove an image platform really contains binaries of that architecture.
An image whose config says linux/arm64 can still carry x86-64 binaries (the "x86 in arm64"
exec-format-error loop seen with haproxy-manager-base). The registry manifest cannot tell; the ELF
header can. This pulls REF for one platform, copies the named key binaries out of a created (never
started, never executed) container and checks e_machine of each: aarch64 = 0xB7, x86-64 = 0x3E.
Same idea as haproxy-manager-base scripts/verify-image-arch.py (PR #22), adapted to docker cp so
no QEMU execution is needed.
verify-image-arch.py --image REF --platform linux/arm64|linux/amd64 --bin /usr/bin/php [--bin ...]
Exit 0 = every --bin is an ELF64 little-endian binary of the platform's machine type.
Exit 1 = a binary is missing, not an ELF, or of the wrong architecture (or docker failed).
Exit 2 = usage. Exit 4 = could not pull the image (3 attempts): no architecture verdict.
Env: DOCKER overrides the docker command (tests use a stub). Nothing in REF is ever run.
"""
import argparse
import os
import shlex
import subprocess
import sys
import tarfile
import threading
import time
MACHINES = {'linux/arm64': (0xB7, 'AArch64'), 'linux/amd64': (0x3E, 'x86-64')}
NAMES = {0x3E: 'x86-64', 0xB7: 'AArch64', 0x03: 'x86', 0x28: 'ARM', 0xF3: 'RISC-V', 0x15: 'PowerPC64', 0x16: 'S390'}
MAX_STREAM = 1 << 31 # refuse to read more than 2 GiB of one tar stream
def elf_machine(head):
"""Return e_machine of an ELF64 little-endian header, or raise ValueError."""
if len(head) < 20 or head[:4] != b'\x7fELF':
raise ValueError('not an ELF file')
if head[4] != 2:
raise ValueError('not ELF64 (EI_CLASS=%d)' % head[4])
if head[5] != 1:
raise ValueError('not little-endian (EI_DATA=%d)' % head[5])
return int.from_bytes(head[18:20], 'little')
def docker_cmd():
return shlex.split(os.environ.get('DOCKER') or 'docker')
def run(args, timeout=300):
try:
return subprocess.run(docker_cmd() + args, capture_output=True, timeout=timeout)
except subprocess.TimeoutExpired:
return subprocess.CompletedProcess(args, 124, b'', b'timed out after %ds' % timeout)
def first_bytes_of(cid, path):
"""First 64 bytes of the regular file at path (symlinks followed) inside container cid."""
p = subprocess.Popen(docker_cmd() + ['cp', '-L', '%s:%s' % (cid, path), '-'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
timer = threading.Timer(120, p.kill) # a stalled docker cp must not hang the job
timer.start()
try:
tf = tarfile.open(fileobj=p.stdout, mode='r|')
m = tf.next()
if m is None or not m.isreg():
raise ValueError('%s is not a regular file' % path)
return tf.extractfile(m).read(64)
except tarfile.TarError as e:
err = p.stderr.read(300).decode('utf-8', 'replace').strip()
raise ValueError('cannot read %s: %s %s' % (path, e, err))
finally:
timer.cancel()
p.kill()
p.wait()
def main(argv):
ap = argparse.ArgumentParser(description=__doc__.split('\n')[0])
ap.add_argument('--image', required=True)
ap.add_argument('--platform', required=True, choices=sorted(MACHINES))
ap.add_argument('--bin', dest='bins', action='append', required=True)
ap.add_argument('--no-pull', action='store_true', help='image is already in the local store')
a = ap.parse_args(argv)
want, label = MACHINES[a.platform]
pulled = False
if not a.no_pull:
r = None
for attempt in range(3):
r = run(['pull', '--quiet', '--platform', a.platform, a.image], timeout=900)
if r.returncode == 0:
break
time.sleep(float(os.environ.get('VERIFY_PULL_SLEEP', '15')))
if r.returncode != 0:
print('verify-image-arch: could not pull %s after 3 attempts (not an architecture finding): %s' % (
a.image, r.stderr.decode('utf-8', 'replace')[:300].strip()), file=sys.stderr)
return 4
pulled = True
r = run(['create', '--platform', a.platform, '--entrypoint', '/nonexistent', a.image])
cid = r.stdout.decode().strip()
if r.returncode != 0 or not cid:
print('verify-image-arch: docker create failed: %s' % r.stderr.decode('utf-8', 'replace')[:300].strip(), file=sys.stderr)
return 1
rc = 0
try:
for path in a.bins:
try:
m = elf_machine(first_bytes_of(cid, path))
except ValueError as e:
print('FAIL %s %s %s: %s' % (a.image, a.platform, path, e))
rc = 1
continue
if m != want:
print('FAIL %s %s %s: e_machine=0x%X (%s), want 0x%X (%s)' % (
a.image, a.platform, path, m, NAMES.get(m, '?'), want, label))
rc = 1
else:
print('OK %s %s %s: e_machine=0x%X (%s)' % (a.image, a.platform, path, m, label))
finally:
run(['rm', '-f', cid], timeout=120)
if pulled:
run(['image', 'rm', a.image], timeout=120) # keep the runner disk from filling
return rc
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))