feat: add stats helper service

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>
This commit is contained in:
h z
2026-05-17 12:01:53 +01:00
commit 2cfa6ca76a
6 changed files with 242 additions and 0 deletions

22
publish.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/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}"