From 35a6544b799af28b1891d4f6200d7450ae48419f Mon Sep 17 00:00:00 2001
From: Anton Kostenko <anton.k@metabase.com>
Date: Tue, 28 May 2024 16:47:23 -0400
Subject: [PATCH] Add Git repo SHA to the final image for future tracking
 (#43260)

---
 .github/workflows/uberjar.yml | 4 ++++
 bin/docker/Dockerfile         | 3 +++
 bin/docker/Dockerfile_ubuntu  | 3 +++
 3 files changed, 10 insertions(+)

diff --git a/.github/workflows/uberjar.yml b/.github/workflows/uberjar.yml
index 03fa2880a6a..da52399fc15 100644
--- a/.github/workflows/uberjar.yml
+++ b/.github/workflows/uberjar.yml
@@ -116,6 +116,8 @@ jobs:
         platforms: linux/amd64
         network: host
         tags: localhost:5000/metabase-dev:${{ steps.extract_branch.outputs.branch }}-${{ matrix.edition }}
+        build-args: |
+          GIT_COMMIT_SHA=${{ github.sha }}
         no-cache: true
         push: true
     - name: Launch ${{ matrix.edition }} container
@@ -240,6 +242,8 @@ jobs:
           file: bin/docker/Dockerfile_ubuntu
           network: host
           tags: localhost:5000/metabase-dev:${{ steps.extract_branch.outputs.branch }}-${{ matrix.edition }}-ubuntu
+          build-args: |
+            GIT_COMMIT_SHA=${{ github.sha }}
           no-cache: true
           push: true
       - name: Launch ${{ matrix.edition }} Ubuntu based container
diff --git a/bin/docker/Dockerfile b/bin/docker/Dockerfile
index 38b3dc07620..700e12080d8 100644
--- a/bin/docker/Dockerfile
+++ b/bin/docker/Dockerfile
@@ -2,6 +2,9 @@ FROM --platform=linux/amd64 eclipse-temurin:11-jre-alpine
 
 ENV FC_LANG=en-US LC_CTYPE=en_US.UTF-8
 
+ARG GIT_COMMIT_SHA
+ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
+
 # dependencies
 RUN apk add -U bash fontconfig curl font-noto font-noto-arabic font-noto-hebrew font-noto-cjk java-cacerts && \
     apk upgrade && \
diff --git a/bin/docker/Dockerfile_ubuntu b/bin/docker/Dockerfile_ubuntu
index 8052be66750..8b0e074df2a 100644
--- a/bin/docker/Dockerfile_ubuntu
+++ b/bin/docker/Dockerfile_ubuntu
@@ -2,6 +2,9 @@ FROM eclipse-temurin:11-jre-jammy as runner
 
 ENV FC_LANG=en-US LC_CTYPE=en_US.UTF-8
 
+ARG GIT_COMMIT_SHA
+ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
+
 # Dependencies
 RUN apt-get update && \
   apt-get upgrade -y && \
-- 
GitLab