File size: 1,775 Bytes
3464008
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52ffe96
 
 
 
 
 
 
3464008
 
 
 
 
 
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
#!/bin/sh
set -e

# ── Generate ephemeral secrets for the in-container Redis stack ─────────────
# Nothing here is persisted or exposed outside this container; a fresh set is
# generated on every boot, matching World Monitor's own SELF_HOSTING.md model
# (openssl rand -hex 32) minus the manual .env step, since it's all internal.
export REDIS_PASSWORD="$(node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))")"
export REDIS_TOKEN="$(node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))")"
export SRH_TOKEN="$REDIS_TOKEN"
export SRH_CONNECTION_STRING="redis://:${REDIS_PASSWORD}@127.0.0.1:6379"
export UPSTASH_REDIS_REST_URL="http://127.0.0.1:8079"
export UPSTASH_REDIS_REST_TOKEN="$REDIS_TOKEN"

export LOCAL_API_PORT="${LOCAL_API_PORT:-46123}"
export LOCAL_API_MODE="docker"
export LOCAL_API_CLOUD_FALLBACK="false"
if [ -z "${LOCAL_API_TOKEN:-}" ]; then
  LOCAL_API_TOKEN="$(node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))")"
  export LOCAL_API_TOKEN
fi

# Signs the anonymous session cookie minted by /api/wm-session (api/_session.js
# fails closed β€” 503s every panel β€” without this, min 32 chars).
if [ -z "${WM_SESSION_SECRET:-}" ]; then
  WM_SESSION_SECRET="$(node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))")"
  export WM_SESSION_SECRET
fi

# World Monitor's own internal nginx (unmodified template, :8080) needs these
# two vars substituted in, same as its stock docker/entrypoint.sh.
envsubst '$LOCAL_API_PORT $LOCAL_API_TOKEN' < /etc/nginx/wm-internal.conf.template > /tmp/nginx-internal.conf
cp /etc/nginx/wm-outer.conf.template /tmp/nginx-outer.conf

exec /usr/bin/supervisord -c /etc/supervisor/conf.d/combined.conf