services:
  backend:
    container_name: backend
    image: ghcr.io/intuitem/ciso-assistant-enterprise/backend:latest
    restart: always
    environment:
      - ALLOWED_HOSTS=backend,cool-vm
      - CISO_ASSISTANT_URL=https://cool-vm:8443
      - DJANGO_DEBUG=True
      - AUTH_TOKEN_TTL=7200
    volumes:
      - ./db:/code/db

  # huey:
  #   container_name: huey
  #   image: ghcr.io/intuitem/ciso-assistant-community/backend:latest
  #   restart: always
  #   environment:
  #     - ALLOWED_HOSTS=backend,localhost
  #     - DJANGO_DEBUG=False
  #   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://cool-vm:8443/api
      - PROTOCOL_HEADER=x-forwarded-proto
      - HOST_HEADER=x-forwarded-host

    image: ghcr.io/intuitem/ciso-assistant-enterprise/frontend:latest
    depends_on:
      - backend

  caddy:
    container_name: caddy
    image: caddy:2.10.0
    environment:
      - CISO_ASSISTANT_URL=https://cool-vm:8443
    depends_on:
      - frontend
    restart: unless-stopped
    ports:
      - 8443:8443
    volumes:
      - ./caddy_data:/data
    command: |
      sh -c 'echo $$CISO_ASSISTANT_URL "{
      reverse_proxy /api/iam/sso/redirect/ backend:8000
      reverse_proxy /api/accounts/saml/0/acs/ backend:8000
      reverse_proxy /api/accounts/saml/0/acs/finish/ backend:8000
      reverse_proxy /api/accounts/oidc/openid_connect/login/callback/ backend:8000
      reverse_proxy /* frontend:3000
      tls internal
      }" > Caddyfile && caddy run'
