services:
  controls:
    image: ghcr.io/scorifya/controls:latest
    # To build locally instead: comment out image and uncomment:
    # build: .
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      NODE_ENV: production
      DATABASE_URL: file:/data/scorifya.db

      # ── Required ───────────────────────────────────────────────────────────────
      # Generate with: openssl rand -base64 32
      SESSION_SECRET: replace-with-32-plus-char-secret

      # The public URL this instance is served at (used for invite email links).
      # Include the scheme and no trailing slash, e.g. https://controls.acme.com
      NEXT_PUBLIC_BASE_URL: http://localhost:3000

      # ── License ────────────────────────────────────────────────────────────────
      # Issued at scorifya.com — enter here or via the Settings page after login.
      LICENSE_KEY: ""
      LICENSE_DOMAIN: ""           # hostname this instance runs on, e.g. controls.acme.com
      LICENSE_VALIDATION_URL: "https://www.scorifya.com/api/licenses/validate"

      # ── Optional: SMTP (for team invite emails) ────────────────────────────────
      # If not set, invite links are printed to container logs instead.
      SMTP_HOST: ""
      SMTP_PORT: "587"
      SMTP_SECURE: "false"         # set to "true" for port 465
      SMTP_USER: ""
      SMTP_PASS: ""
      SMTP_FROM: "Scorifya Controls <noreply@yourcompany.com>"

      # ── Optional: Slack webhook for drift alerts ───────────────────────────────
      SLACK_WEBHOOK_URL: ""

      # ── Optional: protect the cron endpoint ───────────────────────────────────
      CRON_SECRET: ""

    volumes:
      - data:/data

    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/api/health', r => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s

volumes:
  data:
    driver: local
