# ASGI Framework Compatibility Test Suite
# Tests gunicorn's native ASGI worker with multiple frameworks
#
# Usage:
#   docker compose up -d --build
#   ASGI_LOOP=asyncio docker compose up -d --build
#   ASGI_LOOP=uvloop docker compose up -d --build

x-healthcheck: &healthcheck
  healthcheck:
    test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
    interval: 5s
    timeout: 3s
    retries: 10
    start_period: 10s

services:
  django:
    build:
      context: ../../..
      dockerfile: tests/docker/asgi_framework_compat/frameworks/django_app/Dockerfile
    ports:
      - "8001:8000"
    command: ["gunicorn", "asgi:application", "-k", "asgi", "-b", "0.0.0.0:8000", "--workers", "1", "--worker-connections", "100", "--asgi-loop", "${ASGI_LOOP:-auto}"]
    networks:
      - asgi_test_network
    <<: *healthcheck

  fastapi:
    build:
      context: ../../..
      dockerfile: tests/docker/asgi_framework_compat/frameworks/fastapi_app/Dockerfile
    ports:
      - "8002:8000"
    command: ["gunicorn", "app:app", "-k", "asgi", "-b", "0.0.0.0:8000", "--workers", "1", "--worker-connections", "100", "--asgi-loop", "${ASGI_LOOP:-auto}"]
    networks:
      - asgi_test_network
    <<: *healthcheck

  starlette:
    build:
      context: ../../..
      dockerfile: tests/docker/asgi_framework_compat/frameworks/starlette_app/Dockerfile
    ports:
      - "8003:8000"
    command: ["gunicorn", "app:app", "-k", "asgi", "-b", "0.0.0.0:8000", "--workers", "1", "--worker-connections", "100", "--asgi-loop", "${ASGI_LOOP:-auto}"]
    networks:
      - asgi_test_network
    <<: *healthcheck

  quart:
    build:
      context: ../../..
      dockerfile: tests/docker/asgi_framework_compat/frameworks/quart_app/Dockerfile
    ports:
      - "8004:8000"
    command: ["gunicorn", "app:app", "-k", "asgi", "-b", "0.0.0.0:8000", "--workers", "1", "--worker-connections", "100", "--asgi-loop", "${ASGI_LOOP:-auto}"]
    networks:
      - asgi_test_network
    <<: *healthcheck

  litestar:
    build:
      context: ../../..
      dockerfile: tests/docker/asgi_framework_compat/frameworks/litestar_app/Dockerfile
    ports:
      - "8005:8000"
    command: ["gunicorn", "app:app", "-k", "asgi", "-b", "0.0.0.0:8000", "--workers", "1", "--worker-connections", "100", "--asgi-loop", "${ASGI_LOOP:-auto}"]
    networks:
      - asgi_test_network
    <<: *healthcheck

  blacksheep:
    build:
      context: ../../..
      dockerfile: tests/docker/asgi_framework_compat/frameworks/blacksheep_app/Dockerfile
    ports:
      - "8006:8000"
    command: ["gunicorn", "app:app", "-k", "asgi", "-b", "0.0.0.0:8000", "--workers", "1", "--worker-connections", "100", "--asgi-loop", "${ASGI_LOOP:-auto}"]
    networks:
      - asgi_test_network
    <<: *healthcheck

networks:
  asgi_test_network:
    driver: bridge
