refactor(docker): split scriptor-app into data + uploads volumes#52
Merged
Conversation
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.
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.
The previous setup mounted a single named volume
scriptor-appover the entire/var/www/scriptorin both containers. Docker only copy-initialises a named volume from the image once, so subsequentdocker compose up -d --buildupdates rebuilt the image but the running container kept reading the OLD code from the volume — making code updates requiredocker 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:
Migration on existing deployments: a one-time
docker compose down -vis needed (the oldscriptor-appvolume is no longer referenced and can bedocker volume rm'd). After that, code updates flow through cleanly without ever touching state again.