feat: expose running CalVer version via API (#126)

Closes #126

- Dockerfile: ARG BUILD_VERSION=dev baked into ENV APP_VERSION + OCI label
- CI: passes BUILD_VERSION build-arg from git tag to docker build
- main.py: adds GET /health returning {"status": "ok", "version": "..."}
- Dockerfile: updates HEALTHCHECK to use /health (no SQL, lightweight)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-04-09 21:32:52 -05:00
parent 29f9875718
commit 9249cb06f0
3 changed files with 14 additions and 1 deletions

View File

@ -58,6 +58,8 @@ jobs:
tags: |
manticorum67/major-domo-database:${{ steps.version.outputs.version }}
manticorum67/major-domo-database:${{ steps.version.outputs.environment }}
build-args: |
BUILD_VERSION=${{ steps.version.outputs.version }}
cache-from: type=registry,ref=manticorum67/major-domo-database:buildcache
cache-to: type=registry,ref=manticorum67/major-domo-database:buildcache,mode=max

View File

@ -1,10 +1,16 @@
# Use official Python slim image
FROM python:3.12-slim
# Build-time version arg — passed by CI from the git tag
ARG BUILD_VERSION=dev
LABEL org.opencontainers.image.version=$BUILD_VERSION
# Set Python optimizations
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
# Bake the CalVer version into the image so it's readable at runtime
ENV APP_VERSION=$BUILD_VERSION
WORKDIR /usr/src/app
@ -27,7 +33,7 @@ RUN mkdir -p /usr/src/app/storage
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:80/api/v3/current || exit 1
CMD curl -f http://localhost:80/health || exit 1
# Start uvicorn
ENV WEB_WORKERS=2

View File

@ -139,6 +139,11 @@ app.include_router(views.router)
logger.info(f"Loaded all routers.")
@app.get("/health")
async def health():
return {"status": "ok", "version": os.environ.get("APP_VERSION", "dev")}
@app.get("/api/docs", include_in_schema=False)
async def get_docs(req: Request):
logger.debug(req.scope)