harb/containers/ponder-dev-entrypoint.sh
johba a29ca1a26a Harden kraiken-lib watch loop and confirm host-built dist propagation (#38)
- expand scripts/watch-kraiken-lib.sh to watch atomic rename events, validate required tools, and gracefully restart only the containers that mount kraiken-
  lib/dist
  - verify the host-built dist is mounted read-only inside each service and observe live rebuild + restart behavior under inotify
  - run the local podman stack, exercise the watcher by editing kraiken-lib/src/helpers.ts, and confirm GraphQL responds through Caddy after restarts

resolves #33

Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/38
2025-10-02 14:33:59 +02:00

39 lines
1,021 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR=/workspace
CONTRACT_ENV=$ROOT_DIR/tmp/podman/contracts.env
PONDER_WORKDIR=$ROOT_DIR/services/ponder
while [[ ! -f "$CONTRACT_ENV" ]]; do
echo "[ponder-entrypoint] waiting for contracts env"
sleep 2
done
cd "$PONDER_WORKDIR"
REQUIRED_DIST="$ROOT_DIR/kraiken-lib/dist/index.js"
if [[ ! -f "$REQUIRED_DIST" ]]; then
echo "[ponder-entrypoint] ERROR: Run ./scripts/build-kraiken-lib.sh before starting containers" >&2
exit 1
fi
echo "[ponder-entrypoint] Installing dependencies..."
npm install --no-save --loglevel error 2>&1 || {
echo "[ponder-entrypoint] npm install failed, trying with --force"
npm install --force --no-save --loglevel error
}
# Load and export all environment variables from .env.local
if [[ -f .env.local ]]; then
echo "[ponder-entrypoint] Loading environment from .env.local"
set -a
source .env.local
set +a
fi
export CHOKIDAR_USEPOLLING=${CHOKIDAR_USEPOLLING:-1}
export HOST=0.0.0.0
export PORT=${PORT:-42069}
exec npm run dev