#!/usr/bin/env bash # Deploy origin/dev to the shared server (ssh alias `vobot`, dir /srv/ptsr). Run from a clean checkout: # infra/deploy/deploy.sh [git-ref] default: origin/dev # Keeps /srv/ptsr/.env (secrets live only on the server) and the Postgres volume. set -euo pipefail REF=${1:-origin/dev} HOST=${DEPLOY_HOST:-vobot} DIR=/srv/ptsr git fetch -q origin SHA=$(git rev-parse --short "$REF") echo "deploy $REF ($SHA) -> $HOST:$DIR" git archive --format=tar "$REF" | ssh "$HOST" "rm -rf $DIR/app.new && mkdir -p $DIR/app.new && tar -x -C $DIR/app.new" ssh "$HOST" bash -s < REVISION docker run --rm -v "\$PWD/web:/w" -w /w node:20-alpine sh -c "npm ci --no-audit --no-fund >/dev/null && npm run build >/dev/null" docker compose -p ptsr -f docker-compose.yml -f infra/deploy/docker-compose.server.yml up -d --build /dev/null && break; sleep 3; done curl -sf 127.0.0.1:8010/health && echo " api ok" SH