services:
  backend:
    container_name: backend
    build:
      context: ../
      dockerfile: ./enterprise/backend/Dockerfile
    restart: always
    environment:
      - ALLOWED_HOSTS=backend,localhost
      - CISO_ASSISTANT_URL=https://localhost:8443
      - DJANGO_DEBUG=True
      - LICENSE_SEATS=5
      - LICENSE_EXPIRATION=2025-12-21
      - DJANGO_SETTINGS_MODULE=enterprise_core.settings
    volumes:
      - ./db:/code/db

  huey:
    container_name: huey
    build:
      context: ../
      dockerfile: ./enterprise/backend/Dockerfile
    restart: always
    environment:
      - ALLOWED_HOSTS=backend,localhost
      - DJANGO_DEBUG=True
      - LICENSE_SEATS=5
      - LICENSE_EXPIRATION=2025-12-21
    volumes:
      - ./db:/code/db
    entrypoint:
      - /bin/sh
      - -c
      - |
        poetry run python manage.py run_huey

  frontend:
    container_name: frontend
    environment:
      - PUBLIC_BACKEND_API_URL=http://backend:8000/api
      - PUBLIC_BACKEND_API_EXPOSED_URL=https://localhost:8443/api
      - PROTOCOL_HEADER=x-forwarded-proto
      - HOST_HEADER=x-forwarded-host

    build:
      context: ../
      dockerfile: ./enterprise/frontend/Dockerfile
    depends_on:
      - backend

  caddy:
    container_name: caddy
    image: caddy:2.10.0
    environment:
      - CISO_ASSISTANT_URL=https://localhost:8443
    restart: unless-stopped
    ports:
      - 8443:8443
    volumes:
      - ./db:/data
    command: |
      sh -c 'echo $$CISO_ASSISTANT_URL "{
      reverse_proxy /api/* backend:8000
      reverse_proxy /* frontend:3000
      tls internal
      }" > Caddyfile && caddy run'
