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:
@@ -31,10 +31,8 @@ build: generate ## Build ./foodster
|
||||
CGO_ENABLED=0 go build -trimpath \
|
||||
-ldflags="-s -w -X main.version=dev" -o $(BIN) $(PKG)
|
||||
|
||||
run: generate ## Run locally on :8080
|
||||
FOODSTER_PASSWORD=$${FOODSTER_PASSWORD:-dev} \
|
||||
FOODSTER_DB=$${FOODSTER_DB:-./foodster.db} \
|
||||
go run $(PKG)
|
||||
run: generate ## Run locally on :8080 (database in ./data)
|
||||
FOODSTER_PASSWORD=$${FOODSTER_PASSWORD:-dev} go run $(PKG)
|
||||
|
||||
seed: ## Import a dish bundle (SEED=seeds/testi.json)
|
||||
go run $(PKG) -import $(SEED)
|
||||
@@ -84,6 +82,7 @@ push: ## Push the newest tag and :latest
|
||||
release: image push ## Build, tag and push in one go
|
||||
|
||||
up: ## Start the stack
|
||||
@mkdir -p data # or the engine creates it root-owned and the app cannot write
|
||||
$(COMPOSE) up -d
|
||||
|
||||
down: ## Stop the stack
|
||||
|
||||
Reference in New Issue
Block a user