Skip to content

Commit 4c08731

Browse files
committed
feat: add Nginx reverse proxy to docker-compose.dev.yaml
- Add Nginx reverse proxy service (port 3000) for unified access - Add frontend service (React dev server on port 3001) - Add backend service (FastAPI on port 8001) - Create nginx.conf with proper routing: - Frontend at / (with WebSocket support for React HMR) - Backend API at /api/ (with extended timeouts for LLM inference) - Create Dockerfile.frontend for React development server - Configure proper proxy headers and WebSocket support - Disable buffering for streaming responses Access application via http://localhost:3000 (Nginx) Direct access: Frontend http://localhost:3001, Backend http://localhost:8001
1 parent 96e5e0b commit 4c08731

3 files changed

Lines changed: 148 additions & 0 deletions

File tree

Dockerfile.frontend

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Frontend Development Dockerfile
2+
# Runs React development server with hot reload
3+
4+
FROM node:20-alpine
5+
6+
WORKDIR /app
7+
8+
# Copy package files
9+
COPY src/ui/web/package*.json ./
10+
11+
# Install dependencies
12+
RUN npm ci
13+
14+
# Copy frontend source
15+
COPY src/ui/web/ ./
16+
17+
# Expose port
18+
EXPOSE 3001
19+
20+
# Start development server
21+
CMD ["npm", "start"]
22+

deploy/compose/docker-compose.dev.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,73 @@ services:
9090
- "9091:9091" # HTTP
9191
depends_on: [etcd, minio]
9292

93+
# Backend API Service
94+
backend:
95+
build:
96+
context: ../..
97+
dockerfile: Dockerfile
98+
container_name: wosa-backend
99+
ports:
100+
- "8001:8001"
101+
environment:
102+
- POSTGRES_USER=${POSTGRES_USER}
103+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
104+
- POSTGRES_DB=${POSTGRES_DB}
105+
- DB_HOST=timescaledb
106+
- DB_PORT=5432
107+
- REDIS_HOST=redis
108+
- REDIS_PORT=6379
109+
- MILVUS_HOST=milvus
110+
- MILVUS_PORT=19530
111+
- KAFKA_BOOTSTRAP_SERVERS=kafka:9092
112+
- ENVIRONMENT=development
113+
depends_on:
114+
- timescaledb
115+
- redis
116+
- milvus
117+
- kafka
118+
restart: unless-stopped
119+
healthcheck:
120+
test: ["CMD", "curl", "-f", "http://localhost:8001/api/v1/health"]
121+
interval: 30s
122+
timeout: 10s
123+
retries: 3
124+
start_period: 40s
125+
126+
# Frontend Service (React Development Server)
127+
frontend:
128+
build:
129+
context: ../..
130+
dockerfile: Dockerfile.frontend
131+
container_name: wosa-frontend
132+
ports:
133+
- "3001:3001"
134+
environment:
135+
- REACT_APP_API_URL=http://localhost:8001
136+
- PORT=3001
137+
- HOST=0.0.0.0
138+
- CHOKIDAR_USEPOLLING=true
139+
volumes:
140+
- ../../src/ui/web:/app
141+
- /app/node_modules
142+
depends_on:
143+
- backend
144+
restart: unless-stopped
145+
stdin_open: true
146+
tty: true
147+
148+
# Nginx Reverse Proxy
149+
nginx:
150+
image: nginx:1.25.3-alpine
151+
container_name: wosa-nginx
152+
ports:
153+
- "3000:80"
154+
volumes:
155+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
156+
depends_on:
157+
- frontend
158+
- backend
159+
restart: unless-stopped
160+
93161
volumes:
94162
kafka_data:

deploy/compose/nginx.conf

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
events {
2+
worker_connections 1024;
3+
}
4+
5+
http {
6+
client_max_body_size 10M;
7+
8+
upstream frontend {
9+
server frontend:3001;
10+
}
11+
12+
upstream backend {
13+
server backend:8001;
14+
}
15+
16+
server {
17+
listen 80;
18+
19+
# Frontend (includes WebSocket support for React hot reload)
20+
location / {
21+
proxy_pass http://frontend;
22+
proxy_set_header Host $host;
23+
proxy_set_header X-Real-IP $remote_addr;
24+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
25+
proxy_set_header X-Forwarded-Proto $scheme;
26+
27+
# WebSocket handling for React HMR
28+
proxy_http_version 1.1;
29+
proxy_set_header Upgrade $http_upgrade;
30+
proxy_set_header Connection "upgrade";
31+
}
32+
33+
# Backend API routes
34+
location /api/ {
35+
proxy_pass http://backend/;
36+
proxy_set_header Host $host;
37+
proxy_set_header X-Real-IP $remote_addr;
38+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
39+
proxy_set_header X-Forwarded-Proto $scheme;
40+
41+
# Disable buffering for streaming responses
42+
proxy_buffering off;
43+
proxy_cache off;
44+
proxy_request_buffering off;
45+
46+
# Increase timeouts for long-running requests (LLM inference, document processing)
47+
proxy_read_timeout 300s;
48+
proxy_connect_timeout 300s;
49+
proxy_send_timeout 300s;
50+
51+
# WebSocket support
52+
proxy_http_version 1.1;
53+
proxy_set_header Upgrade $http_upgrade;
54+
proxy_set_header Connection "upgrade";
55+
}
56+
}
57+
}
58+

0 commit comments

Comments
 (0)