feat: Bake build metadata (git tag, commit, date) into OCI image and display in web UI
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:
13
app.py
13
app.py
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user