From 738a579038799ebad9bafe007de3696e3794face Mon Sep 17 00:00:00 2001 From: Stan Brubaker <120737309+stanbrub@users.noreply.github.com> Date: Mon, 19 Aug 2024 19:53:48 -0600 Subject: [PATCH] Commit Hash in Docker Image (#115) --- .github/workflows/branch-ci.yml | 7 +++++++ .github/workflows/edge-ci.yml | 9 ++++++++- contexts/server-slim/Dockerfile | 16 +++++++++++++++- contexts/server/Dockerfile | 16 +++++++++++++++- server-slim.hcl | 5 +++++ server.hcl | 5 +++++ 6 files changed, 55 insertions(+), 3 deletions(-) diff --git a/.github/workflows/branch-ci.yml b/.github/workflows/branch-ci.yml index 507b9f3..e70e54b 100644 --- a/.github/workflows/branch-ci.yml +++ b/.github/workflows/branch-ci.yml @@ -19,6 +19,8 @@ concurrency: release jobs: assemble-deephaven-core: runs-on: ubuntu-24.04 + outputs: + git-revision: ${{ steps.get-git-revision.outputs.GIT_REVISION }} steps: - name: Checkout deephaven-core uses: actions/checkout@v4 @@ -26,6 +28,10 @@ jobs: repository: deephaven/deephaven-core ref: ${{ github.event.inputs.deephaven_core_ref }} + - name: Get GIT Revision + id: get-git-revision + run: echo "GIT_REVISION="$(git rev-parse HEAD) >> $GITHUB_OUTPUT + - name: Setup JDK 11 id: setup-java-11 uses: actions/setup-java@v4 @@ -106,6 +112,7 @@ jobs: env: DEEPHAVEN_SOURCES: custom DEEPHAVEN_VERSION: ${{ steps.artifact_metadata.outputs.deephaven_version }} + GIT_REVISION: ${{ needs.assemble-deephaven-core.outputs.git-revision }} DEEPHAVEN_CORE_WHEEL: ${{ steps.artifact_metadata.outputs.deephaven_core_wheel }} MULTI_ARCH: true RELEASE: true diff --git a/.github/workflows/edge-ci.yml b/.github/workflows/edge-ci.yml index ae18197..b0392f1 100644 --- a/.github/workflows/edge-ci.yml +++ b/.github/workflows/edge-ci.yml @@ -18,12 +18,18 @@ jobs: if: ${{ github.repository_owner == 'deephaven' || github.event_name != 'schedule' }} runs-on: ubuntu-24.04 + outputs: + git-revision: ${{ steps.get-git-revision.outputs.GIT_REVISION }} steps: - name: Checkout deephaven-core uses: actions/checkout@v4 with: repository: deephaven/deephaven-core + - name: Get GIT Revision + id: get-git-revision + run: echo "GIT_REVISION="$(git rev-parse HEAD) >> $GITHUB_OUTPUT + - name: Setup JDK 11 id: setup-java-11 uses: actions/setup-java@v4 @@ -33,7 +39,7 @@ jobs: - name: Set JAVA_HOME run: echo "JAVA_HOME=${{ steps.setup-java-11.outputs.path }}" >> $GITHUB_ENV - + - name: Setup gradle properties run: | .github/scripts/gradle-properties.sh >> gradle.properties @@ -105,6 +111,7 @@ jobs: env: DEEPHAVEN_SOURCES: custom DEEPHAVEN_VERSION: ${{ steps.artifact_metadata.outputs.deephaven_version }} + GIT_REVISION: ${{ needs.assemble-deephaven-core.outputs.git-revision }} DEEPHAVEN_CORE_WHEEL: ${{ steps.artifact_metadata.outputs.deephaven_core_wheel }} MULTI_ARCH: true RELEASE: ${{ github.event_name != 'pull_request' }} diff --git a/contexts/server-slim/Dockerfile b/contexts/server-slim/Dockerfile index 5ef9a59..f0e1a4b 100644 --- a/contexts/server-slim/Dockerfile +++ b/contexts/server-slim/Dockerfile @@ -84,7 +84,7 @@ LABEL \ # ------------------------------------- -FROM openjdk-bits as deephaven-bits +FROM openjdk-bits as deephaven-bits-released ARG DEEPHAVEN_VERSION COPY --link --from=deephaven /opt/deephaven /opt/deephaven LABEL \ @@ -92,6 +92,20 @@ LABEL \ # ------------------------------------- +FROM openjdk-bits as deephaven-bits-custom +ARG DEEPHAVEN_VERSION +ARG GIT_REVISION +COPY --link --from=deephaven /opt/deephaven /opt/deephaven +LABEL \ + io.deephaven.server.version="${DEEPHAVEN_VERSION}" \ + org.opencontainers.image.revision="${GIT_REVISION}" + +# ------------------------------------- + +FROM deephaven-bits-${DEEPHAVEN_SOURCES} as deephaven-bits + +# ------------------------------------- + FROM deephaven-bits as grpc-health-probe-bits ARG GRPC_HEALTH_PROBE_VERSION ADD --link --chmod=755 \ diff --git a/contexts/server/Dockerfile b/contexts/server/Dockerfile index f86366f..d11b4af 100644 --- a/contexts/server/Dockerfile +++ b/contexts/server/Dockerfile @@ -144,7 +144,7 @@ LABEL \ # ------------------------------------- -FROM openjdk-bits as deephaven-bits +FROM openjdk-bits as deephaven-bits-released ARG DEEPHAVEN_VERSION COPY --link --from=deephaven /opt/deephaven /opt/deephaven LABEL \ @@ -152,6 +152,20 @@ LABEL \ # ------------------------------------- +FROM openjdk-bits as deephaven-bits-custom +ARG DEEPHAVEN_VERSION +ARG GIT_REVISION +COPY --link --from=deephaven /opt/deephaven /opt/deephaven +LABEL \ + io.deephaven.server.version="${DEEPHAVEN_VERSION}" \ + org.opencontainers.image.revision="${GIT_REVISION}" + +# ------------------------------------- + +FROM deephaven-bits-${DEEPHAVEN_SOURCES} as deephaven-bits + +# ------------------------------------- + FROM deephaven-bits as grpc-health-probe-bits ARG GRPC_HEALTH_PROBE_VERSION ADD --link --chmod=755 \ diff --git a/server-slim.hcl b/server-slim.hcl index 727bc4d..16db3ff 100644 --- a/server-slim.hcl +++ b/server-slim.hcl @@ -28,6 +28,10 @@ variable "DEEPHAVEN_VERSION" { default = "0.36.0" } +variable "GIT_REVISION" { + default = "" +} + variable "OPENJDK_VERSION" { default = "21" } @@ -73,6 +77,7 @@ target "server-slim" { ] args = { DEEPHAVEN_VERSION = DEEPHAVEN_VERSION + GIT_REVISION = GIT_REVISION OPENJDK_VERSION = OPENJDK_VERSION UBUNTU_VERSION = UBUNTU_VERSION GRPC_HEALTH_PROBE_VERSION = GRPC_HEALTH_PROBE_VERSION diff --git a/server.hcl b/server.hcl index bd72c70..61a164e 100644 --- a/server.hcl +++ b/server.hcl @@ -39,6 +39,10 @@ variable "DEEPHAVEN_VERSION" { default = "0.36.0" } +variable "GIT_REVISION" { + default = "" +} + variable "DEEPHAVEN_CORE_WHEEL" { default = "" } @@ -169,6 +173,7 @@ target "server-context" { context = "contexts/server/" args = { DEEPHAVEN_VERSION = DEEPHAVEN_VERSION + GIT_REVISION = GIT_REVISION DEEPHAVEN_CORE_WHEEL = DEEPHAVEN_CORE_WHEEL OPENJDK_VERSION = OPENJDK_VERSION PYTHON_VERSION = PYTHON_VERSION