# Reactive Resume v5 - Upgraded from v4 with same configuration values
# Docs: https://docs.rxresu.me/self-hosting/docker

services:
  db:
    image: postgres:18
    container_name: Resume-DB-V5
    hostname: resume-db
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "resume", "-U", "resumeuser"]
      timeout: 45s
      interval: 10s
      retries: 10
    volumes:
      - /volume1/docker/rxv5/db:/var/lib/postgresql:rw
    environment:
      POSTGRES_DB: resume
      POSTGRES_USER: resumeuser
      POSTGRES_PASSWORD: "REDACTED_PASSWORD"
    restart: unless-stopped

  browserless:
    image: ghcr.io/browserless/chromium:latest
    container_name: Resume-BROWSERLESS-V5
    ports:
      - "4000:3000"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/pressure?token=1234567890"]
      interval: 10s
      timeout: 5s
      retries: 10
    environment:
      QUEUED: 30
      HEALTH: true
      CONCURRENT: 20
      TOKEN: 1234567890
    restart: unless-stopped

  seaweedfs:
    image: chrislusf/seaweedfs:latest
    container_name: Resume-SEAWEEDFS-V5
    ports:
      - "9753:8333"  # S3 API port (same as v4 MinIO)
    healthcheck:
      test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://localhost:8888"]
      start_period: 10s
      interval: 30s
      timeout: 10s
      retries: 3
    command: server -s3 -filer -dir=/data -ip=0.0.0.0
    environment:
      AWS_ACCESS_KEY_ID: seaweedfs
      AWS_SECRET_ACCESS_KEY: seaweedfs
    volumes:
      - /volume1/docker/rxv5/seaweedfs:/data:rw
    restart: unless-stopped

  seaweedfs-create-bucket:
    image: quay.io/minio/mc:latest
    container_name: Resume-BUCKET-V5
    entrypoint: >
      /bin/sh -c "
        sleep 5;
        mc alias set seaweedfs http://seaweedfs:8333 seaweedfs seaweedfs;
        mc mb seaweedfs/reactive-resume;
        exit 0;
      "
    depends_on:
      seaweedfs:
        condition: service_healthy
    restart: on-failure:5

  ollama:
    image: ollama/ollama:latest
    container_name: Resume-OLLAMA-V5
    ports:
      - "11434:11434"
    volumes:
      - /volume1/docker/rxv5/ollama:/root/.ollama:rw
    environment:
      OLLAMA_HOST: "0.0.0.0"
    restart: unless-stopped
    # Uncomment if you have GPU support
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: 1
    #           capabilities: [gpu]

  resume:
    image: amruthpillai/reactive-resume:v5
    container_name: Resume-ACCESS-V5
    hostname: resume
    security_opt:
      - no-new-privileges:true
    ports:
      - "9751:3000"  # Main application port (same as v4)
    environment:
      # --- Server ---
      PORT: 3000
      TZ: "America/Chicago"
      NODE_ENV: production
      APP_URL: "https://rx.vish.gg"
      PRINTER_APP_URL: "http://resume:3000"

      # --- Database ---
      DATABASE_URL: "postgresql://resumeuser:REDACTED_PASSWORD@resume-db:5432/resume"

      # --- Authentication ---
      # Using same secret as v4 for consistency
      AUTH_SECRET: "d5c3e165dafd2d82bf84acacREDACTED_GITEA_TOKEN"

      # --- Printer (v5 uses WebSocket) ---
      PRINTER_ENDPOINT: "ws://browserless:3000?token=1234567890"

      # --- Storage (S3 - SeaweedFS) ---
      S3_ACCESS_KEY_ID: "seaweedfs"
      S3_SECRET_ACCESS_KEY: "seaweedfs"
      S3_ENDPOINT: "http://seaweedfs:8333"
      S3_BUCKET: "reactive-resume"
      S3_FORCE_PATH_STYLE: "true"
      STORAGE_USE_SSL: "false"

      # --- Email (SMTP) - Same as v4 ---
      SMTP_HOST: "smtp.gmail.com"
      SMTP_PORT: "465"
      SMTP_USER: "your-email@example.com"
      SMTP_PASS: "REDACTED_PASSWORD" rnqz rnqz rnqz" # pragma: allowlist secret
      SMTP_FROM: "your-email@example.com"
      SMTP_SECURE: "true"

      # --- OAuth / SSO (Authentik) ---
      OAUTH_PROVIDER_NAME: "Authentik"
      OAUTH_CLIENT_ID: "REDACTED_CLIENT_ID"
      OAUTH_CLIENT_SECRET: "REDACTED_CLIENT_SECRET"  # pragma: allowlist secret
      OAUTH_DISCOVERY_URL: "https://sso.vish.gg/application/o/reactive-resume/.well-known/openid-configuration"

      # --- Feature Flags ---
      FLAG_DISABLE_SIGNUPS: "false"
      FLAG_DISABLE_EMAIL_AUTH: "false"

      # --- AI Integration (Olares Ollama) ---
      # Configured via Settings UI → AI → OpenAI-compatible provider
      # Points to Olares RTX 5090 GPU inference (qwen3:32b (dense 32B))
      OPENAI_API_KEY: "dummy"  # pragma: allowlist secret
      OPENAI_BASE_URL: "http://192.168.0.145:31434/v1"
      OPENAI_MODEL: "qwen3:32b"

    depends_on:
      db:
        condition: service_healthy
      seaweedfs:
        condition: service_healthy
    restart: unless-stopped
