Files
greatbear/deploy.sh
T
tanshu 757ec8aee2 Rebuild ansible on the project deploy template
- playbook.yml (hosts: monoco) + vars/default.yml, requirements.yml
- roles: network (shared docker network), greatbear (registry pull,
  bind mount /var/lib/greatbear/pb_data, .env upload, health wait),
  caddy (blockinfile snippet into the shared Caddyfile + docker exec reload)
- image honors PB_DATA_DIR and runs as root to match the bind-mount pattern
- frontend on www.greatbear.in (+apex) with /api/* and /_* proxied to
  PocketBase; admin.greatbear.in redirects to the admin UI
2026-09-03 10:14:11 +05:30

41 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Build the Great Bear image and push it to the private registry.
#
# Reads registry credentials from the environment or from ./.env
# (REGISTRY_USER, REGISTRY_PASSWORD). Optional overrides: REGISTRY,
# IMAGE_NAME, PLATFORM.
#
set -euo pipefail
cd "$(dirname "$0")"
# shellcheck disable=SC1091
[ -f .env ] && set -a && . ./.env && set +a
REGISTRY="${REGISTRY:-registry.tanshu.com}"
IMAGE_NAME="${IMAGE_NAME:-tanshu/greatbear}"
REGISTRY_USER="${REGISTRY_USER:?REGISTRY_USER not set (define it in .env or the environment)}"
REGISTRY_PASSWORD="${REGISTRY_PASSWORD:?REGISTRY_PASSWORD not set (define it in .env or the environment)}"
PLATFORM="${PLATFORM:-linux/amd64}"
IMAGE="$REGISTRY/$IMAGE_NAME"
VERSION="$(git rev-parse --short HEAD 2>/dev/null || date +%Y%m%d%H%M%S)"
echo "==> Building $IMAGE:$VERSION (and :latest) for $PLATFORM"
docker build --platform "$PLATFORM" \
-t "$IMAGE:latest" \
-t "$IMAGE:$VERSION" \
.
echo "==> Logging in to $REGISTRY"
printf '%s' "$REGISTRY_PASSWORD" | docker login "$REGISTRY" --username "$REGISTRY_USER" --password-stdin
echo "==> Pushing $IMAGE:latest"
docker push "$IMAGE:latest"
echo "==> Pushing $IMAGE:$VERSION"
docker push "$IMAGE:$VERSION"
echo
echo "Done. Deploy with:"
echo " cd ansible && ansible-playbook playbook.yml"