-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
184 lines (175 loc) · 4.28 KB
/
docker-compose.prod.yml
File metadata and controls
184 lines (175 loc) · 4.28 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
version: '3.8'
services:
# MongoDB データベース (本番環境)
mongodb:
image: mongo:7.0
container_name: callguard-mongodb-prod
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGO_DB_NAME}
volumes:
- mongodb_data:/data/db
- ./backup:/backup
networks:
- callguard-network
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
deploy:
resources:
limits:
memory: 1G
reservations:
memory: 512M
# バックエンド API サーバー (本番環境)
backend:
build:
context: ./backend
dockerfile: Dockerfile
target: production
container_name: callguard-backend-prod
restart: always
environment:
NODE_ENV: production
PORT: 3000
MONGODB_URI: ${MONGODB_URI}
JWT_SECRET: ${JWT_SECRET}
CORS_ORIGIN: ${CORS_ORIGIN}
RATE_LIMIT_WINDOW_MS: ${RATE_LIMIT_WINDOW_MS:-900000}
RATE_LIMIT_MAX_REQUESTS: ${RATE_LIMIT_MAX_REQUESTS:-100}
depends_on:
mongodb:
condition: service_healthy
networks:
- callguard-network
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:3000/api/health']
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
deploy:
replicas: 2
resources:
limits:
memory: 512M
reservations:
memory: 256M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
# フロントエンド Web アプリ (本番環境)
frontend:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: callguard-frontend-prod
restart: always
depends_on:
- backend
networks:
- callguard-network
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
# Redis (本番環境)
redis:
image: redis:7-alpine
container_name: callguard-redis-prod
restart: always
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
volumes:
- redis_data:/data
networks:
- callguard-network
healthcheck:
test: ['CMD', 'redis-cli', '--no-auth-warning', '-a', '${REDIS_PASSWORD}', 'ping']
interval: 30s
timeout: 10s
retries: 3
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
# Nginx (本番環境)
nginx:
image: nginx:alpine
container_name: callguard-nginx-prod
restart: always
ports:
- '80:80'
- '443:443'
volumes:
- ./nginx.prod.conf:/etc/nginx/nginx.conf:ro
- ./ssl:/etc/nginx/ssl:ro
- nginx_logs:/var/log/nginx
depends_on:
- backend
- frontend
networks:
- callguard-network
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost/health']
interval: 30s
timeout: 10s
retries: 3
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
# ログ収集 (Fluentd)
fluentd:
image: fluent/fluentd:v1.16-debian-1
container_name: callguard-fluentd
restart: always
volumes:
- ./fluentd/conf:/fluentd/etc
- nginx_logs:/var/log/nginx:ro
networks:
- callguard-network
depends_on:
- backend
- frontend
# 監視 (Prometheus)
prometheus:
image: prom/prometheus:latest
container_name: callguard-prometheus
restart: always
ports:
- '9090:9090'
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks:
- callguard-network
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
volumes:
mongodb_data:
driver: local
redis_data:
driver: local
nginx_logs:
driver: local
prometheus_data:
driver: local
networks:
callguard-network:
driver: bridge