siftlode/deploy/deploy.sh
npeter83 882429d6af feat(version): /api/version + build-time version/commit stamping
Add a VERSION file (0.1.0) and inject APP_VERSION/GIT_SHA/BUILD_DATE as Docker
build-args (both stages; Vite inlines them into the SPA). New public GET
/api/version returns app_version, git_sha, build_date and the Alembic head as the
database revision. deploy.sh and the localdev build pass the args.
2026-06-15 00:06:57 +02:00

25 lines
907 B
Bash
Executable file

#!/usr/bin/env bash
# Roll out the latest main branch to the public VPS instance.
#
# Layout on the host:
# /srv/siftlode/src git clone of this repo (build context + compose file)
# /srv/siftlode/.env secrets, mode 0600 (never in git)
#
# Build runs on the host Docker daemon, so it isn't constrained by the CI runner's memory.
set -euo pipefail
ROOT=/srv/siftlode
cd "$ROOT/src"
git fetch --quiet origin
git checkout --quiet main
git pull --ff-only --quiet
# Stamp the image with the version/commit being built (read by /api/version + the SPA).
export APP_VERSION="$(cat VERSION 2>/dev/null || echo dev)"
export GIT_SHA="$(git rev-parse --short HEAD)"
export BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
docker compose -f docker-compose.prod.yml --env-file "$ROOT/.env" up -d --build
docker image prune -f >/dev/null || true
docker compose -f docker-compose.prod.yml --env-file "$ROOT/.env" ps