Skip to content

refactor(docker): split scriptor-app into data + uploads volumes#52

Merged
bigin merged 1 commit into
masterfrom
refactor/docker-volume-split
May 15, 2026
Merged

refactor(docker): split scriptor-app into data + uploads volumes#52
bigin merged 1 commit into
masterfrom
refactor/docker-volume-split

Conversation

@bigin
Copy link
Copy Markdown
Owner

@bigin bigin commented May 15, 2026

The previous setup mounted a single named volume scriptor-app over the entire /var/www/scriptor in both containers. Docker only copy-initialises a named volume from the image once, so subsequent docker compose up -d --build updates rebuilt the image but the running container kept reading the OLD code from the volume — making code updates require docker compose down -v, which also wipes the demo DB and uploads.

This split puts code in the IMAGES (rebuilt fresh on every build) and only mutable state in named volumes:

scriptor-data → /var/www/scriptor/data
scriptor-uploads → /var/www/scriptor/public/uploads

The web service now builds from a tiny new docker/Dockerfile.web that bakes public/ into nginx:alpine — both containers have an identical public/ tree, so SCRIPT_FILENAME paths resolve in both when nginx forwards .php to fastcgi. The web container also mounts scriptor-uploads:ro so it can serve user uploads.

Verified locally on macOS Docker 28.1:

  • up -d --build → both containers healthy, smoke matrix passes
  • down (no -v) + up → DB bytes + mtime preserved exactly
  • simulate code change + up -d --build → new code in container, DB still at original bytes + mtime
  • down -v → both volumes removed, fresh seed on next up

Migration on existing deployments: a one-time docker compose down -v is needed (the old scriptor-app volume is no longer referenced and can be docker volume rm'd). After that, code updates flow through cleanly without ever touching state again.

The previous setup mounted a single named volume `scriptor-app` over
the entire `/var/www/scriptor` in both containers. Docker only
copy-initialises a named volume from the image once, so subsequent
`docker compose up -d --build` updates rebuilt the image but the
running container kept reading the OLD code from the volume —
making code updates require `docker compose down -v`, which also
wipes the demo DB and uploads.

This split puts code in the IMAGES (rebuilt fresh on every build)
and only mutable state in named volumes:

  scriptor-data    → /var/www/scriptor/data
  scriptor-uploads → /var/www/scriptor/public/uploads

The web service now builds from a tiny new docker/Dockerfile.web
that bakes public/ into nginx:alpine — both containers have an
identical public/ tree, so SCRIPT_FILENAME paths resolve in both
when nginx forwards .php to fastcgi. The web container also
mounts scriptor-uploads:ro so it can serve user uploads.

Verified locally on macOS Docker 28.1:
  - up -d --build → both containers healthy, smoke matrix passes
  - down (no -v) + up → DB bytes + mtime preserved exactly
  - simulate code change + up -d --build → new code in container,
    DB still at original bytes + mtime
  - down -v → both volumes removed, fresh seed on next up

Migration on existing deployments: a one-time `docker compose
down -v` is needed (the old `scriptor-app` volume is no longer
referenced and can be `docker volume rm`'d). After that, code
updates flow through cleanly without ever touching state again.
@bigin bigin merged commit 3f4c8d6 into master May 15, 2026
@bigin bigin deleted the refactor/docker-volume-split branch May 15, 2026 07:51
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