-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
During Docker image builds, automatically inject the last git commit hash and message as build args (DOKPLOY_COMMIT_HASH and DOKPLOY_COMMIT_MESSAGE), so users can expose them as runtime environment variables in their Dockerfiles.
Motivation
Currently there's no way to access git commit information at runtime inside deployed containers. This is useful for:
- Displaying version/commit info in application UIs or health endpoints
- Debugging which exact commit is running in a given deployment
- Logging and observability
Proposed Solution
After cloning the repo and before running docker build, extract the commit info via git commands and pass them as --build-arg:
DOKPLOY_COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DOKPLOY_COMMIT_MESSAGE=$(git log -1 --pretty=%s 2>/dev/null || echo "unknown")
docker build ... --build-arg DOKPLOY_COMMIT_HASH="$DOKPLOY_COMMIT_HASH" --build-arg DOKPLOY_COMMIT_MESSAGE="$DOKPLOY_COMMIT_MESSAGE"Users would then add to their Dockerfile:
ARG DOKPLOY_COMMIT_HASH
ARG DOKPLOY_COMMIT_MESSAGE
ENV DOKPLOY_COMMIT_HASH=$DOKPLOY_COMMIT_HASH
ENV DOKPLOY_COMMIT_MESSAGE=$DOKPLOY_COMMIT_MESSAGEThis should be applied to all relevant builders (dockerfile, railpack, etc.).
I'm going to work on this and submit a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request