diff --git a/.github/actions/build-n-cache-image/action.yml b/.github/actions/build-n-cache-image/action.yml index d5ceb305fbcd3..03b5db99a1deb 100644 --- a/.github/actions/build-n-cache-image/action.yml +++ b/.github/actions/build-n-cache-image/action.yml @@ -33,6 +33,7 @@ runs: load: ${{ inputs.load }} tags: ${{ steps.emit.outputs.tag }} platforms: linux/amd64,linux/arm64 + build-args: COMMIT_HASH=${{ github.sha }} env: ACTIONS_ID_TOKEN_REQUEST_URL: ${{ inputs.actions-id-token-request-url }} @@ -45,5 +46,6 @@ runs: file: production-unit.Dockerfile tags: ${{ steps.emit.outputs.tag }} platforms: linux/amd64 + build-args: COMMIT_HASH=${{ github.sha }} env: ACTIONS_ID_TOKEN_REQUEST_URL: ${{ inputs.actions-id-token-request-url }} diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml index 10556e36c4c59..6b15b95ef6898 100644 --- a/.github/workflows/container-images-cd.yml +++ b/.github/workflows/container-images-cd.yml @@ -70,6 +70,7 @@ jobs: push: true tags: posthog/posthog:${{ github.sha }},posthog/posthog:latest,${{ steps.aws-ecr.outputs.registry }}/posthog-cloud:master platforms: linux/arm64,linux/amd64 + build-args: COMMIT_HASH=${{ github.sha }} - name: Build and push unit container image id: build-unit @@ -80,6 +81,7 @@ jobs: file: production-unit.Dockerfile tags: ${{ steps.aws-ecr.outputs.registry }}/posthog-cloud:unit platforms: linux/amd64 + build-args: COMMIT_HASH=${{ github.sha }} - name: get deployer token id: deployer diff --git a/production-unit.Dockerfile b/production-unit.Dockerfile index 59be69641dc21..fb79f50912fb0 100644 --- a/production-unit.Dockerfile +++ b/production-unit.Dockerfile @@ -168,6 +168,10 @@ RUN groupadd -g 1000 posthog && \ chown posthog:posthog /code USER posthog +# Add the commit hash +ARG COMMIT_HASH +RUN echo $COMMIT_HASH > /code/commit.txt + # Add in the compiled plugin-server & its runtime dependencies from the plugin-server-build stage. COPY --from=plugin-server-build --chown=posthog:posthog /code/plugin-server/dist /code/plugin-server/dist COPY --from=plugin-server-build --chown=posthog:posthog /code/plugin-server/node_modules /code/plugin-server/node_modules diff --git a/production.Dockerfile b/production.Dockerfile index 5075ef0671b13..b3d27e2861e51 100644 --- a/production.Dockerfile +++ b/production.Dockerfile @@ -1,7 +1,7 @@ # # This Dockerfile is used for self-hosted production builds. # -# PostHog has sunset support for self-hosted K8s deployments. +# PostHog has sunset support for self-hosted K8s deployments. # See: https://posthog.com/blog/sunsetting-helm-support-posthog # # Note: for PostHog Cloud remember to update ‘Dockerfile.cloud’ as appropriate. @@ -168,6 +168,10 @@ RUN groupadd -g 1000 posthog && \ chown posthog:posthog /code USER posthog +# Add the commit hash +ARG COMMIT_HASH +RUN echo $COMMIT_HASH > /code/commit.txt + # Add in the compiled plugin-server & its runtime dependencies from the plugin-server-build stage. COPY --from=plugin-server-build --chown=posthog:posthog /code/plugin-server/dist /code/plugin-server/dist COPY --from=plugin-server-build --chown=posthog:posthog /code/plugin-server/node_modules /code/plugin-server/node_modules