Skip to content

Commit

Permalink
chore: add commit hash file to the built docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner committed Oct 5, 2023
1 parent 8e754e4 commit aefd8f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/container-images-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ jobs:
id: aws-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Get current commit hash
id: commit_hash
run: echo "::set-output name=hash::$(git rev-parse HEAD)"

- name: Build and push container image
id: build
uses: depot/build-push-action@v1
Expand All @@ -70,6 +74,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=${{ steps.commit_hash.outputs.hash }}

- name: Build and push unit container image
id: build-unit
Expand All @@ -80,6 +85,7 @@ jobs:
file: production-unit.Dockerfile
tags: ${{ steps.aws-ecr.outputs.registry }}/posthog-cloud:unit
platforms: linux/amd64
build-args: COMMIT_HASH=${{ steps.commit_hash.outputs.hash }}

- name: get deployer token
id: deployer
Expand Down
4 changes: 4 additions & 0 deletions production-unit.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion production.Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aefd8f5

Please sign in to comment.