forked from thezak48/comps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
31 lines (26 loc) · 817 Bytes
/
docker-entrypoint.sh
File metadata and controls
31 lines (26 loc) · 817 Bytes
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
#!/bin/bash
# Set user and group based on environment variables
groupmod -o -g "$PGID" appgroup
usermod -o -u "$PUID" appuser
# Create necessary directories if they don't exist
mkdir -p /config /data/uploads
chown -R appuser:appgroup /config /data /app
# Switch to appuser
# Simple readiness check: try to import app (runs migrations), then start uvicorn.
echo "[entrypoint] Waiting for database and migrations to be ready..."
su appuser -c "python - << 'PY'
import os,time,sys
max_wait=60
start=time.time()
while True:
try:
import main # triggers init_db()
break
except Exception as e:
if time.time()-start>max_wait:
print('[entrypoint] DB/migrations not ready:', e)
sys.exit(1)
time.sleep(2)
print('[entrypoint] DB ready.')
PY"
exec su appuser -c "uvicorn main:app --host 0.0.0.0 --port 8000"