tools/deploy.sh
neil 9d910eb147 Tools site: Markdown editor, JSON editor, 24-hour pastebin
Single FastAPI container with a registry-driven single-page front end, so
new tools are one module plus one registry entry. Runs as one container behind a reverse proxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 23:32:22 -08:00

24 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Deploy this checkout (including uncommitted changes) over SSH:
# HOST=root@<server> ./deploy.sh
# HOST=root@<server> ./deploy.sh # elsewhere
# Copies app/ and compose.yml to /opt/tools, rebuilds and restarts the container,
# then waits for it to report healthy. Paste data in /opt/tools/data is kept.
set -euo pipefail
HOST=${HOST:?set HOST=root@<server>}
cd "$(dirname "$0")"
node --test tests/ >/dev/null || { echo "tests failed; not deploying" >&2; exit 1; }
tar -czf - --exclude=__pycache__ --exclude=data app compose.yml |
ssh "$HOST" 'set -e; mkdir -p /opt/tools && rm -rf /opt/tools/app && tar -xzf - -C /opt/tools'
ssh "$HOST" bash -s <<'REMOTE'
set -euo pipefail
cd /opt/tools
mkdir -p data && chown 10001:10001 data && chmod 700 data
docker compose up -d --build --remove-orphans
for i in $(seq 1 30); do
s=$(docker inspect -f '{{.State.Health.Status}}' tools 2>/dev/null || echo none)
[ "$s" = healthy ] && { echo "tools is healthy on 127.0.0.1:8090"; docker image prune -f >/dev/null; exit 0; }
sleep 2
done
echo "tools did not become healthy:" >&2; docker logs --tail 50 tools >&2; exit 1
REMOTE