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:
parent
29f9875718
commit
9249cb06f0
@ -58,6 +58,8 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
manticorum67/major-domo-database:${{ steps.version.outputs.version }}
|
manticorum67/major-domo-database:${{ steps.version.outputs.version }}
|
||||||
manticorum67/major-domo-database:${{ steps.version.outputs.environment }}
|
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-from: type=registry,ref=manticorum67/major-domo-database:buildcache
|
||||||
cache-to: type=registry,ref=manticorum67/major-domo-database:buildcache,mode=max
|
cache-to: type=registry,ref=manticorum67/major-domo-database:buildcache,mode=max
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
# Use official Python slim image
|
# Use official Python slim image
|
||||||
FROM python:3.12-slim
|
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
|
# Set Python optimizations
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
ENV PIP_NO_CACHE_DIR=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
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
@ -27,7 +33,7 @@ RUN mkdir -p /usr/src/app/storage
|
|||||||
|
|
||||||
# Health check
|
# Health check
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
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
|
# Start uvicorn
|
||||||
ENV WEB_WORKERS=2
|
ENV WEB_WORKERS=2
|
||||||
|
|||||||
@ -139,6 +139,11 @@ app.include_router(views.router)
|
|||||||
logger.info(f"Loaded all routers.")
|
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)
|
@app.get("/api/docs", include_in_schema=False)
|
||||||
async def get_docs(req: Request):
|
async def get_docs(req: Request):
|
||||||
logger.debug(req.scope)
|
logger.debug(req.scope)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user