Skip to content

fix(docker): move Postgres to a named volume and bump to Postgres 18 (beta)#487

Merged
therealbrad merged 1 commit into
betafrom
fix/postgres-bind-mount-ownership-beta
Jul 1, 2026
Merged

fix(docker): move Postgres to a named volume and bump to Postgres 18 (beta)#487
therealbrad merged 1 commit into
betafrom
fix/postgres-bind-mount-ownership-beta

Conversation

@therealbrad

Copy link
Copy Markdown
Contributor

Description

Ports the fix from #486 (targeting main) to beta. Fixes #485: docker compose build prod fails at the [internal] load build context step with a permission error on docker-data/postgres.

Root cause: the compose files bind-mount ./docker-data/postgres directly onto /var/lib/postgresql/data. Once Postgres has run, it locks that directory down to 0700. The app builds use context: .. (the repo root), so that directory sits inside the build context. BuildKit's context sender needs to stat/read every entry under the context root — a permission-denied directory there aborts the whole context transfer, regardless of .dockerignore rules, since the walk fails before exclusion patterns are applied. Verified empirically on #486 (see that PR for the full repro/verification writeup); this PR applies the same verified fix to the files tracked on beta.

Changes

  • Postgres now uses a named Docker volume (testplanit-postgres-data) instead of a bind mount, in both compose files tracked on this branch (docker-compose.yml, docker-compose.dev.yml).
  • Fixed the .dockerignore inconsistency across all three ignore files (hygiene; verified insufficient alone for this bug in fix(docker): move Postgres to a named volume and bump to Postgres 18 #486).
  • Bumped Postgres 15 → 18 (three majors behind current stable) while in here. Pinned PGDATA=/var/lib/postgresql/data since the 18+ image defaults to a version-specific subdirectory and expects the volume mounted at /var/lib/postgresql instead of .../data (docker-library/postgres#1259) — reproduced locally — and the new layout has a still-open detection bug (docker-library/postgres#1400) that also reproduced reliably in testing.
  • Docs updated (docker-setup.md, deployment.md) with the new data-persistence layout, backup/restore commands, and a migration note for existing deployments (Postgres 18 can't read a Postgres 15 data directory, so this needs a real pg_dump/pg_restore, not a raw file copy).

Note on docker-compose.prod.yml

That file isn't tracked on beta — it was removed in db5cfd83a ("remove prod compose from tracking; add to gitignore") because it contains server-specific IPs, and isn't touched by this PR. Whoever maintains that file's local/server copy needs the equivalent change (named volume + PGDATA pin + Postgres 18 tag) applied manually.

Related Issue

Relates to #485 (fixed on main via #486; this ports the same fix to beta)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)

Breaking in the sense that existing deployments must run the documented pg_dump/pg_restore migration before their next docker compose build/up.

How Has This Been Tested?

  • Manual testing

Same verification approach as #486, re-run against this branch's actual files:

  • Brought up postgres from docker-compose.yml (dev profile) with the named-volume override — reports healthy, SELECT version() confirms PostgreSQL 18.4.
  • Ran a full down / up cycle — a marker row written before the restart survives after, confirming the named volume persists data correctly across container recreation.
  • Validated docker compose config resolves cleanly for both tracked compose files.
  • Content is otherwise identical to what was Prettier-checked and build/integration-tested on main in fix(docker): move Postgres to a named volume and bump to Postgres 18 #486 (this worktree had no local node_modules to re-run Prettier against, but the patch applied via git apply --check with zero fuzz, confirming byte-identical content).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have signed the CLA

Additional Notes

None of this touches application source, tests, or types.

Ports the fix from #486 (main) to beta: docker compose build fails at
"load build context" because Postgres locks ./docker-data/postgres down
to 0700 once it's run, and BuildKit's context walker aborts on any
permission-denied entry under the build context root regardless of
.dockerignore rules. Switch Postgres to the named volume
testplanit-postgres-data across both compose files tracked on this
branch, so its data can never live inside the build context again.
Also fixes the .dockerignore inconsistency across the three ignore
files (hygiene; verified insufficient alone for this bug).

Also bumps Postgres 15 -> 18 (three majors behind current stable), pinning
PGDATA back to the old flat path since the 18+ image defaults to a
version-specific subdirectory and expects the volume mounted at
/var/lib/postgresql instead of .../data (docker-library/postgres#1259),
and the new layout has a still-open detection bug
(docker-library/postgres#1400) that reproduced reliably in testing.

Verified on this branch's actual files: postgres:18-alpine starts
healthy, and data survives a full down/up cycle.

Note: docker-compose.prod.yml is not tracked on this branch (removed in
db5cfd8 for containing server-specific IPs) and is not touched here;
whoever maintains that file's local/server copy needs the equivalent
change (named volume + PGDATA pin) applied manually.
@therealbrad
therealbrad merged commit 2bcd256 into beta Jul 1, 2026
@therealbrad
therealbrad deleted the fix/postgres-bind-mount-ownership-beta branch July 1, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant