# QualityProfit Dashboard v3.0.0
# https://qualityprofit.io/getting-started
#
# Usage:
#   docker compose up -d
#
# Dashboard: http://localhost:3000
# API:       http://localhost:8000

services:
  # Backend - QualityProfit API
  backend:
    image: ghcr.io/shiroo81/dashboard-backend:latest
    container_name: qualityprofit-backend
    ports:
      - "8000:8000"
    environment:
      - PYTHONUNBUFFERED=1
      - LICENSE_SERVER_URL=${LICENSE_SERVER_URL:-https://api.qualityprofit.com}
      # License validation mode: online (default), offline (JWT only), auto (online → JWT → cache)
      - LICENSE_VALIDATION_MODE=${LICENSE_VALIDATION_MODE:-online}
      # Path to JWT license file (required for offline/auto mode)
      - JWT_LICENSE_FILE=${JWT_LICENSE_FILE:-}
      # Path to public key for JWT verification
      - JWT_PUBLIC_KEY_FILE=${JWT_PUBLIC_KEY_FILE:-/app/keys/public_key.pem}
    volumes:
      - qualityprofit-data:/app/data
      # Mount JWT license file for offline validation (optional)
      # - ./license.jwt:/app/license.jwt:ro
      # - ./keys/public_key.pem:/app/keys/public_key.pem:ro
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health/live"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # Frontend - QualityProfit Dashboard
  frontend:
    image: ghcr.io/shiroo81/dashboard-frontend:latest
    container_name: qualityprofit-frontend
    ports:
      - "3000:80"
    depends_on:
      - backend
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:80"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

volumes:
  qualityprofit-data:
    name: qualityprofit-data

networks:
  default:
    name: qualityprofit-network
