forked from cardosofelipe/fast-next-template
feat: integrate MCP servers into Docker Compose files for development and deployment
- Added `mcp-llm-gateway` and `mcp-knowledge-base` services to `docker-compose.dev.yml`, `docker-compose.deploy.yml`, and `docker-compose.yml` for AI agent capabilities. - Configured health checks, environment variables, and dependencies for MCP services. - Included updated resource limits and deployment settings for production environments. - Connected backend and agent services to the MCP servers.
This commit is contained in:
@@ -48,6 +48,80 @@ services:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
|
||||
# ==========================================================================
|
||||
# MCP Servers - Model Context Protocol servers for AI agent capabilities
|
||||
# ==========================================================================
|
||||
|
||||
mcp-llm-gateway:
|
||||
# REPLACE THIS with your actual image from your container registry
|
||||
image: YOUR_REGISTRY/YOUR_PROJECT_MCP_LLM_GATEWAY:latest
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- LLM_GATEWAY_HOST=0.0.0.0
|
||||
- LLM_GATEWAY_PORT=8001
|
||||
- REDIS_URL=redis://redis:6379/1
|
||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ENVIRONMENT=production
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import httpx; httpx.get('http://localhost:8001/health').raise_for_status()"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2.0'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
|
||||
mcp-knowledge-base:
|
||||
# REPLACE THIS with your actual image from your container registry
|
||||
image: YOUR_REGISTRY/YOUR_PROJECT_MCP_KNOWLEDGE_BASE:latest
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
# KB_ prefix required by pydantic-settings config
|
||||
- KB_HOST=0.0.0.0
|
||||
- KB_PORT=8002
|
||||
- KB_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
||||
- KB_REDIS_URL=redis://redis:6379/2
|
||||
- KB_LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ENVIRONMENT=production
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import httpx; httpx.get('http://localhost:8002/health').raise_for_status()"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 1G
|
||||
reservations:
|
||||
cpus: '0.25'
|
||||
memory: 256M
|
||||
|
||||
backend:
|
||||
# REPLACE THIS with your actual image from your container registry
|
||||
# Examples:
|
||||
@@ -64,11 +138,18 @@ services:
|
||||
- DEBUG=false
|
||||
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
# MCP Server URLs
|
||||
- LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- KNOWLEDGE_BASE_URL=http://mcp-knowledge-base:8002
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mcp-llm-gateway:
|
||||
condition: service_healthy
|
||||
mcp-knowledge-base:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
@@ -92,11 +173,18 @@ services:
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- CELERY_QUEUE=agent
|
||||
# MCP Server URLs (agents need access to MCP)
|
||||
- LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- KNOWLEDGE_BASE_URL=http://mcp-knowledge-base:8002
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mcp-llm-gateway:
|
||||
condition: service_healthy
|
||||
mcp-knowledge-base:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -32,6 +32,70 @@ services:
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
# ==========================================================================
|
||||
# MCP Servers - Model Context Protocol servers for AI agent capabilities
|
||||
# ==========================================================================
|
||||
|
||||
mcp-llm-gateway:
|
||||
build:
|
||||
context: ./mcp-servers/llm-gateway
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8001:8001"
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- LLM_GATEWAY_HOST=0.0.0.0
|
||||
- LLM_GATEWAY_PORT=8001
|
||||
- REDIS_URL=redis://redis:6379/1
|
||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ENVIRONMENT=development
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import httpx; httpx.get('http://localhost:8001/health').raise_for_status()"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
|
||||
mcp-knowledge-base:
|
||||
build:
|
||||
context: ./mcp-servers/knowledge-base
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8002:8002"
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
# KB_ prefix required by pydantic-settings config
|
||||
- KB_HOST=0.0.0.0
|
||||
- KB_PORT=8002
|
||||
- KB_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
||||
- KB_REDIS_URL=redis://redis:6379/2
|
||||
- KB_LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ENVIRONMENT=development
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import httpx; httpx.get('http://localhost:8002/health').raise_for_status()"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
@@ -52,11 +116,18 @@ services:
|
||||
- DEBUG=true
|
||||
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
# MCP Server URLs
|
||||
- LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- KNOWLEDGE_BASE_URL=http://mcp-knowledge-base:8002
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mcp-llm-gateway:
|
||||
condition: service_healthy
|
||||
mcp-knowledge-base:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||||
interval: 10s
|
||||
@@ -81,11 +152,18 @@ services:
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- CELERY_QUEUE=agent
|
||||
# MCP Server URLs (agents need access to MCP)
|
||||
- LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- KNOWLEDGE_BASE_URL=http://mcp-knowledge-base:8002
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mcp-llm-gateway:
|
||||
condition: service_healthy
|
||||
mcp-knowledge-base:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app-network
|
||||
command: ["celery", "-A", "app.celery_app", "worker", "-Q", "agent", "-l", "info", "-c", "4"]
|
||||
|
||||
@@ -32,6 +32,82 @@ services:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
|
||||
# ==========================================================================
|
||||
# MCP Servers - Model Context Protocol servers for AI agent capabilities
|
||||
# ==========================================================================
|
||||
|
||||
mcp-llm-gateway:
|
||||
build:
|
||||
context: ./mcp-servers/llm-gateway
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- LLM_GATEWAY_HOST=0.0.0.0
|
||||
- LLM_GATEWAY_PORT=8001
|
||||
- REDIS_URL=redis://redis:6379/1
|
||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ENVIRONMENT=production
|
||||
depends_on:
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import httpx; httpx.get('http://localhost:8001/health').raise_for_status()"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '2.0'
|
||||
memory: 2G
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
|
||||
mcp-knowledge-base:
|
||||
build:
|
||||
context: ./mcp-servers/knowledge-base
|
||||
dockerfile: Dockerfile
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
# KB_ prefix required by pydantic-settings config
|
||||
- KB_HOST=0.0.0.0
|
||||
- KB_PORT=8002
|
||||
- KB_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
||||
- KB_REDIS_URL=redis://redis:6379/2
|
||||
- KB_LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
||||
- ENVIRONMENT=production
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import httpx; httpx.get('http://localhost:8002/health').raise_for_status()"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 1G
|
||||
reservations:
|
||||
cpus: '0.25'
|
||||
memory: 256M
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
@@ -48,11 +124,18 @@ services:
|
||||
- DEBUG=false
|
||||
- BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
# MCP Server URLs
|
||||
- LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- KNOWLEDGE_BASE_URL=http://mcp-knowledge-base:8002
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mcp-llm-gateway:
|
||||
condition: service_healthy
|
||||
mcp-knowledge-base:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
@@ -75,11 +158,18 @@ services:
|
||||
- DATABASE_URL=${DATABASE_URL}
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- CELERY_QUEUE=agent
|
||||
# MCP Server URLs (agents need access to MCP)
|
||||
- LLM_GATEWAY_URL=http://mcp-llm-gateway:8001
|
||||
- KNOWLEDGE_BASE_URL=http://mcp-knowledge-base:8002
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
mcp-llm-gateway:
|
||||
condition: service_healthy
|
||||
mcp-knowledge-base:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- app-network
|
||||
restart: unless-stopped
|
||||
|
||||
Reference in New Issue
Block a user