-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
125 lines (116 loc) · 3.24 KB
/
docker-compose.prod.yml
File metadata and controls
125 lines (116 loc) · 3.24 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
version: "3.8"
services:
redis:
image: redis:7-alpine
container_name: kindmap-redis
restart: unless-stopped
networks:
- kindmap-network
expose:
- "6379"
volumes:
- redis-data:/data
command: >
redis-server
--appendonly yes
--maxmemory 512mb
--maxmemory-policy allkeys-lru
--notify-keyspace-events ""
--client-output-buffer-limit pubsub 32mb 8mb 60
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
start_period: 5s
fastapi:
image: ${REPOSITORY_URI}:fastapi-${IMAGE_TAG}
# replicas 사용 시 container_name은 사용할 수 없습니다. (주석 유지)
restart: unless-stopped
env_file:
- /home/ec2-user/.env
environment:
ALLOWED_ORIGINS: "http://localhost:3000,http://localhost:5173,http://127.0.0.1:3000,http://35.92.117.143,http://inha-capstone-03-frontend.s3-website-us-west-2.amazonaws.com,https://kindmap-for-you.cloud"
REDIS_PUBSUB_ENABLED: "true"
REDIS_PUBSUB_CHANNEL: "kindmap_events"
WHISPER_MODEL_DIR: "/root/.cache/huggingface"
# C++ 엔진 활성화
USE_CPP_ENGINE: "false"
expose:
- "8001"
networks:
- kindmap-network
depends_on:
redis:
condition: service_healthy
# [Modified] 1 Container - 1 Worker 전략 적용
# C++ 엔진은 GIL을 우회하므로 컨테이너당 단일 워커로 충분하며,
# 3개의 레플리카를 통해 처리량을 3배로 늘립니다.
command: >
gunicorn app.main:app
--workers 1
--worker-class uvicorn.workers.UvicornWorker
--bind 0.0.0.0:8001
--timeout 300
--keep-alive 120
--worker-connections 1000
# volumes:
# - /home/ec2-user/model_cache:/root/.cache/huggingface
deploy:
# [Modified] 레플리카 3개로 확장
replicas: 3
resources:
limits:
# 3개의 컨테이너가 호스트 CPU를 효율적으로 나눠 쓰도록 제한 (1.0 ~ 1.5 권장)
cpus: "1.5"
# [Modified] C++ 최적화 반영: 메모리 사용량이 줄었으므로 1G로 하향 조정하여
# 3개 컨테이너(총 3GB)가 T3.medium 등에서 안전하게 실행되도록 함
memory: 1G
reservations:
cpus: "0.25"
memory: 512M
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import urllib.request; urllib.request.urlopen('http://localhost:8001/health').read()",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
nginx:
image: ${REPOSITORY_URI}:nginx-${IMAGE_TAG}
container_name: kindmap-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
depends_on:
- fastapi
networks:
- kindmap-network
volumes:
- /etc/letsencrypt:/etc/letsencrypt
healthcheck:
test:
[
"CMD",
"wget",
"--quiet",
"--tries=1",
"--spider",
"http://localhost/health",
]
interval: 30s
timeout: 3s
retries: 3
start_period: 10s
networks:
kindmap-network:
driver: bridge
volumes:
redis-data:
driver: local