# Reactive Resume 个人简历 / QNAP QTS 直接部署版。
# 本文件已按 /share/Container/Reactive_Resume_Personal、
# https://isiseg.huijutec.cn、192.168.31.5:3004 本地访问、
# frpc 公网映射 82.157.255.195:10004 预置。

name: reactive-resume-personal-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:
      - /share/Container/Reactive_Resume_Personal/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: 5b341c0ca29fefd6d648661150c00fa4
    volumes:
      - /share/Container/Reactive_Resume_Personal/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:
      - "3004:3000"
    volumes:
      - /share/Container/Reactive_Resume_Personal/data/uploads:/app/data
    environment:
      TZ: Asia/Shanghai
      APP_URL: https://isiseg.huijutec.cn
      DATABASE_URL: postgresql://reactive_resume:5b341c0ca29fefd6d648661150c00fa4@reactive_resume_db:5432/reactive_resume
      AUTH_SECRET: c76b0eaf79f731e9ee95918dc69d41696aec9d1deffeabc122944898037bfab1
      ENCRYPTION_SECRET: df3a460fa2f92f6e8765927a169322980e18f63a88fbcfedb090819b5afb2408

      BETTER_AUTH_API_KEY: ""
      GOOGLE_CLIENT_ID: ""
      GOOGLE_CLIENT_SECRET: ""
      GITHUB_CLIENT_ID: ""
      GITHUB_CLIENT_SECRET: ""
      LINKEDIN_CLIENT_ID: ""
      LINKEDIN_CLIENT_SECRET: ""
      OAUTH_PROVIDER_NAME: ""
      OAUTH_CLIENT_ID: ""
      OAUTH_CLIENT_SECRET: ""
      OAUTH_DISCOVERY_URL: ""
      OAUTH_AUTHORIZATION_URL: ""
      OAUTH_TOKEN_URL: ""
      OAUTH_USER_INFO_URL: ""
      OAUTH_DYNAMIC_CLIENT_REDIRECT_HOSTS: ""
      OAUTH_SCOPES: ""
      SMTP_HOST: ""
      SMTP_PORT: "587"
      SMTP_USER: ""
      SMTP_PASS: ""
      SMTP_FROM: "Reactive Resume <noreply@isiseg.huijutec.cn>"
      SMTP_SECURE: "false"
      S3_ACCESS_KEY_ID: ""
      S3_SECRET_ACCESS_KEY: ""
      S3_REGION: us-east-1
      S3_ENDPOINT: ""
      S3_BUCKET: ""
      S3_FORCE_PATH_STYLE: "false"
      REDIS_URL: ""
      CLOUDFLARE_ACCOUNT_ID: ""
      CLOUDFLARE_API_TOKEN: ""
      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_seed:
    image: postgres:16-alpine
    restart: "no"
    user: "0:0"
    entrypoint: ["/bin/sh"]
    command:
      - -c
      - |
        set -eu
        mkdir -p /app/data/uploads
        cp -a /seed/uploads/. /app/data/uploads/
        chown -R 1000:1000 /app/data/uploads || true
        psql -h reactive_resume_db -U reactive_resume -d reactive_resume -v ON_ERROR_STOP=1 -f /seed/seed.sql
    environment:
      PGPASSWORD: 5b341c0ca29fefd6d648661150c00fa4
    volumes:
      - /share/Container/Reactive_Resume_Personal/data/uploads:/app/data
      - /share/Container/Reactive_Resume_Personal/seed:/seed:ro
    depends_on:
      reactive_resume_permissions:
        condition: service_completed_successfully
      reactive_resume_db:
        condition: service_healthy
      reactive_resume_app:
        condition: service_healthy

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

        auth.method = "token"
        auth.token = "en.xjtu.edu.cn"

        transport.poolCount = 5
        transport.heartbeatTimeout = -1

        [[proxies]]
        name = "Reactive_Resume_Personal_NAS"
        type = "tcp"
        localIP = "reactive_resume_app"
        localPort = 3000
        remotePort = 10004
        EOF
        exec frpc -c /tmp/frpc.toml
    depends_on:
      reactive_resume_seed:
        condition: service_completed_successfully
