Added separate docker compose for local testing
This commit is contained in:
13
app/main.py
13
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)
|
||||
|
||||
37
docker-compose.prod.yml
Normal file
37
docker-compose.prod.yml
Normal file
@@ -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:
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user