diff --git a/.gitea/workflows/build-local.yaml b/.gitea/workflows/build-local.yaml index 4d3758d..5bd3699 100644 --- a/.gitea/workflows/build-local.yaml +++ b/.gitea/workflows/build-local.yaml @@ -35,7 +35,9 @@ jobs: - name: Build and Push Docker Image run: | - docker build -t ghcr.io/gansejunge/${{ env.IMAGE_NAME }}:${{ steps.get_tag.outputs.next }} . + docker build \ + --build-arg COMMIT_ID=$(echo "${{ github.sha }}" | cut -c1-7) \ + -t ghcr.io/gansejunge/${{ env.IMAGE_NAME }}:${{ steps.get_tag.outputs.next }} . docker push ghcr.io/gansejunge/${{ env.IMAGE_NAME }}:${{ steps.get_tag.outputs.next }} - name: Clone ops-deployment repo diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 3cced48..0fe3dff 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -35,7 +35,9 @@ jobs: - name: Build and Push Docker Image run: | - docker build -t ghcr.io/gansejunge/${{ env.IMAGE_NAME }}:${{ steps.get_tag.outputs.next }} . + docker build \ + --build-arg COMMIT_ID=$(echo "${{ github.sha }}" | cut -c1-7) \ + -t ghcr.io/gansejunge/${{ env.IMAGE_NAME }}:${{ steps.get_tag.outputs.next }} . docker push ghcr.io/gansejunge/${{ env.IMAGE_NAME }}:${{ steps.get_tag.outputs.next }} - name: Clone ops-deployment repo diff --git a/Dockerfile b/Dockerfile index f41be2e..0c48267 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,5 +11,9 @@ FROM nvcr.io/nvidia/distroless/python:3.12-v4.1.6 COPY --from=builder /install /usr/local COPY --from=builder /app /app WORKDIR /app + +ARG COMMIT_ID=unknown +ENV COMMIT_ID=$COMMIT_ID + ENTRYPOINT ["python", "main.py"] diff --git a/src/main.py b/src/main.py index cf2af73..6d0d46d 100644 --- a/src/main.py +++ b/src/main.py @@ -168,6 +168,7 @@ async def pull_notifications( async def start_servers(): logger.info("[Server] Starting main API (port 8101) and metrics server (port 9000)...") + logger.info(f"[Server] Build commit id={os.getenv("COMMIT_ID","unknown")}") config_main = uvicorn.Config("main:api", host="0.0.0.0", port=8101, log_level=LOG_LEVEL.lower(), log_config=None) config_metrics = uvicorn.Config("metrics_server:metrics_api", host="0.0.0.0", port=9000, log_level=LOG_LEVEL.lower(), log_config=None)