All four services now share one builder stage (dependencies compile once per deploy, not once per service). BuildKit cache mounts keep the cargo registry and target/ between deploys: a one-line change rebuilds in ~16 s instead of recompiling the whole dependency tree.
35 lines
1 KiB
Bash
Executable file
35 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Idempotent redeploy for LoVisual. Run as: /opt/lovisual/deploy.sh
|
|
set -euo pipefail
|
|
|
|
REPO_DIR=/opt/lovisual
|
|
FRONTEND_ROOT=/var/www/visual.loki-code.dev/html
|
|
|
|
cd "$REPO_DIR"
|
|
git pull --ff-only
|
|
|
|
echo "==> Building backend images (one at a time: the first builds the shared Rust builder stage, the rest reuse it)"
|
|
cd "$REPO_DIR/backend"
|
|
COMPOSE_PARALLEL_LIMIT=1 docker compose -f docker-compose.prod.yml build
|
|
|
|
echo "==> (Re)starting backend services"
|
|
docker compose -f docker-compose.prod.yml up -d
|
|
|
|
echo "==> Trimming the build cache (keeps the cargo/target cache mounts warm, caps disk use)"
|
|
docker builder prune -f --keep-storage 8GB >/dev/null || true
|
|
|
|
echo "==> Building frontend"
|
|
cd "$REPO_DIR/frontend"
|
|
bun install --frozen-lockfile
|
|
bun run build
|
|
|
|
echo "==> Syncing frontend build to $FRONTEND_ROOT"
|
|
mkdir -p "$FRONTEND_ROOT"
|
|
rsync -a --delete dist/ "$FRONTEND_ROOT/"
|
|
|
|
echo "==> Reloading nginx"
|
|
nginx -t
|
|
systemctl reload nginx
|
|
|
|
echo "==> Done"
|
|
docker compose -f "$REPO_DIR/backend/docker-compose.prod.yml" ps
|