forked from vercel/chatbot
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
138 lines (132 loc) · 4.71 KB
/
Copy pathdocker-compose.yml
File metadata and controls
138 lines (132 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Docker Compose configuration for local development
# NOT intended for production orchestration
#
# IMPORTANT: Create a root .env file with POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB
# for variable substitution. These values should match backend/.env.
# See docs/docker-setup.md for details.
#
# Usage:
# docker compose up - Start all services
# docker compose up -d - Start in detached mode
# docker compose down - Stop all services
# docker compose logs -f - Follow logs
#
# Optional Redis:
# docker compose --profile redis up - Start with Redis enabled
#
# See docs/docker-setup.md for detailed documentation
services:
# =============================================================================
# Database Service
# =============================================================================
db:
image: postgres:17.2
container_name: chatbot-db
ports:
# TODO: change to 5432 when production is ready
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
env_file:
- ./backend/.env
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
# =============================================================================
# Backend Service (FastAPI)
# =============================================================================
backend:
build:
context: ./backend
dockerfile: Dockerfile
# Certificate secret is optional - only include if backend/certs/corp-root-ca.crt exists
secrets:
- corp_cert
container_name: chatbot-backend
# Ensure host.docker.internal resolves to host machine
# This allows the backend to connect to services running on the host (e.g., MCP server on port 8022)
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8001:8001"
volumes:
# Mount source code for hot reloading
- ./backend:/app
# Prevent overwriting installed packages
- /app/.venv
env_file:
- ./backend/.env
environment:
# Override database host to use Docker service name
- POSTGRES_URL=postgresql+asyncpg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
- POSTGRES_URL_SYNC=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
- SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
- REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
depends_on:
db:
condition: service_healthy
restart: unless-stopped
# =============================================================================
# Frontend Service (Next.js)
# =============================================================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.frontend
secrets:
- npmrc
container_name: chatbot-frontend
ports:
- "3001:3001"
env_file:
- ./frontend/.env.local
environment:
# Browser-accessible URL (client-side JavaScript)
- NEXT_PUBLIC_API_URL=http://localhost:8001
# Server-side URL for internal Docker networking (server components, API routes)
- SERVER_API_URL=http://backend:8001
# Configure npm/pnpm to use .npmrc from volume mount at runtime
# The volume mount ./frontend:/app provides .npmrc at /app/.npmrc
- NPM_CONFIG_USERCONFIG=/app/.npmrc
depends_on:
- backend
restart: unless-stopped
# =============================================================================
# Redis Service (Optional)
# Enable with: docker compose --profile redis up
# =============================================================================
redis:
image: redis:7-alpine
container_name: chatbot-redis
profiles:
- redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
restart: unless-stopped
# =============================================================================
# Volumes
# =============================================================================
volumes:
# PostgreSQL data persistence
postgres_data:
# Redis data persistence (only used when redis profile is enabled)
redis_data:
secrets:
npmrc:
file: ./frontend/.npmrc
# Corporate root CA certificate (optional - only needed if behind corporate proxy)
# If you don't have this certificate, comment out the 'corp_cert' secret above and below
# Create backend/certs/corp-root-ca.crt with your corporate certificate if needed
corp_cert:
file: ./backend/certs/corp-root-ca.crt