Keep the database in ./data and bind-mount it
SQLite writes three files — the database plus its -wal and -shm companions. Putting them in one directory means a deployment mounts a single path and a backup copies a single directory. - FOODSTER_DB defaults to ./data/foodster.db, and openDB creates the parent directory on startup rather than failing on a fresh checkout - compose bind-mounts ./data instead of using a named volume, so the file can be listed, copied and opened with any sqlite client without going through the container engine - the image runs as UID 65534, which cannot write to a host directory owned by someone else, so compose now sets user: from FOODSTER_UID/FOODSTER_GID - `make up` creates ./data first: left to the engine it appears root-owned and the app silently cannot write to it
This commit is contained in:
+6
-4
@@ -2,6 +2,11 @@ services:
|
||||
app:
|
||||
image: ${FOODSTER_REPO:?set FOODSTER_REPO in .env}:${FOODSTER_TAG:-latest}
|
||||
restart: unless-stopped
|
||||
# A bind mount rather than a named volume: the database sits in ./data on
|
||||
# the host, where it can be listed, copied and backed up without going
|
||||
# through the container engine. The image runs as UID 65534, so the
|
||||
# container has to be told which host user owns that directory.
|
||||
user: "${FOODSTER_UID:-1000}:${FOODSTER_GID:-1000}"
|
||||
ports:
|
||||
- "${FOODSTER_PORT:-8080}:8080"
|
||||
environment:
|
||||
@@ -9,7 +14,4 @@ services:
|
||||
FOODSTER_DB: /data/foodster.db
|
||||
TZ: ${TZ:-Europe/Helsinki}
|
||||
volumes:
|
||||
- foodster-data:/data
|
||||
|
||||
volumes:
|
||||
foodster-data:
|
||||
- ./data:/data
|
||||
|
||||
Reference in New Issue
Block a user