- Create Dockerfile for Nginx with envsubst for dynamic configuration. - Add djmaster.conf.template for Nginx configuration with upstream services. - Implement docker-entrypoint.sh to substitute environment variables in the Nginx config. - Add README.md in nginx-examples for guidance on using the Nginx template. - Include djmaster.conf.template in nginx-examples for local setup. - Introduce utility functions for fetching YouTube video snippets and titles.
63 lines
2.7 KiB
Bash
63 lines
2.7 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
# ── Generate runtime config from env vars ────────────────────────────────────
|
|
CONFIG_FILE="/ui/build/config.js"
|
|
|
|
cat > "$CONFIG_FILE" <<EOF
|
|
/**
|
|
* Restreamer UI - Runtime Configuration (auto-generated by docker-entrypoint.sh)
|
|
*/
|
|
window.__RESTREAMER_CONFIG__ = {
|
|
CORE_ADDRESS: "${CORE_ADDRESS:-}",
|
|
YTDLP_URL: "${YTDLP_URL:-}",
|
|
YTDLP_TITLES_URL: "${YTDLP_TITLES_URL:-}",
|
|
FB_SERVER_URL: "${FB_SERVER_URL:-}",
|
|
FB_OAUTH_CALLBACK_URL: "${FB_OAUTH_CALLBACK_URL:-}",
|
|
YT_OAUTH_CALLBACK_URL: "${YT_OAUTH_CALLBACK_URL:-}",
|
|
YOUTUBE_API_KEY: "${YOUTUBE_API_KEY:-}",
|
|
};
|
|
EOF
|
|
|
|
echo "[entrypoint] config.js generated:"
|
|
cat "$CONFIG_FILE"
|
|
|
|
# ── Set YTDLP_HOST for Caddy reverse_proxy (default: external service or localhost) ─
|
|
export YTDLP_HOST="${YTDLP_HOST:-192.168.1.20:8282}"
|
|
|
|
# ── Set LIVEKIT_INGRESS_HOST for Caddy reverse_proxy (/w/* → livekit-ingress) ─
|
|
export LIVEKIT_INGRESS_HOST="${LIVEKIT_INGRESS_HOST:-192.168.1.20:8088}"
|
|
|
|
# ── Set EGRESS_HOST for Caddy reverse_proxy (/whep/* → egress server) ──────
|
|
export EGRESS_HOST="${EGRESS_HOST:-llmchats-whep.zuqtxy.easypanel.host}"
|
|
|
|
# ── Persist FB data directory ─────────────────────────────────────────────────
|
|
mkdir -p /data/fb
|
|
export FB_DATA_DIR="${FB_DATA_DIR:-/data/fb}"
|
|
|
|
# ── Start Facebook OAuth2 microserver + WebRTC relay in background ────────────
|
|
echo "[entrypoint] Starting FB OAuth2 + WebRTC relay server on :3002 ..."
|
|
FB_SERVER_PORT=3002 \
|
|
FB_DATA_DIR="$FB_DATA_DIR" \
|
|
FB_ENCRYPTION_SECRET="${FB_ENCRYPTION_SECRET:-restreamer-ui-fb-secret-key-32x!}" \
|
|
RTMP_HOST="${RTMP_HOST:-127.0.0.1}" \
|
|
RTMP_PORT="${RTMP_PORT:-1935}" \
|
|
RTMP_APP="${RTMP_APP:-live}" \
|
|
FFMPEG_BIN="${FFMPEG_BIN:-ffmpeg}" \
|
|
LIVEKIT_API_KEY="${LIVEKIT_API_KEY:-}" \
|
|
LIVEKIT_API_SECRET="${LIVEKIT_API_SECRET:-}" \
|
|
LIVEKIT_WS_URL="${LIVEKIT_WS_URL:-}" \
|
|
LIVEKIT_INGRESS_INTERNAL_URL="${LIVEKIT_INGRESS_INTERNAL_URL:-http://192.168.1.20:8088}" \
|
|
UI_BASE_URL="${UI_BASE_URL:-}" \
|
|
node /ui/server/index.js &
|
|
FB_PID=$!
|
|
echo "[entrypoint] FB server PID: $FB_PID"
|
|
|
|
# ── Wait briefly for FB server to bind ───────────────────────────────────────
|
|
sleep 1
|
|
|
|
# ── Start Caddy (foreground) ──────────────────────────────────────────────────
|
|
echo "[entrypoint] Starting Caddy on :3000 ..."
|
|
exec caddy run --config /ui/Caddyfile
|
|
|