Files
mrp-qrcode/docker/rebuild.sh
T
2026-04-21 09:07:49 -05:00

40 lines
1.0 KiB
Bash

#!/usr/bin/env sh
# Pull latest source from Gitea, rebuild the local image, and restart the
# container. Intended for the "Unraid builds locally" deploy path documented
# in docs/DEPLOY.md §5. Run it on the Unraid host, not inside the container.
#
# Usage:
# SRC_DIR=/mnt/user/appdata/mrp-qrcode-src \
# IMAGE=mrp-qrcode:local \
# CONTAINER=mrp-qrcode \
# docker/rebuild.sh
#
# Wire it up as a User Scripts plugin cron job to get poor-man's CI.
set -eu
SRC_DIR="${SRC_DIR:-/mnt/user/appdata/mrp-qrcode-src}"
IMAGE="${IMAGE:-mrp-qrcode:local}"
CONTAINER="${CONTAINER:-mrp-qrcode}"
BRANCH="${BRANCH:-main}"
cd "$SRC_DIR"
echo "[rebuild] fetching $BRANCH"
git fetch --prune origin "$BRANCH"
git checkout "$BRANCH"
git reset --hard "origin/$BRANCH"
echo "[rebuild] building $IMAGE"
docker build -t "$IMAGE" .
echo "[rebuild] restarting $CONTAINER"
if docker inspect "$CONTAINER" >/dev/null 2>&1; then
docker restart "$CONTAINER"
else
echo "[rebuild] container $CONTAINER not found — create it from the Unraid GUI first."
exit 1
fi
echo "[rebuild] done"