2025-09-24 10:57:22 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
ROOT_DIR=/workspace
|
|
|
|
|
TXNBOT_ENV_FILE=$ROOT_DIR/tmp/podman/txnBot.env
|
|
|
|
|
BOT_DIR=$ROOT_DIR/services/txnBot
|
2025-09-24 12:10:41 +00:00
|
|
|
KRAIKEN_LIB_DIR=$ROOT_DIR/kraiken-lib
|
2025-09-24 10:57:22 +02:00
|
|
|
|
|
|
|
|
while [[ ! -f "$TXNBOT_ENV_FILE" ]]; do
|
|
|
|
|
echo "[txn-bot-entrypoint] waiting for env file"
|
|
|
|
|
sleep 2
|
|
|
|
|
done
|
|
|
|
|
|
2025-09-24 12:10:41 +00:00
|
|
|
# Build kraiken-lib first
|
|
|
|
|
echo "[txn-bot-entrypoint] Building kraiken-lib..."
|
|
|
|
|
cd "$KRAIKEN_LIB_DIR"
|
|
|
|
|
|
|
|
|
|
# Install dependencies if needed
|
2025-09-24 10:57:22 +02:00
|
|
|
if [[ ! -d node_modules ]]; then
|
2025-09-24 12:10:41 +00:00
|
|
|
echo "[txn-bot-entrypoint] Installing kraiken-lib dependencies..."
|
|
|
|
|
npm install --loglevel error
|
2025-09-24 10:57:22 +02:00
|
|
|
fi
|
|
|
|
|
|
2025-09-24 12:10:41 +00:00
|
|
|
# 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..."
|
2025-10-01 20:26:49 +02:00
|
|
|
./node_modules/.bin/tsc 2>&1 | head -20 || {
|
2025-09-24 12:10:41 +00:00
|
|
|
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
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "$BOT_DIR"
|
|
|
|
|
echo "[txn-bot-entrypoint] Installing txn-bot dependencies..."
|
|
|
|
|
npm install --no-save --loglevel error 2>&1 || {
|
|
|
|
|
echo "[txn-bot-entrypoint] npm install failed, trying with --force"
|
|
|
|
|
npm install --force --no-save --loglevel error
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-24 10:57:22 +02:00
|
|
|
export TXN_BOT_ENV_FILE="$TXNBOT_ENV_FILE"
|
|
|
|
|
exec npm run start
|