# Reactive Resume / QNAP QTS 纯净模板。
# 使用前请填写：
# - NAS 数据目录，例如 /share/Container/Reactive_Resume
# - APP_URL，例如 https://resume.example.com
# - 本地访问端口，例如 3004
# - PostgreSQL 密码、AUTH_SECRET、ENCRYPTION_SECRET
# - FRP serverAddr/serverPort/token/proxy name/remotePort

name: reactive-resume-nas

services:
  reactive_resume_permissions:
    image: alpine:3.20
    restart: "no"
    command: ["sh", "-c", "mkdir -p /app/data && chown -R 1000:1000 /app/data"]
    volumes:
      # 待填写：改成你的 NAS 数据目录。
      - /share/Container/CHANGE_ME_REACTIVE_RESUME/data/uploads:/app/data

  reactive_resume_db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: reactive_resume
      POSTGRES_USER: reactive_resume
      POSTGRES_PASSWORD: CHANGE_ME_POSTGRES_PASSWORD
    volumes:
      # 待填写：改成你的 NAS 数据目录。
      - /share/Container/CHANGE_ME_REACTIVE_RESUME/data/postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U reactive_resume -d reactive_resume"]
      interval: 10s
      timeout: 5s
      retries: 10

  reactive_resume_app:
    image: amruthpillai/reactive-resume:latest
    restart: unless-stopped
    depends_on:
      reactive_resume_permissions:
        condition: service_completed_successfully
      reactive_resume_db:
        condition: service_healthy
    ports:
      # 待填写：NAS 本地访问端口。
      - "CHANGE_ME_LOCAL_APP_PORT:3000"
    volumes:
      # 待填写：改成你的 NAS 数据目录。
      - /share/Container/CHANGE_ME_REACTIVE_RESUME/data/uploads:/app/data
    environment:
      TZ: Asia/Shanghai
      APP_URL: https://YOUR_DOMAIN.example.com
      DATABASE_URL: postgresql://reactive_resume:CHANGE_ME_POSTGRES_PASSWORD@reactive_resume_db:5432/reactive_resume
      AUTH_SECRET: CHANGE_ME_64_HEX_AUTH_SECRET
      ENCRYPTION_SECRET: CHANGE_ME_64_HEX_ENCRYPTION_SECRET
      SMTP_FROM: Reactive Resume <noreply@YOUR_DOMAIN.example.com>
      SMTP_PORT: "587"
      SMTP_SECURE: "false"
      FLAG_DISABLE_SIGNUPS: "false"
      FLAG_DISABLE_EMAIL_AUTH: "false"
      FLAG_DISABLE_IMAGE_PROCESSING: "false"
      FLAG_ALLOW_UNSAFE_AI_BASE_URL: "false"
    healthcheck:
      test: ["CMD-SHELL", "node -e \"fetch('http://127.0.0.1:3000/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\""]
      interval: 30s
      timeout: 10s
      retries: 8
      start_period: 30s

  reactive_resume_frpc:
    image: snowdreamtech/frpc:latest
    restart: unless-stopped
    entrypoint: ["/bin/sh"]
    command:
      - -c
      - |
        cat > /tmp/frpc.toml <<'EOF'
        serverAddr = "YOUR_FRP_SERVER_IP_OR_DOMAIN"
        serverPort = CHANGE_ME_FRP_SERVER_PORT

        auth.method = "token"
        auth.token = "CHANGE_ME_FRP_TOKEN"

        transport.poolCount = 5
        transport.heartbeatTimeout = -1

        [[proxies]]
        name = "CHANGE_ME_PROXY_NAME"
        type = "tcp"
        localIP = "reactive_resume_app"
        localPort = 3000
        remotePort = CHANGE_ME_REMOTE_PORT
        EOF
        exec frpc -c /tmp/frpc.toml
    depends_on:
      reactive_resume_app:
        condition: service_healthy
