Make Docker Compose setup production-ready
- Require a login: HTTP Basic auth from CASHBOOK_PASSWORD (compose refuses to start without it); /healthz stays open for health checks - Run as non-root (1000:1000 by default, CASHBOOK_USER to override) with a read-only filesystem, tmpfs /tmp, no capabilities, no-new-privileges, and CPU/memory/pid limits - Health check, log rotation, configurable bind address and port - Refuse cross-origin POSTs by matching Origin to Host (works behind a reverse proxy), cap request size, add security headers, and stop leaking exception text in 500 responses - Make the extra statements mount opt-in; create the data folder at startup; document server setup and reverse proxying in the README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
971de14356
commit
9b9203c4bb
5 files changed
+192
-36
No files matched your search
+40
-7
@@ -1,15 +1,48 @@
|
||||
services:
|
||||
cashbook:
|
||||
build: .
|
||||
image: accounts-cashbook:latest
|
||||
init: true
|
||||
# Rootless Docker maps container root to you, so files stay owned by you.
|
||||
# With rootful Docker, set CASHBOOK_USER=1000:1000 (your uid:gid) instead.
|
||||
user: "${CASHBOOK_USER:-0:0}"
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 20s
|
||||
|
||||
# Run as the owner of ./data so saved books stay owned by them on the host.
|
||||
# Rootless Docker maps container root to you instead: set CASHBOOK_USER=0:0.
|
||||
user: "${CASHBOOK_USER:-1000:1000}"
|
||||
|
||||
# Only published on localhost by default; put a TLS reverse proxy in front
|
||||
# to reach it from elsewhere (set CASHBOOK_BIND=0.0.0.0 only behind a firewall).
|
||||
ports:
|
||||
- "127.0.0.1:8765:8765"
|
||||
- "${CASHBOOK_BIND:-127.0.0.1}:${CASHBOOK_PORT:-8765}:8765"
|
||||
|
||||
# Browser login (HTTP Basic). Set CASHBOOK_PASSWORD in .env; compose won't start without it.
|
||||
environment:
|
||||
CASHBOOK_USERNAME: "${CASHBOOK_USERNAME:-cashbook}"
|
||||
CASHBOOK_PASSWORD: "${CASHBOOK_PASSWORD:?set CASHBOOK_PASSWORD in .env}"
|
||||
|
||||
volumes:
|
||||
# cashbooks and statements/ (uploads go there too)
|
||||
- ./data:/data
|
||||
# ANZ CSV exports, read-only
|
||||
- ${HOME}/Downloads/anz:/statements:ro
|
||||
restart: unless-stopped
|
||||
# optional: a folder of ANZ exports to pick from, read-only
|
||||
# - /path/to/anz:/statements:ro
|
||||
|
||||
# Locked down: read-only image, scratch space in /tmp, no extra privileges
|
||||
read_only: true
|
||||
tmpfs:
|
||||
- /tmp:size=512m,mode=1777
|
||||
cap_drop:
|
||||
- ALL
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
pids_limit: 256
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: 1g
|
||||
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: 10m
|
||||
max-file: "3"
|
||||
Reference in new issue
Block a user