Rebuild deploy process on the project template
- Dockerfile: deps → builder → pb-downloader → runner stages, cross-arch (BUILDPLATFORM node stages, TARGETARCH PocketBase binary), Debian slim runner, VOLUME /app/pb_data, dual healthcheck, docker-entrypoint.sh - docker-entrypoint.sh: bash supervisor replacing scripts/run-all.mjs - Makefile: build-production (multi-arch push from git remote), build-check, build-check-local - deploy.sh [tag]: make build-production then ansible-playbook with tag - drop .env/.env.example (credentials live in ansible/vars/default.yml)
This commit is contained in:
@@ -1,40 +1,19 @@
|
||||
#!/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
|
||||
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
|
||||
cd "$parent_path" || exit
|
||||
|
||||
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}"
|
||||
echo "========================================================"
|
||||
echo " Building & Uploading Docker Image"
|
||||
echo "========================================================"
|
||||
current_version="${1:-latest}"
|
||||
make build-production TAG="$current_version"
|
||||
|
||||
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"
|
||||
echo ""
|
||||
echo "========================================================"
|
||||
echo " Executing Ansible Deployment"
|
||||
echo "========================================================"
|
||||
cd "$parent_path/ansible" || exit
|
||||
ansible-playbook playbook.yml -e "tag=$current_version"
|
||||
|
||||
Reference in New Issue
Block a user