Commit 8643f36

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-10-27 05:56:09
build: add commit sha and date in docker image
1 parent 980735d
Changed files (2)
.github
workflows
docker
.github/workflows/docker.yml
@@ -62,6 +62,8 @@ jobs:
           file: docker/Dockerfile
           build-args: |
             IMAGE_NAME=ghcr.io/${{ github.repository }}
+            COMMIT_SHA=${{ github.sha }}
+            COMMIT_DATE=${{ github.event.head_commit.timestamp }}
           platforms: linux/amd64
           push: true
           tags: ${{ steps.meta.outputs.tags }}
docker/Dockerfile
@@ -1,5 +1,9 @@
 ARG IMAGE_NAME
 FROM $IMAGE_NAME:base-latest
+ARG COMMIT_SHA
+ARG COMMIT_DATE
+ENV COMMIT_SHA=$COMMIT_SHA \
+    COMMIT_DATE=$COMMIT_DATE
 COPY docker/cont-init.d/ /etc/cont-init.d
 COPY docker/services/ /etc/s6-overlay/s6-rc.d
 COPY --chown=abc src /app