-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·69 lines (58 loc) · 1.77 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·69 lines (58 loc) · 1.77 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
#!/bin/sh
set -e
MEDIA_STORAGE=${MEDIA_STORAGE:-local}
LOCAL_MEDIA_DIR=${LOCAL_MEDIA_DIR:-/app/storage}
DEMO_MARKER="$LOCAL_MEDIA_DIR/.demo_downloaded"
DEMO_UPLOAD_TO_S3=${DEMO_UPLOAD_TO_S3:-false}
S3_READY=true
if [ -z "$S3_ENDPOINT" ] || [ -z "$S3_BUCKET" ] || [ -z "$S3_ACCESS_KEY" ] || [ -z "$S3_SECRET_KEY" ]; then
S3_READY=false
fi
EFFECTIVE_STORAGE="$MEDIA_STORAGE"
if [ "$MEDIA_STORAGE" = "s3" ] && [ "$S3_READY" != "true" ]; then
echo "S3 config incomplete; falling back to local storage."
EFFECTIVE_STORAGE="local"
fi
export MEDIA_STORAGE="$EFFECTIVE_STORAGE"
export LOCAL_MEDIA_DIR
# -----------------------------
# Demo download (local or S3)
# -----------------------------
RUN_DEMO_DOWNLOAD=${RUN_DEMO_DOWNLOAD:-false}
if [ "$RUN_DEMO_DOWNLOAD" = "true" ]; then
if [ "$EFFECTIVE_STORAGE" = "s3" ]; then
export DEMO_UPLOAD_TO_S3="true"
fi
if [ ! -f "$DEMO_MARKER" ]; then
echo "Downloading demo content (storage=$EFFECTIVE_STORAGE)..."
npm run demo:videos
mkdir -p "$(dirname "$DEMO_MARKER")"
touch "$DEMO_MARKER"
echo "Demo download completed."
else
echo "Demo content already downloaded; skipping."
fi
else
echo "Demo download skipped (storage=$EFFECTIVE_STORAGE)"
fi
echo "Waiting for database..."
until psql "$DATABASE_URL" -c "SELECT 1" >/dev/null 2>&1; do
sleep 2
done
echo "Running migrations..."
npm run db:migrate
# -----------------------------
# Database seed
# -----------------------------
RUN_DB_SEED=${RUN_DB_SEED:-true}
if [ "$RUN_DB_SEED" = "true" ]; then
SEED_EXISTS=$(psql "$DATABASE_URL" -tAc 'SELECT 1 FROM "User" LIMIT 1;')
if [ -z "$SEED_EXISTS" ]; then
echo "Seeding database..."
npm run db:seed
else
echo "Seed data already present; skipping."
fi
fi
echo "Starting application..."
exec "$@"