feat(postgres): bundle top-10 extensions in the appwrite/postgres image#2
feat(postgres): bundle top-10 extensions in the appwrite/postgres image#2abnegate wants to merge 2 commits into
Conversation
Dedicated Postgres databases (and VectorsDB) need the most-used extensions available out of the box. Compile pgvector, PostGIS, and pg_cron into the image (the seven contrib extensions already ship in the base image) and set shared_preload_libraries = 'pg_stat_statements,pg_cron' in the cluster config template, since preload libraries must be set before the server starts and edge sets no Postgres config at runtime. Build for every major version Cloud advertises (Postgres 17 and 18) via a PG_MAJOR build arg and a CI matrix, tagging per major so the version -> image mapping keeps working. A build-and-verify workflow boots each image on PRs and asserts all ten extensions are available, install via CREATE EXTENSION, and that the two preload extensions actually load. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances the appwrite/postgres Docker image so it ships with (and verifies) a curated set of commonly used PostgreSQL extensions across supported major versions (17 and 18), and adds CI to build/test the image on PRs.
Changes:
- Parameterize the Docker build by
PG_MAJORand install pgvector, PostGIS, and pg_cron packages for that major. - Add CI workflow to build (PG 17/18) and run a container-based verification script on PRs/pushes.
- Update publishing workflow to push per-major tags and add user-facing documentation for the image and tags.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
Dockerfile |
Adds PG_MAJOR build arg and installs required extension packages; appends preload config to the sample config template. |
tests/verify.sh |
New runtime verification that extensions are available/installable and preload libraries are active. |
.github/workflows/build.yml |
New PR/push CI to build images for PG 17/18 and run tests/verify.sh. |
.github/workflows/publish.yml |
Publishes multi-arch images with a PG-major matrix and per-major tag scheme. |
docker-compose.yml |
Forwards PG_MAJOR into the image build for local use. |
README.md |
Documents bundled extensions, preload behavior, and tagging scheme. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| jobid="$(psql "SELECT cron.schedule('verify-job','* * * * *','SELECT 1');")" | ||
| if [[ "$jobid" =~ ^[0-9]+$ ]]; then | ||
| echo "PASS: pg_cron.schedule returned job $jobid" | ||
| psql "SELECT cron.unschedule('verify-job');" >/dev/null | ||
| else |
Greptile SummaryThis PR bundles the ten most-used PostgreSQL extensions (
Confidence Score: 5/5Safe to merge — the Dockerfile changes are straightforward package installations and a single config-file append, and the tag matrix logic in the publish workflow is correct and backward-compatible. All core changes — Dockerfile parametrisation, extension installation, preload config, CI workflow, and tag matrix — are well-structured and the author verified both majors locally and in CI. The two findings are non-blocking quality suggestions. .github/workflows/publish.yml for the missing layer cache; .github/workflows/build.yml for the arm64 testing gap relative to what publish produces. Important Files Changed
Reviews (2): Last reviewed commit: "test(postgres): harden verify.sh and dro..." | Re-trigger Greptile |
Address review feedback on the verification script and workflows: - CREATE EXTENSION now asserts the exact "CREATE EXTENSION" success string, so empty output from a crashed container no longer counts as success. - Unschedule the pg_cron job by its numeric id rather than name, and report <no output> on empty results consistently. - Assert on postgis_version() like the other runtime usability checks instead of only printing it. - Remove the unused VERSION build-arg from publish.yml (the Dockerfile never declared ARG VERSION). - Cache the apt layer across build-verify runs with the GitHub Actions cache. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Implements DAT-1666. Bundles the ten most-used PostgreSQL extensions into the
appwrite/postgresimage so they are available out of the box for dedicated Postgres databases (and the VectorsDB product), built for every major version Cloud advertises.What changed
Dockerfile: parameterised byPG_MAJOR(default18). Installspgvector,postgis(+ scripts), andpg_cronfrom PGDG. The other seven extensions already ship compiled in the basepostgresimage, so no extra package is needed for them. Setsshared_preload_librariesin the cluster config template..github/workflows/build.yml(new): builds both majors on every PR and push tomain, then boots each image and runstests/verify.sh. This gives the repo real PR CI (previously it only built on tag push)..github/workflows/publish.yml: now aPG_MAJORmatrix (17,18) producing per-major tags.tests/verify.sh(new): boots the image and asserts every extension is available, installs viaCREATE EXTENSION, and that both preload extensions actually load.docker-compose.yml: forwards thePG_MAJORbuild arg.README.md(new): documents extensions, preload config, and the tag scheme.The 10 extensions
CREATE EXTENSIONvectorpg_stat_statementsuuid-ossppgcryptopg_trgmpostgiscitextunaccenthstorepg_cronPreload config
pg_stat_statementsandpg_cronrequireshared_preload_libraries, which must be set before the server starts (a runtimeCREATE EXTENSIONalone will not load them). The image appends this topostgresql.conf.sample, so it applies to every clusterinitdbcreates with no runtime configuration from edge:Tags produced
Publishing a release tag (e.g.
0.2.0) produces, per major:appwrite/postgres:18,appwrite/postgres:17— floating per-major tag (what the edge wiring in DAT-1667 will select viaversion)appwrite/postgres:18-0.2.0,appwrite/postgres:17-0.2.0— immutable major + releaseappwrite/postgres:0.2.0,appwrite/postgres:latest— default major (18), preserving the current single-tag mapping edge uses today (_APP_DATABASE_POSTGRES_IMAGE_VERSION) so nothing breaks before DAT-1667 landsVerification
Built and booted both PG 17 and PG 18 locally (native arm64) via the committed
tests/verify.sh. All checks passed for both:pg_available_extensionsCREATE EXTENSION IF NOT EXISTSsucceeds for all 10SHOW shared_preload_libraries=pg_stat_statements,pg_cronpg_stat_statementsview queryable andcron.schedule(...)returns a job id (both preload extensions actually loaded)vectordistance operator andpostgis_version()(3.6) workServer versions: PG 18.4, PG 17.10. hadolint and shellcheck clean. The CI workflow runs this same verification (linux/amd64) on the PR.
Follow-up
Does not merge. This image unblocks DAT-1667 (wire the custom
appwrite/postgresimage into edge for all Postgres dedicated DBs, selecting the per-major tag byversion) and DAT-1668 (blue-green image-version bumps).🤖 Generated with Claude Code