Repository navigation
build(images): slim the Postgres image and build each platform natively - #248
Merged
Merged
Conversation
The Postgres image no longer builds from main: apt.postgresql.org has dropped the pinned postgis, pg_cron, pg_repack, and hypopg versions. Move every extension to its current pgdg package and pin both base images by digest, so later rebuilds are reproducible. pgvector now compiles in its own stage and downloads happen in a separate fetch stage. The final image no longer carries binutils, dpkg-dev, cpp, libcrypt-dev, curl, or unzip (about 19 MB). The pgvectorscale package is bind-mounted rather than copied. ca-certificates is installed explicitly: the old image had it only as a side effect of the build step, and WAL-G needs it for TLS. The Postgres workflow builds each platform on a native runner instead of compiling arm64 under QEMU, caches layers per platform, verifies each pushed platform candidate, and moves the 18 tag only after both pass. It also fails if build tools or the CA bundle regress. The discovery image drops QEMU, which it never needed, and reuses the gha layer cache from main in releases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Probe readiness over TCP. The entrypoint's init server listens only on the Unix socket, so a socket probe could pass before the real server started and psql then failed (2 of 3 local runs). - Before promoting :18, assert the merged index holds exactly amd64 and arm64, each at the digest its own runner verified. - Extend the build-tool guard to clang, llvm-config, and unzip. - Declare PGVECTORSCALE_VERSION once, as a global ARG. - Run the fetch stage on the build platform; it only downloads. - Correct the comments: the digest pins do not make apt pins reproducible, pgvector's headers do ship, and PG_MAJOR must match the base image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pinning the base images by digest stopped PostgreSQL minor releases and Debian security fixes from reaching hosts on their own, and pgdg drops old extension builds, so the apt pins go stale too. postgres-bump.sh moves POSTGRES_IMAGE and DEBIAN_IMAGE to their tag's current digest and each pgdg package to the newest build the new base offers. A weekly workflow runs it, pushes bot/postgres-image-bump, builds and smoke-tests both platforms on native runners, and then opens or updates the pull request. Merging it republishes onebox-postgres:18. The smoke test moves to postgres-verify.sh so the publish and bump workflows run the same checks. A pull request opened with GITHUB_TOKEN starts no workflows, so the bump uses POSTGRES_BUMP_TOKEN when that secret exists; otherwise the body says to close and reopen. The CLA allowlist gains github-actions[bot], which authors the bump commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Push the bump to a per-run candidate branch and move the pull request branch only after both platforms pass, so an open pull request never carries unverified pins. A cleanup job deletes failed candidates. - Move a package pin only to a build both amd64 and arm64 offer; pgdg can publish one architecture first. - Fail loudly when apt-get update fails instead of reporting every package as missing. - Refuse to run when PG_MAJOR does not match the POSTGRES_IMAGE tag. - Always bump main, whatever ref dispatched the run. - Read main's layer cache but never write it from an unmerged bump. - Drop the unneeded buildx setup and extra fetch depth, note the repo setting the GITHUB_TOKEN fallback needs, and fix the Dockerfile comment on what republishes the image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Postgres image (
build/package/postgres.Dockerfile)maincannot rebuild the image today. Every extension moves to its current pgdg package:postgres:18-trixieanddebian:trixie-slimby digest.fetchstage. The final image no longer contains binutils, dpkg-dev, cpp, libcrypt-dev, curl or unzip, which saves about 19 MB on disk. Upstream GDAL 3.9 grew by about the same amount, so the net size change is close to zero (amd64 adds 276 MB over the base instead of 278 MB)..debinstead of copying it, so no layer contains it.ca-certificatesexplicitly. The old image had it only because the build step happened to install it, and WAL-G needs it for TLS to object storage.Postgres workflow
ubuntu-24.04andubuntu-24.04-arm) instead of compiling arm64 under QEMU.18tag moves only after both platforms pass. The image is now built once instead of twice (verify and publish).Discovery image
discovery-image.ymlandrelease.yml. The Go stage cross-compiles on the build platform and thescratchstage runs no commands, so nothing needs emulation.main. Releases reuse that cache.Weekly pin bump (
postgres-image-bump.yml)build/package/postgres-bump.shmoves both base images to their tag's current digest and each pgdg package to its newest build.build/package/postgres-verify.sh. Then it opens or updates a pull request frombot/postgres-image-bump.GITHUB_TOKENstart no workflows, so the required checks wouldn't run. Add aPOSTGRES_BUMP_TOKENsecret (a fine-grained token with contents and pull-requests write) to fix that. Without it, the PR body says to close and reopen the PR.github-actions[bot], which authors the bump commits.Why this is correct
wal-g --version.onebox-postgres:18, created all extensions, and added data with spatial and vector indexes. Then I started the new image on the same volume. Queries returned correct results before anyALTER EXTENSION.postgis_extensions_upgrade()andALTER EXTENSION … UPDATEfor pgaudit, pg_partman and hypopg all succeeded.just checkpasses.actionlintpasses; shellcheck ran separately on the verify script, the bump script, and every workflowrunblock.workflow_dispatchneeds the file onmain).The native arm64 runner and the merge step run only on
main, so their first real run happens after merge.Effect on the safety envelope
After merge, the workflow republishes
ghcr.io/labstack/onebox-postgres:18. Each host picks up the new image on its next pull, which restarts Postgres: brief database downtime for each app. Existing databases keep their current extension versions until someone runsALTER EXTENSION … UPDATE; Onebox never runs it. Merge at a quiet time, then check on goal and monk that Postgres starts and WAL archiving works (pg_stat_archiver). No change toobbehaviour or to the capabilities reference.Checklist
just checkpasses locally.just checkverifies this).🤖 Generated with Claude Code