# 云端部署配置 — 仅启动应用容器，PG/Redis 使用宿主机已安装的服务
# 使用方式: docker compose -f docker/docker-compose.cloud.yml up -d
#
# 前置条件:
#   1. 宿主机已安装 PostgreSQL 16 + Redis 7
#   2. PostgreSQL 已创建数据库和用户
#   3. 复制 .env.production.example 为 .env.production 并填写实际值
#   4. OpenResty 反代配置:
#      - /api/* → http://localhost:3000
#      - /uploads/* → http://localhost:3000
#      - / → 前端静态文件 (挂载 /opt/hms/static/)

services:
  app:
    build:
      context: ..
      dockerfile: Dockerfile
    container_name: hms-server
    restart: unless-stopped
    network_mode: host
    env_file:
      - .env.production
    volumes:
      - ../uploads:/app/uploads
      - ../config:/app/config:ro
      - ../static:/app/static
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/api/v1/health"]
      interval: 30s
      timeout: 5s
      start_period: 60s
      retries: 3
    deploy:
      resources:
        limits:
          cpus: "2"
          memory: 1024M
        reservations:
          cpus: "0.5"
          memory: 256M
