-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
218 lines (195 loc) · 6.2 KB
/
docker-compose.yml
File metadata and controls
218 lines (195 loc) · 6.2 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# GitHub - Docker Compose Configuration
#
# This docker-compose file orchestrates GitHub services
# with REST API, and optional components.
#
# Usage:
# docker-compose up -d # Start all services
# docker-compose up api # Start API only
# docker-compose logs -f api # View API logs
# docker-compose down # Stop all services
# docker-compose ps # Check service status
version: '3.8'
services:
# ==========================================================================
# REST API Service
# ==========================================================================
api:
build:
context: .
dockerfile: Dockerfile
target: runtime
image: github:latest
container_name: github-api
ports:
- "8000:8000"
environment:
# Application settings
GITHUB_ENV: production
GITHUB_LOG_LEVEL: INFO
# API settings
GITHUB_API_HOST: 0.0.0.0
GITHUB_API_PORT: 8000
# CORS settings
GITHUB_CORS_ENABLED: "true"
GITHUB_CORS_ORIGINS: "http://localhost:3000,https://app.example.com"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s
restart: unless-stopped
networks:
- github-network
volumes:
# Optional: Mount data directory for persistence
- github-data:/app/data
command: uvicorn github.interfaces.rest:app --host 0.0.0.0 --port 8000
# ==========================================================================
# Nginx Reverse Proxy (optional)
# ==========================================================================
nginx:
image: nginx:alpine
container_name: github-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./ssl:/etc/nginx/ssl:ro
depends_on:
- api
restart: unless-stopped
networks:
- github-network
profiles:
- production # Only start with: docker-compose --profile production up
# ==========================================================================
# PostgreSQL Database (optional)
# ==========================================================================
postgres:
image: postgres:16-alpine
container_name: github-postgres
environment:
POSTGRES_DB: github
POSTGRES_USER: github_user
POSTGRES_PASSWORD: changeme # Change in production!
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U github_user"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- github-network
profiles:
- database # Only start with: docker-compose --profile database up
# ==========================================================================
# Redis Cache (optional)
# ==========================================================================
redis:
image: redis:7-alpine
container_name: github-redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
restart: unless-stopped
networks:
- github-network
command: redis-server --appendonly yes
profiles:
- cache # Only start with: docker-compose --profile cache up
# ==========================================================================
# Prometheus (monitoring, optional)
# ==========================================================================
prometheus:
image: prom/prometheus:latest
container_name: github-prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
restart: unless-stopped
networks:
- github-network
profiles:
- monitoring # Only start with: docker-compose --profile monitoring up
# ==========================================================================
# Grafana (dashboards, optional)
# ==========================================================================
grafana:
image: grafana/grafana:latest
container_name: github-grafana
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: admin # Change in production!
GF_INSTALL_PLUGINS: ""
volumes:
- grafana-data:/var/lib/grafana
depends_on:
- prometheus
restart: unless-stopped
networks:
- github-network
profiles:
- monitoring # Only start with: docker-compose --profile monitoring up
# ============================================================================
# Networks
# ============================================================================
networks:
github-network:
driver: bridge
name: github-network
# ============================================================================
# Volumes
# ============================================================================
volumes:
github-data:
name: github-data
postgres-data:
name: github-postgres-data
redis-data:
name: github-redis-data
prometheus-data:
name: github-prometheus-data
grafana-data:
name: github-grafana-data
# ============================================================================
# Usage Examples
# ============================================================================
# Start core services (API):
# docker-compose up -d
# Start with database:
# docker-compose --profile database up -d
# Start with monitoring:
# docker-compose --profile monitoring up -d
# Start everything:
# docker-compose --profile database --profile cache --profile monitoring --profile production up -d
# View logs:
# docker-compose logs -f api
# docker-compose logs -f --tail=100 api
# Scale API:
# docker-compose up -d --scale api=3
# Stop all services:
# docker-compose down
# Stop and remove volumes:
# docker-compose down -v
# Rebuild images:
# docker-compose build --no-cache
# docker-compose up -d --force-recreate