services:
  app:
    build:
      context: .
      target: runner
    restart: unless-stopped
    ports:
      - "${APP_PORT:-3000}:3000"
    volumes:
      - sqlite_data:/app/storage
    env_file: .env
    environment:
      - DATABASE_URL=file:/app/storage/jboard.db
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3000/api/public/app-info || exit 1"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  # 数据库初始化：首次部署或 schema 变更时运行
  # docker compose run --rm init
  init:
    build:
      context: .
      target: init
    volumes:
      - sqlite_data:/app/storage
    env_file: .env
    environment:
      - DATABASE_URL=file:/app/storage/jboard.db
    profiles:
      - setup

volumes:
  sqlite_data:
