Files
archy/docker/conduit-market/docker-entrypoint.sh
T
ssmithxandClaude Sonnet 5 bb0193932f Package Conduit Market as an Archipelago app
Pure client-side Nostr+Lightning marketplace (apps/market from
Conduit-BTC/conduit-mono) built into a static nginx image. Public/private
is a genuine runtime toggle, not two separate builds: Vite bakes VITE_*
relay config into the bundle at build time, so config.ts is patched
(apply-runtime-override.py) to merge in a window.__CONDUIT_RUNTIME_ENV__
override written by docker-entrypoint.sh from CONDUIT_MODE /
CONDUIT_PRIVATE_RELAY_URLS at container start -- flipping mode only needs
a restart, not a rebuild. Verified end-to-end: build succeeds, the
override survives bundling/minification, and public/private/missing-relay
all produce the correct runtime-env.js (private with no relay URL refuses
to start rather than silently falling back to the public network).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-26 23:21:27 +00:00

44 lines
1.9 KiB
Bash

#!/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