-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
150 lines (143 loc) · 6.44 KB
/
docker-compose.yml
File metadata and controls
150 lines (143 loc) · 6.44 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
139
140
141
142
143
144
145
146
147
148
149
150
# Article-Chat Docker Compose Configuration - Hybrid Microservices Architecture
#
# This Docker Compose file orchestrates the complete Article-Chat system using a
# hybrid microservices architecture optimized for both development and production deployment.
#
# ARCHITECTURE OVERVIEW:
# - Go Backend: High-performance API gateway handling HTTP traffic and service orchestration
# - Node.js RAG Service: Specialized AI/ML service with LangChain.js, Claude, and FAISS vector storage
# - React Frontend: Modern web interface with nginx reverse proxy
# - Redis: High-performance caching layer for chat responses and article processing
#
# SERVICE COMMUNICATION:
# - Internal Docker network (app-network) enables secure inter-service communication
# - Service discovery via Docker DNS (service names resolve to container IPs)
# - Port mapping exposes services to host for development and monitoring
#
# PERFORMANCE OPTIMIZATIONS:
# - Multi-stage builds for optimized production images
# - Volume mounting for persistent data (FAISS store, articles)
# - Redis caching reduces API calls and improves response times
# - Restart policies ensure high availability
#
# DEPLOYMENT CONSIDERATIONS:
# - Environment files (.env) for service-specific configuration
# - Health checks and dependency management with depends_on
# - Network isolation with custom bridge network
# - Volume persistence for AI model cache and vector storage
services:
# ============================================================================
# GO BACKEND SERVICE - API Gateway & Request Orchestration
# ============================================================================
backend-go:
build:
context: . # Build from repository root
dockerfile: server.Dockerfile # Go service Dockerfile
ports:
- "8080:8080" # HTTP API endpoint
env_file:
- ./server/.env # Go service environment variables
environment:
# Service communication configuration
- RAG_SERVICE_URL=http://rag-service-nodejs:3001 # Internal Docker network URL
- REDIS_URL=redis://redis:6379 # Redis connection string
- GO_ENV=development # Development environment for Docker Compose
depends_on:
- rag-service-nodejs # Wait for RAG service
- redis # Wait for Redis cache
- postgres # Wait for PostgreSQL database
networks:
- app-network # Internal service network
restart: unless-stopped # High availability restart policy
# ============================================================================
# NODE.JS RAG SERVICE - AI/ML Processing Engine
# ============================================================================
rag-service-nodejs:
build:
context: . # Build from repository root
dockerfile: rag-service.Dockerfile # Node.js RAG service Dockerfile
ports:
- "3001:3001" # RAG service API endpoint
env_file:
- ./rag-service/.env # RAG service environment (ANTHROPIC_API_KEY, etc.)
environment:
- NODE_ENV=production # Node.js production optimizations
- PORT=3001 # Service port
# AI/ML data paths within container
- ARTICLES_JSON_PATH=/app/data/articles.json # Knowledge base source
- FAISS_STORE_PATH=/app/data/faiss_store # Vector storage location
- TRANSFORMERS_CACHE=/app/.cache # HuggingFace model cache
networks:
- app-network # Internal service network
volumes:
- ./data:/app/data # Persistent storage for articles and vector store
restart: unless-stopped # High availability restart policy
# ============================================================================
# REACT FRONTEND SERVICE - Web Interface with Nginx Proxy
# ============================================================================
frontend-react:
build:
context: . # Build from repository root
dockerfile: client.Dockerfile # React frontend Dockerfile
ports:
- "3000:3000" # Web application port
env_file:
- ./client/.env # Frontend environment variables
environment:
# API communication configuration
- VITE_API_URL=http://localhost:8080 # Go backend API URL (host-accessible)
depends_on:
- backend-go # Wait for backend API availability
networks:
- app-network # Internal service network
restart: unless-stopped # High availability restart policy
# ============================================================================
# REDIS CACHE SERVICE - High-Performance Caching Layer
# ============================================================================
redis:
image: redis:7-alpine # Lightweight Redis image
ports:
- "6379:6379" # Redis connection port
networks:
- app-network # Internal service network
restart: unless-stopped # High availability restart policy
# Redis provides:
# - Chat response caching
# - Article processing result caching
# - Session and conversation state persistence
# ============================================================================
# POSTGRESQL DATABASE SERVICE - User Authentication & Chat History Storage
# ============================================================================
postgres:
image: postgres:15-alpine # Lightweight PostgreSQL image
env_file:
- ./server/.env # Read PostgreSQL environment variables from server .env
volumes:
- postgres_data:/var/lib/postgresql/data # Persistent data storage
- ./data/migrations:/docker-entrypoint-initdb.d # Auto-run migrations on first start
ports:
- "5432:5432" # PostgreSQL connection port
networks:
- app-network # Internal service network
restart: unless-stopped # High availability restart policy
healthcheck:
test: ["CMD-SHELL", "pg_isready -U clarticle_user -d clarticle"]
interval: 10s
timeout: 5s
retries: 5
# PostgreSQL provides:
# - User authentication data storage
# - Conversation and message persistence
# - Session management
# - ACID compliance for data integrity
# ============================================================================
# NETWORKING CONFIGURATION
# ============================================================================
networks:
app-network:
driver: bridge # Docker bridge network for service isolation
# ============================================================================
# VOLUMES CONFIGURATION
# ============================================================================
volumes:
postgres_data: # Persistent PostgreSQL data storage