diff --git a/app/main.py b/app/main.py index d0c2510..9c8ecfa 100644 --- a/app/main.py +++ b/app/main.py @@ -1,5 +1,5 @@ from fastapi import FastAPI, Request -# from fastapi.middleware.cors import CORSMiddleware +from fastapi.middleware.cors import CORSMiddleware from slowapi import _rate_limit_exceeded_handler from slowapi.errors import RateLimitExceeded @@ -46,7 +46,16 @@ def create_application() -> FastAPI: logger.info(f"DEBUG: Status Code: {response.status_code}") return response - # Set up Rate Limiter (CORS is handled by Caddy at the edge) + # Set up fully permissive CORS for standalone/tunnelling mode + application.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) + + # Set up Rate Limiter application.state.limiter = limiter @application.exception_handler(RateLimitExceeded) diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..0952bb3 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,37 @@ +services: + ai-gateway: + build: . + container_name: ai-gateway + networks: + - ai_network + environment: + - PYTHONUNBUFFERED=1 + env_file: + - .env + restart: always + command: uvicorn app.main:app --host 0.0.0.0 --port 8000 + + caddy: + image: caddy:latest + container_name: caddy + restart: always + ports: + - "80:80" + - "443:443" + - "443:443/udp" + networks: + - ai_network + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile + - caddy_data:/data + - caddy_config:/config + depends_on: + - ai-gateway + +networks: + ai_network: + driver: bridge + +volumes: + caddy_data: + caddy_config: diff --git a/docker-compose.yml b/docker-compose.yml index 0952bb3..7eb8ac9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,36 +2,11 @@ services: ai-gateway: build: . container_name: ai-gateway - networks: - - ai_network environment: - PYTHONUNBUFFERED=1 env_file: - .env + ports: + - "8000:8000" restart: always command: uvicorn app.main:app --host 0.0.0.0 --port 8000 - - caddy: - image: caddy:latest - container_name: caddy - restart: always - ports: - - "80:80" - - "443:443" - - "443:443/udp" - networks: - - ai_network - volumes: - - ./Caddyfile:/etc/caddy/Caddyfile - - caddy_data:/data - - caddy_config:/config - depends_on: - - ai-gateway - -networks: - ai_network: - driver: bridge - -volumes: - caddy_data: - caddy_config: