Some checks failed
Build and Push Docker Image / build (push) Failing after 28s
Patch RequestResponder.respond() and cancel() at startup to handle the race where a notifications/cancelled arrives between handler return and respond(), which crashes the session with "AssertionError: Request already responded to". Also improve build.sh to handle registry push failures gracefully and auto-restart the container after building.
46 lines
1.4 KiB
Bash
Executable File
46 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
SCRAPER_DIR="/home/b3nw/projects/financial/schwab-scraper"
|
|
IMAGE="gitea.ext.ben.io/b3nw/schwab-mcp-custom:latest"
|
|
BUILD_HOST="${BUILD_HOST:-docker-test}"
|
|
COMPOSE_DIR="/opt/schwab-mcp-custom"
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
echo "==> Preparing vendor directory..."
|
|
rm -rf vendor/schwab-scraper
|
|
mkdir -p vendor/schwab-scraper
|
|
git -C "$SCRAPER_DIR" archive HEAD | tar -x -C vendor/schwab-scraper
|
|
|
|
echo "==> Syncing build context to $BUILD_HOST..."
|
|
rsync -az --delete \
|
|
--exclude '.venv' \
|
|
--exclude '.git' \
|
|
--exclude '__pycache__' \
|
|
--exclude 'cookies.json' \
|
|
--exclude 'config.json' \
|
|
--exclude '.env' \
|
|
"$PROJECT_DIR/" "$BUILD_HOST:/tmp/schwab-mcp-build/"
|
|
|
|
echo "==> Building Docker image on $BUILD_HOST..."
|
|
ssh "$BUILD_HOST" "cd /tmp/schwab-mcp-build && docker build -t $IMAGE ."
|
|
|
|
echo "==> Pushing image to registry..."
|
|
if ssh "$BUILD_HOST" "docker push $IMAGE" 2>/dev/null; then
|
|
echo " Image pushed to registry."
|
|
else
|
|
echo " Registry push failed (auth?), image available locally only."
|
|
fi
|
|
|
|
echo "==> Restarting container..."
|
|
ssh "$BUILD_HOST" "cd $COMPOSE_DIR && docker compose up -d --force-recreate --pull never --no-deps schwab-mcp"
|
|
|
|
echo "==> Cleaning up..."
|
|
rm -rf vendor/schwab-scraper
|
|
ssh "$BUILD_HOST" "rm -rf /tmp/schwab-mcp-build"
|
|
|
|
echo "==> Done! Container restarted with new image."
|