Periodically snapshots Gitea instance metrics from a read-only MySQL user and writes stats.json into Gitea custom/public/assets for the home page to fetch same-origin. Config via env vars only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
23 lines
743 B
Bash
Executable File
23 lines
743 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build and publish the stats helper image to the Gitea container registry.
|
|
#
|
|
# IMAGE=git.hangman-lab.top/hzhang/gitea-stats TAG=0.1.0 ./publish.sh
|
|
#
|
|
# Requires: docker logged in to the registry
|
|
# echo "$PASSWORD" | docker login git.hangman-lab.top -u hzhang --password-stdin
|
|
set -euo pipefail
|
|
|
|
IMAGE="${IMAGE:-git.hangman-lab.top/hzhang/gitea-stats}"
|
|
TAG="${TAG:-latest}"
|
|
CONTEXT="$(cd "$(dirname "${BASH_SOURCE[0]}")/stats" && pwd)"
|
|
|
|
echo "building ${IMAGE}:${TAG} (and :latest) from ${CONTEXT}"
|
|
docker build -t "${IMAGE}:${TAG}" -t "${IMAGE}:latest" "${CONTEXT}"
|
|
|
|
echo "pushing ${IMAGE}:${TAG}"
|
|
docker push "${IMAGE}:${TAG}"
|
|
echo "pushing ${IMAGE}:latest"
|
|
docker push "${IMAGE}:latest"
|
|
|
|
echo "done: ${IMAGE}:${TAG}"
|