Initial commit: Nosterm client (terminal-style Nostr chat SPA)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# regenerate runtime client config from env before caddy starts.
|
||||
#
|
||||
# the SPA fetches /config.json at startup, so this lets one prebuilt image be
|
||||
# deployed with different relays per environment without a rebuild. set
|
||||
# NOSTERM_DEFAULT_RELAYS to a comma-separated list of relay websocket urls.
|
||||
set -eu
|
||||
|
||||
CONFIG_PATH=/srv/config.json
|
||||
RELAYS="${NOSTERM_DEFAULT_RELAYS:-}"
|
||||
|
||||
# build a json array from the comma-separated list, trimming blanks.
|
||||
relays_json=""
|
||||
IFS=','
|
||||
for relay in $RELAYS; do
|
||||
# trim surrounding whitespace.
|
||||
trimmed="$(printf '%s' "$relay" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
|
||||
[ -z "$trimmed" ] && continue
|
||||
if [ -z "$relays_json" ]; then
|
||||
relays_json="\"$trimmed\""
|
||||
else
|
||||
relays_json="$relays_json,\"$trimmed\""
|
||||
fi
|
||||
done
|
||||
unset IFS
|
||||
|
||||
printf '{\n "relays": [%s]\n}\n' "$relays_json" > "$CONFIG_PATH"
|
||||
|
||||
if [ -n "$relays_json" ]; then
|
||||
echo "[entrypoint] wrote $CONFIG_PATH with relays: $RELAYS"
|
||||
else
|
||||
echo "[entrypoint] no NOSTERM_DEFAULT_RELAYS set; wrote empty relay list"
|
||||
fi
|
||||
|
||||
# hand off to the container command (caddy).
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user