Files
HangmanLab.Server.T1/docker-compose.yml
hzhang 5c10d6d4c2 Add HarborForge stack to docker-compose
- Add hf_db_init sidecar that ensures the HarborForge database exists on
  every `compose up` (idempotent CREATE DATABASE IF NOT EXISTS), so the
  shared MySQL instance can host both hangmanlab and harborforge schemas
  without touching existing data.
- Wire hf_backend's DATABASE_URL directly from compose env vars and gate
  it on hf_db_init completing successfully.
- Add a mysqladmin-ping healthcheck on mysql so dependents can wait on
  service_healthy.
- Drop dead Vite runtime envs from hf_frontend (build-time only) and
  make wizard CORS_ORIGINS configurable via HF_FRONTEND_HOST.
- Seed .env.example with all variables the stack reads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-15 07:18:47 +01:00

118 lines
2.7 KiB
YAML

services:
backend:
image: git.hangman-lab.top/hzhang/hangmanlab-backend:latest
ports:
- "$BACKEND_PORT:$BACKEND_PORT"
env_file:
- .env
depends_on:
- mysql
networks:
- app-network
volumes:
- backend_dump:/app/dump
frontend:
image: git.hangman-lab.top/hzhang/hangmanlab-frontend:latest
ports:
- "$FRONTEND_PORT:80"
env_file:
- .env
depends_on:
- backend
networks:
- app-network
mysql:
image: mysql:8.0
container_name: mysql
ports:
- "$DB_PORT:$DB_PORT"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
networks:
- app-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
hf_db_init:
image: mysql:8.0
restart: "no"
environment:
MYSQL_HOST: mysql
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
DB_USER: ${DB_USER}
HF_DB_NAME: ${HF_DB_NAME:-harborforge}
volumes:
- ./mysql-init/10-harborforge.sh:/init/10-harborforge.sh:ro
entrypoint: ["/bin/sh", "/init/10-harborforge.sh"]
depends_on:
mysql:
condition: service_healthy
networks:
- app-network
hf_backend:
image: git.hangman-lab.top/zhi/harborforge-backend:multi-stage
restart: "no"
ports:
- "$HF_BACKEND_PORT:8000"
volumes:
- wizard_config:/config:ro
environment:
CONFIG_DIR: /config
CONFIG_FILE: harborforge.json
SECRET_KEY: ${HF_SECRET_KEY:-change_me_in_production}
LOG_LEVEL: ${HF_LOG_LEVEL:-INFO}
DATABASE_URL: mysql+pymysql://${DB_USER}:${DB_PASSWORD}@mysql:3306/${HF_DB_NAME:-harborforge}
depends_on:
hf_db_init:
condition: service_completed_successfully
networks:
- app-network
wizard:
image: git.hangman-lab.top/nav/abstract-wizard:latest
ports:
- "$WIZARD_PORT:8080"
volumes:
- wizard_config:/config
environment:
CONFIG_DIR: /config
LISTEN_ADDR: "0.0.0.0:8080"
MAX_BACKUPS: "5"
CORS_ORIGINS: ${HF_FRONTEND_HOST}
networks:
- app-network
hf_frontend:
image: git.hangman-lab.top/zhi/harborforge-frontend:latest
ports:
- "$HF_FRONTEND_PORT:3000"
environment:
FRONTEND_DEV_MODE: ${HF_FRONTEND_DEV_MODE:-0}
NODE_ENV: production
depends_on:
- wizard
- hf_backend
networks:
- app-network
networks:
app-network:
driver: bridge
volumes:
mysql_data:
backend_dump:
wizard_config: