feat: Bake build metadata (git tag, commit, date) into OCI image and display in web UI
Some checks failed
Deploy to K8s / deploy (push) Failing after 10s
Build and Push / build (push) Successful in 6s

Store git tag, commit hash, and build date as OCI-standard labels and a
build_meta.json file inside the Docker image. The Flask app reads this at
startup and displays version info in all page footers. Adds /version JSON
endpoint for programmatic access. Falls back to dev@local outside Docker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 16:30:20 +01:00
parent 8b3223f865
commit 3c1604c7af
10 changed files with 35 additions and 9 deletions

13
app.py
View File

@@ -72,6 +72,13 @@ def warmup_cache():
logger.info("Cache warmup complete.")
app = Flask(__name__)
import json as _json
_meta_path = Path(__file__).parent / "build_meta.json"
BUILD_META = _json.loads(_meta_path.read_text()) if _meta_path.exists() else {
"tag": "dev", "commit": "local", "build_date": ""
}
warmup_cache()
@app.before_request
@@ -101,7 +108,7 @@ def inject_render_time():
"total": f"{total:.3f}",
"breakdown": " | ".join(breakdown)
}
return dict(get_render_time=get_render_time)
return dict(get_render_time=get_render_time, build_meta=BUILD_META)
@app.route("/")
def index():
@@ -113,6 +120,10 @@ def flush_cache_endpoint():
deleted = flush_cache()
return jsonify({"status": "ok", "deleted_files": deleted})
@app.route("/version")
def version():
return BUILD_META
@app.route("/fees")
def fees():
attendance_url = f"https://docs.google.com/spreadsheets/d/{ATTENDANCE_SHEET_ID}/edit"