Files
bot-hub/docker-entrypoint.sh
zeekay cd2a15c8a2 Keep Base's ZAP transport off
Base 1.5.91 starts ZAP on [::]:9999 and registers it over mDNS unless
ZAP_DISABLED is set. The API reaches Base over loopback HTTP only.
2026-09-30 02:03:45 -07:00

36 lines
1.1 KiB
Bash

#!/bin/sh
set -e
echo "Bot Hub starting..."
# Hanzo Base, on loopback: only the API beside it talks to it. Its address is
# fixed rather than read from BASE_PORT, because Kubernetes writes
# BASE_PORT=tcp://<ip>:<port> into every pod of a namespace holding a Service
# named base, and a port read from it is no port at all.
# Its ZAP transport would listen on every interface at :9999 and announce itself
# over mDNS; nothing here speaks ZAP, so it stays off.
echo "Starting Base on 127.0.0.1:8090..."
ZAP_DISABLED=1 base serve \
--http 127.0.0.1:8090 \
--dir /app/data \
--migrationsDir /app/hz_migrations &
BASE_PID=$!
# The API reaches Base at http://127.0.0.1:8090 (api/src/lib/env.ts).
echo "Starting API server on port ${PORT:-3001}..."
PORT=${PORT:-3001} bun run /app/api/dist/index.js &
API_PID=$!
# Start web server (Nitro reads PORT for its listen port)
echo "Starting web server on port ${WEB_PORT:-3000}..."
PORT=${WEB_PORT:-3000} bun run /app/.output/server/index.mjs &
WEB_PID=$!
# Wait for any child to exit
wait
EXIT_CODE=$?
# Kill remaining
kill $BASE_PID $API_PID $WEB_PID 2>/dev/null || true
exit $EXIT_CODE