Files
archy/docker/conduit-market/docker-entrypoint.sh
T

44 lines
1.9 KiB
Bash
Raw Normal View History

#!/bin/sh
# Runs via nginx's own /docker-entrypoint.d/ hook mechanism (official nginx
# image sources every executable script there before starting nginx) --
# no custom ENTRYPOINT needed. Writes /runtime-env.js, loaded by index.html
# before the app bundle (see Dockerfile), so this container's own env vars
# can flip Conduit between an isolated private relay and the public Conduit
# network without rebuilding the image -- see
# packages/core/src/config.ts's getRuntimeOverrides() (installed by
# apply-runtime-override.py) for the other half of this.
set -eu
CONDUIT_MODE="${CONDUIT_MODE:-public}"
OUT=/usr/share/nginx/html/runtime-env.js
if [ "$CONDUIT_MODE" = "private" ]; then
if [ -z "${CONDUIT_PRIVATE_RELAY_URLS:-}" ]; then
echo "conduit-market: CONDUIT_MODE=private requires CONDUIT_PRIVATE_RELAY_URLS (comma-separated wss:// URLs) -- refusing to start with no relay configured" >&2
exit 1
fi
cat > "$OUT" <<EOF
window.__CONDUIT_RUNTIME_ENV__ = {
relayUrl: "",
defaultRelayUrl: "${CONDUIT_PRIVATE_RELAY_URLS}",
defaultRelays: "${CONDUIT_PRIVATE_RELAY_URLS}",
appWriteRelayUrls: "${CONDUIT_PRIVATE_RELAY_URLS}",
publicRelayUrls: "${CONDUIT_PRIVATE_RELAY_URLS}",
commerceRelayUrls: "${CONDUIT_PRIVATE_RELAY_URLS}",
lightningNetwork: "${CONDUIT_LIGHTNING_NETWORK:-mainnet}"
};
EOF
echo "conduit-market: CONDUIT_MODE=private -- isolated to ${CONDUIT_PRIVATE_RELAY_URLS}"
else
# public: no relay overrides at all, so Conduit's own built-in canonical
# public relay defaults (packages/core/src/config.ts,
# CANONICAL_APP_RELAY_DEFINITIONS) apply exactly as they do upstream --
# this store fully participates in the wider Conduit network.
cat > "$OUT" <<EOF
window.__CONDUIT_RUNTIME_ENV__ = {
lightningNetwork: "${CONDUIT_LIGHTNING_NETWORK:-mainnet}"
};
EOF
echo "conduit-market: CONDUIT_MODE=public -- using Conduit's default public relay network"
fi