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
This commit is contained in:
parent
b4c829e4d6
commit
a29ca1a26a
10 changed files with 100 additions and 35 deletions
|
|
@ -3,6 +3,12 @@ set -euo pipefail
|
|||
|
||||
ROOT_DIR=/workspace
|
||||
LANDING_DIR=$ROOT_DIR/landing
|
||||
REQUIRED_DIST="$ROOT_DIR/kraiken-lib/dist/index.js"
|
||||
|
||||
if [[ ! -f "$REQUIRED_DIST" ]]; then
|
||||
echo "[landing-entrypoint] ERROR: Run ./scripts/build-kraiken-lib.sh before starting containers" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$LANDING_DIR"
|
||||
echo "[landing-entrypoint] Installing dependencies..."
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ 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"
|
||||
|
|
|
|||
|
|
@ -4,42 +4,16 @@ set -euo pipefail
|
|||
ROOT_DIR=/workspace
|
||||
TXNBOT_ENV_FILE=$ROOT_DIR/tmp/podman/txnBot.env
|
||||
BOT_DIR=$ROOT_DIR/services/txnBot
|
||||
KRAIKEN_LIB_DIR=$ROOT_DIR/kraiken-lib
|
||||
REQUIRED_DIST=$ROOT_DIR/kraiken-lib/dist/index.js
|
||||
|
||||
while [[ ! -f "$TXNBOT_ENV_FILE" ]]; do
|
||||
echo "[txn-bot-entrypoint] waiting for env file"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Build kraiken-lib first
|
||||
echo "[txn-bot-entrypoint] Building kraiken-lib..."
|
||||
cd "$KRAIKEN_LIB_DIR"
|
||||
|
||||
# Install dependencies if needed
|
||||
if [[ ! -d node_modules ]]; then
|
||||
echo "[txn-bot-entrypoint] Installing kraiken-lib dependencies..."
|
||||
npm install --loglevel error
|
||||
fi
|
||||
|
||||
# Install TypeScript if not present
|
||||
if [[ ! -f node_modules/.bin/tsc ]]; then
|
||||
echo "[txn-bot-entrypoint] Installing TypeScript..."
|
||||
npm install --loglevel error typescript
|
||||
fi
|
||||
|
||||
# Build TypeScript files (dist is now a volume, writable by node user)
|
||||
echo "[txn-bot-entrypoint] Compiling TypeScript..."
|
||||
if [[ ! -f dist/index.js ]]; then
|
||||
echo "[txn-bot-entrypoint] Running tsc to compile kraiken-lib..."
|
||||
./node_modules/.bin/tsc 2>&1 | head -20 || {
|
||||
echo "[txn-bot-entrypoint] TypeScript compilation had some issues, checking if files were created..."
|
||||
}
|
||||
|
||||
# Verify the main file exists
|
||||
if [[ ! -f dist/index.js ]]; then
|
||||
echo "[txn-bot-entrypoint] ERROR: Failed to compile kraiken-lib"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "$REQUIRED_DIST" ]]; then
|
||||
echo "[txn-bot-entrypoint] ERROR: Run ./scripts/build-kraiken-lib.sh before starting containers" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$BOT_DIR"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ while [[ ! -f "$CONTRACT_ENV" ]]; do
|
|||
sleep 2
|
||||
done
|
||||
|
||||
REQUIRED_DIST="$ROOT_DIR/kraiken-lib/dist/index.js"
|
||||
if [[ ! -f "$REQUIRED_DIST" ]]; then
|
||||
echo "[frontend-entrypoint] ERROR: Run ./scripts/build-kraiken-lib.sh before starting containers" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$CONTRACT_ENV"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue