diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 7666a474..460209db 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -29,7 +29,7 @@ jobs: # Build the Docker image using the Dockerfile - name: Build Docker image run: | - docker build --target runtime -t nv-ingest:latest . + docker build --target runtime --build-arg GIT_COMMIT=${GITHUB_SHA} -t nv-ingest:latest . - name: Run Pytest inside Docker container run: | diff --git a/.github/workflows/docker-nightly-publish.yml b/.github/workflows/docker-nightly-publish.yml index 256a2db3..f3402eb8 100644 --- a/.github/workflows/docker-nightly-publish.yml +++ b/.github/workflows/docker-nightly-publish.yml @@ -27,7 +27,7 @@ jobs: # Build the Docker image using the Dockerfile - name: Build Docker image run: | - docker build --target runtime -t ${{ secrets.DOCKER_REGISTRY }}/nv-ingest:${{ env.CURRENT_DATE }} . + docker build --target runtime --build-arg GIT_COMMIT=${GITHUB_SHA} -t ${{ secrets.DOCKER_REGISTRY }}/nv-ingest:${{ env.CURRENT_DATE }} . # Login to NGC - name: Log in to NGC Registry diff --git a/.github/workflows/docker-release-publish.yml b/.github/workflows/docker-release-publish.yml index 96ff6853..6e3afee6 100644 --- a/.github/workflows/docker-release-publish.yml +++ b/.github/workflows/docker-release-publish.yml @@ -27,7 +27,7 @@ jobs: # Build the Docker image using the Dockerfile - name: Build Docker image run: | - docker build --target runtime -t ${{ secrets.DOCKER_REGISTRY }}/nv-ingest:${{ env.SHORT_BRANCH_NAME }} . + docker build --target runtime --build-arg GIT_COMMIT=${GITHUB_SHA} -t ${{ secrets.DOCKER_REGISTRY }}/nv-ingest:${{ env.SHORT_BRANCH_NAME }} . # Login to NGC - name: Log in to NGC Registry diff --git a/Dockerfile b/Dockerfile index e058323f..eddf4e13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,12 @@ ARG RELEASE_TYPE="dev" ARG VERSION="" ARG VERSION_REV="0" +# Embed the `git rev-parse HEAD` as a Docker metadata label +# Allows for linking container builds to git commits +# docker inspect nv-ingest:latest | jq '.[0].Config.Labels.git_commit' -> GIT_SHA +ARG GIT_COMMIT +LABEL git_commit=$GIT_COMMIT + # Install necessary dependencies using apt-get RUN apt-get update && apt-get install -y \ wget \