-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathweb-entrypoint.sh
More file actions
executable file
·44 lines (38 loc) · 1.5 KB
/
web-entrypoint.sh
File metadata and controls
executable file
·44 lines (38 loc) · 1.5 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
#!/bin/sh
set -e
# Auto-detect ASSET_HOST if not explicitly set.
# If the mounted image directory has content, serve images locally.
# Otherwise fall back to the CloudFront CDN.
# Override by setting ASSET_HOST explicitly in docker-compose.yml:
# ASSET_HOST= # force local
# ASSET_HOST=https://assets.arkhamhorror.app # force CDN
if [ -z "${ASSET_HOST+x}" ]; then
img_dir="/opt/arkham/src/frontend/dist/img"
if [ -n "$(ls -A "$img_dir" 2>/dev/null)" ]; then
export ASSET_HOST=""
else
export ASSET_HOST="https://assets.arkhamhorror.app"
fi
fi
# If the app already got a full DATABASE_URL, leave it alone.
if [ -z "${DATABASE_URL}" ]; then
# Prefer env-injected password first (good for Kamal), then Docker secret file.
if [ -n "${PGPASSWORD}" ]; then
DB_PASSWORD="${PGPASSWORD}"
elif [ -n "${POSTGRES_PASSWORD}" ]; then
DB_PASSWORD="${POSTGRES_PASSWORD}"
elif [ -f /run/secrets/postgres_password ]; then
DB_PASSWORD=$(tr -d '\n\r' < /run/secrets/postgres_password)
else
echo "No database password found. Set DATABASE_URL, PGPASSWORD, POSTGRES_PASSWORD, or mount /run/secrets/postgres_password." >&2
exit 1
fi
export PGUSER="${PGUSER:-arkham_pg_user}"
export PGHOST="${PGHOST:-db}"
export PGPORT="${PGPORT:-5432}"
export PGDATABASE="${PGDATABASE:-arkham-horror-backend}"
export PGPASSWORD="${DB_PASSWORD}"
export DATABASE_URL="postgres://${PGUSER}:${PGPASSWORD}@${PGHOST}:${PGPORT}/${PGDATABASE}"
unset DB_PASSWORD
fi
exec "$@"