Slim down server compose: entrypoint roles, self-migrating image
- docker-entrypoint.sh: `web` (default) or `worker`; both apply pending migrations under a flock on /data, so no start-order dependency - docker-healthcheck.sh baked into the image for both roles - deploy/compose.yaml reduced to image, role, env file, volumes, port - dist/migrate.mjs bundled alongside the worker Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
30b01d7bca
commit
fbcdcf2e2d
8 files changed
+65
-72
No files matched your search
+8
-24
@@ -1,44 +1,28 @@
|
||||
# Builds the image from this checkout. For the server use deploy/compose.yaml (released image).
|
||||
name: kaname
|
||||
|
||||
x-app: &app
|
||||
image: kaname:local
|
||||
build: .
|
||||
env_file: .env
|
||||
# Container paths override whatever local-dev paths are in .env.
|
||||
# Container paths win over local-dev paths in .env.
|
||||
environment:
|
||||
DATABASE_URL: file:/data/app.db
|
||||
MODELS_DIR: /models
|
||||
HF_HOME: /data/hf-home
|
||||
restart: unless-stopped
|
||||
init: true # reaps child processes (hf) and forwards signals
|
||||
|
||||
services:
|
||||
worker:
|
||||
<<: *app
|
||||
command: ["node", "dist/worker.mjs"]
|
||||
volumes:
|
||||
- data:/data
|
||||
- models:/models
|
||||
# Give running downloads time to stop cleanly (they are marked "interrupted").
|
||||
stop_grace_period: 20s
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "find /tmp/kaname-worker-alive -mmin -1 | grep -q ."]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
start_period: 30s
|
||||
retries: 3
|
||||
command: worker
|
||||
volumes: [data:/data, models:/models]
|
||||
|
||||
web:
|
||||
<<: *app
|
||||
command: ["node_modules/.bin/next", "start"]
|
||||
ports:
|
||||
- "${WEB_PORT:-3000}:3000"
|
||||
volumes:
|
||||
- data:/data
|
||||
depends_on:
|
||||
worker:
|
||||
condition: service_healthy # worker applies DB migrations on startup
|
||||
ports: ["${WEB_PORT:-3000}:3000"]
|
||||
volumes: [data:/data]
|
||||
|
||||
volumes:
|
||||
data: # SQLite + hf home; keep on local disk (SQLite and NFS don't mix)
|
||||
models: # downloaded models; will become an NFS mount from TrueNAS
|
||||
data:
|
||||
models:
|
||||
Reference in new issue
Block a user