-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
236 lines (226 loc) · 8.88 KB
/
docker-compose.yml
File metadata and controls
236 lines (226 loc) · 8.88 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
services:
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: transcripts
volumes:
- dbdata:/var/lib/postgresql/data
# NOTE: schema.sql is no longer applied automatically on first boot
# Migrations are now managed by Alembic via the 'migrations' service
# If you need to bootstrap from schema.sql for testing, apply it manually
# Expose Postgres to the host for external clients (psql/DBeaver/etc.)
# If port 5432 is already used on your host, change to something like "5434:5432".
ports:
- '${DB_HOST_PORT:-5435}:5432'
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
ports:
- '${REDIS_HOST_PORT:-6380}:6379'
volumes:
- redis-data:/data
command: redis-server --save 60 1 --loglevel warning
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
timeout: 3s
retries: 5
restart: unless-stopped
migrations:
image: transcript-create:latest
env_file: .env
environment:
DATABASE_URL: postgresql+psycopg://postgres:postgres@db:5432/transcripts
depends_on:
db:
condition: service_healthy
command: ['python3', 'scripts/run_migrations.py', 'upgrade']
restart: 'no'
api:
build:
context: .
args:
# Change to rocm6.1 or rocm6.2 if your host ROCm matches those
ROCM_WHEEL_INDEX: https://download.pytorch.org/whl/rocm6.0
image: transcript-create:latest
env_file: .env
environment:
# Point app to the compose network Postgres
DATABASE_URL: postgresql+psycopg://postgres:postgres@db:5432/transcripts
# Point app to Redis cache inside the compose network
REDIS_URL: redis://redis:6379/0
# Point app to OpenSearch service inside the compose network
OPENSEARCH_URL: http://opensearch:9200
# Persist model caches to a mounted volume
HF_HOME: /root/.cache/hf
HF_HUB_CACHE: /root/.cache/hf/hub
TRANSFORMERS_CACHE: /root/.cache/hf/transformers
LOG_LEVEL: DEBUG
# Disable OpenTelemetry SDK to avoid external telemetry posts
OTEL_SDK_DISABLED: 'true'
ports:
# Map host port 8000 to container port 8000 (matches OAuth callback URLs)
# To use a different host port, set API_HOST_PORT in .env and update OAuth redirect URIs
- '${API_HOST_PORT:-8000}:8000'
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
migrations:
condition: service_completed_successfully
volumes:
- ./data:/data
- ./cache:/root/.cache
devices:
- '/dev/kfd:/dev/kfd'
- '/dev/dri:/dev/dri'
group_add:
- 'video'
worker:
image: transcript-create:latest
env_file: .env
environment:
DATABASE_URL: postgresql+psycopg://postgres:postgres@db:5432/transcripts
OPENSEARCH_URL: http://opensearch:9200
# Persist model caches to a mounted volume
HF_HOME: /root/.cache/hf
HF_HUB_CACHE: /root/.cache/hf/hub
TRANSFORMERS_CACHE: /root/.cache/hf/transformers
LOG_LEVEL: DEBUG
# Use ROCm PyTorch whisper backend and force GPU
WHISPER_BACKEND: 'whisper'
WHISPER_MODEL: 'large-v3'
FORCE_GPU: 'true'
# ROCm stability tweaks for some RDNA cards/drivers
HSA_ENABLE_SDMA: '0'
# Suppress PyTorch FutureWarnings for trusted models
PYTHONWARNINGS: 'ignore::FutureWarning'
# Disable OpenTelemetry SDK to avoid external telemetry posts
OTEL_SDK_DISABLED: 'true'
# Optional: yt-dlp tuning
# Point to a cookies file inside the container to access age-restricted/private videos
# Example: put cookies at ./cache/yt-dlp/cookies.txt and set YTDLP_COOKIES=/root/.cache/yt-dlp/cookies.txt in .env
YTDLP_COOKIES: ${YTDLP_COOKIES:-}
# Extra args passed verbatim to yt-dlp (space-separated)
YTDLP_EXTRA_ARGS: ${YTDLP_EXTRA_ARGS:-}
depends_on:
db:
condition: service_healthy
migrations:
condition: service_completed_successfully
command: ['python3', '-m', 'worker.loop']
volumes:
- ./data:/data
- ./cache:/root/.cache
devices:
- '/dev/kfd:/dev/kfd'
- '/dev/dri:/dev/dri'
group_add:
- 'video'
opensearch:
image: opensearchproject/opensearch:2.12.0
environment:
- discovery.type=single-node
- DISABLE_SECURITY_PLUGIN=true
- DISABLE_INSTALL_DEMO_CONFIG=true
- bootstrap.memory_lock=true
- OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
volumes:
- ./config/opensearch/analysis:/usr/share/opensearch/config/analysis:ro
ulimits:
memlock:
soft: -1
hard: -1
ports:
- '${OPENSEARCH_HOST_PORT:-9201}:9200'
dashboards:
image: opensearchproject/opensearch-dashboards:2.12.0
environment:
- OPENSEARCH_HOSTS=["http://opensearch:9200"]
ports:
- '${DASHBOARDS_HOST_PORT:-5601}:5601'
depends_on:
- opensearch
prometheus:
image: prom/prometheus:v2.55.0
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=30d'
- '--storage.tsdb.retention.size=10GB'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
volumes:
- ./config/prometheus:/etc/prometheus
- prometheus-data:/prometheus
ports:
- '${PROMETHEUS_HOST_PORT:-9091}:9090'
depends_on:
- api
- worker
restart: unless-stopped
grafana:
image: grafana/grafana:11.4.0
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
- GF_SERVER_ROOT_URL=http://localhost:3000
- GF_INSTALL_PLUGINS=
volumes:
- grafana-data:/var/lib/grafana
- ./config/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./config/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./config/grafana/dashboards:/var/lib/grafana/dashboards:ro
ports:
- '${GRAFANA_HOST_PORT:-3301}:3000'
depends_on:
- prometheus
restart: unless-stopped
backup:
image: postgres:16
env_file: .env
environment:
DATABASE_URL: postgresql+psycopg://postgres:postgres@db:5432/transcripts
BACKUP_DIR: /backups
PGHOST: db
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: transcripts
depends_on:
db:
condition: service_healthy
volumes:
- dbdata:/var/lib/postgresql/data:ro
- ./backups:/backups
- ./scripts:/scripts:ro
- ./data:/data:ro
# Run backup daily at 2 AM UTC
# Export metrics every 5 minutes for Prometheus
command: >
sh -c "
apt-get update && apt-get install -y cron rsync &&
mkdir -p /backups/logs &&
echo '0 2 * * * cd /scripts && ./backup_db.sh >> /backups/logs/cron.log 2>&1' > /etc/cron.d/backup &&
echo '0 3 * * * cd /scripts && ./backup_media.sh >> /backups/logs/cron.log 2>&1' >> /etc/cron.d/backup &&
echo '0 4 * * 0 cd /scripts && ./verify_backup.sh >> /backups/logs/cron.log 2>&1' >> /etc/cron.d/backup &&
echo '*/5 * * * * cd /scripts && ./export_backup_metrics.sh --output-file /backups/metrics.prom 2>&1 | logger -t backup-metrics' >> /etc/cron.d/backup &&
chmod 0644 /etc/cron.d/backup &&
crontab /etc/cron.d/backup &&
echo 'Backup service started. Backups scheduled for 2 AM UTC daily.' &&
echo 'Metrics export scheduled every 5 minutes.' &&
cron -f
"
restart: unless-stopped
volumes:
dbdata:
redis-data:
prometheus-data:
grafana-data: