From 5e5a14030a95dd245b2bc9cb2520a40cdffa4ba3 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Thu, 6 Aug 2026 10:20:27 +0200 Subject: [PATCH] chore(docker): refine compose for named volume server deploy Use a named SQLite volume, healthcheck, and clearer production env examples. Co-authored-by: Cursor --- .env.docker.example | 12 +++++++----- docker-compose.yml | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.env.docker.example b/.env.docker.example index 6c81248..5bcccf2 100644 --- a/.env.docker.example +++ b/.env.docker.example @@ -1,5 +1,7 @@ -# Copy to .env.docker for docker compose (gitignored). -# Do not commit real secrets. - -JWT_SECRET=replace-with-a-strong-secret -CORS_ORIGIN=http://localhost:5174 +# Copy to .env.docker on the server (never commit real secrets). +# +# Required in production: +JWT_SECRET=replace-with-a-long-random-secret +# +# Frontend origin (your deployed Vue app URL): +CORS_ORIGIN=https://your-frontend-domain.example diff --git a/docker-compose.yml b/docker-compose.yml index cfded23..1c4efb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,10 @@ services: build: context: . dockerfile: Dockerfile + image: child-gold-land-backend:latest container_name: child-gold-land-backend ports: - - "3000:3000" + - "${PORT:-3000}:3000" env_file: - .env.docker environment: @@ -14,5 +15,23 @@ services: HOST: 0.0.0.0 DB_PATH: /app/data/app.db volumes: - - ./docker-data:/app/data + # Persistent SQLite storage (WAL/SHM live here too). + # On server, replace with e.g. /var/lib/child-gold-land/data:/app/data + - sqlite_data:/app/data restart: unless-stopped + healthcheck: + test: + [ + "CMD", + "node", + "-e", + "fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))", + ] + interval: 30s + timeout: 5s + retries: 3 + start_period: 20s + +volumes: + sqlite_data: + name: child-gold-land-sqlite