-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
122 lines (113 loc) · 2.96 KB
/
docker-compose.yml
File metadata and controls
122 lines (113 loc) · 2.96 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
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"
# Dockerfile에서 설정했지만 명시적으로 한번 더 선언
WHISPER_MODEL_DIR: "/root/.cache/huggingface"
expose:
- "8001"
networks:
- kindmap-network
depends_on:
redis:
condition: service_healthy
# Dockerfile의 CMD와 동일하지만,
# docker-compose에서 명시적으로 제어
command: >
gunicorn app.main:app
--workers 2
--worker-class uvicorn.workers.UvicornWorker
--bind 0.0.0.0:8001
--timeout 120
--keep-alive 120
--worker-connections 1000
# Dockerfile에서 이미지를 빌드할 때 모델을 내장(Pre-baking) 했으므로
# 볼륨을 마운트하면 내장된 모델이 가려져서 다시 다운로드를 시도
# => volumes 부분은 삭제
# volumes:
# - /home/ec2-user/model_cache:/root/.cache/huggingface
deploy:
replicas: 1
resources:
limits:
cpus: "2.0"
memory: 2G
reservations:
cpus: "1.0"
memory: 1G
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