diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index 4549ec6..cabb561 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index a35dc6c..608d5b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -26,7 +32,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 diff --git a/app/main.py b/app/main.py index dd23244..5f8cbc0 100644 --- a/app/main.py +++ b/app/main.py @@ -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)