siftlode/deploy/deploy.sh

27 lines
1 KiB
Bash
Raw Normal View History

#!/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 (compose file + VERSION)
# /srv/siftlode/.env secrets, mode 0600 (never in git)
#
# The app is no longer built on the host — it's pulled as the prebuilt image published by
# `siftlode publish`. We still sync the repo to pick up the new compose file + VERSION (which
# selects the image tag to pull); the version/sha/build-date are baked into that image.
set -euo pipefail
ROOT=/srv/siftlode
cd "$ROOT/src"
git fetch --quiet origin
git checkout --quiet main
git pull --ff-only --quiet
# The released version selects the published image tag to pull.
export APP_VERSION="$(cat VERSION 2>/dev/null || echo latest)"
docker compose -f docker-compose.prod.yml --env-file "$ROOT/.env" pull
docker compose -f docker-compose.prod.yml --env-file "$ROOT/.env" up -d
docker image prune -f >/dev/null || true
docker compose -f docker-compose.prod.yml --env-file "$ROOT/.env" ps