From 25b9d20094dc3707513d1d852325207f02a5f60f Mon Sep 17 00:00:00 2001 From: "ryan.gogo" Date: Sun, 15 Feb 2026 11:00:45 +0100 Subject: [PATCH] Fix: Use short git commit ID (7 chars) instead of full hash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Research findings: - Industry standard uses 'git rev-parse --short HEAD' (7 characters) - Short hashes are more readable for logs and health endpoints - Git automatically extends hash if 7 chars aren't unique - Better for production deployment tracking and version verification Changes: - Dockerfile: Use --short flag to get 7-character commit ID - README: Update examples to show short commit format (0e993d9) - README: Add explanation of why short commits are used Example health response: { "git_commit": "0e993d9", // 7 chars, not full 40-char SHA "version": "1.0.0" } 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- Dockerfile | 4 ++-- README.md | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9ecca8b..85dc1ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,9 @@ RUN npm install --production # Copy app code (changes more often — below the cached layer) COPY . . -# Try to get git commit if not provided and .git exists +# Try to get short git commit (7 chars) if not provided and .git exists RUN if [ "$GIT_COMMIT" = "unknown" ] && [ -d .git ]; then \ - GIT_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \ fi && \ echo "export GIT_COMMIT=${GIT_COMMIT}" >> /etc/profile.d/git-version.sh diff --git a/README.md b/README.md index f182c8c..d7b7cdb 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ curl https://template-001.startanaicompany.com/health # "postgres": "connected", # "redis": "connected", # "timestamp": "2026-02-14T10:30:00.000Z", -# "git_commit": "eb6b6e0...", +# "git_commit": "0e993d9", # "version": "1.0.0" # } @@ -416,7 +416,7 @@ Health check endpoint that verifies connections to PostgreSQL and Redis, and ret "postgres": "connected", "redis": "connected", "timestamp": "2026-02-14T10:30:00.000Z", - "git_commit": "eb6b6e0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q", + "git_commit": "0e993d9", "version": "1.0.0" } ``` @@ -426,16 +426,16 @@ Health check endpoint that verifies connections to PostgreSQL and Redis, and ret { "status": "unhealthy", "error": "Connection error message", - "git_commit": "eb6b6e0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q", + "git_commit": "0e993d9", "version": "1.0.0" } ``` **Version Tracking:** -- `git_commit`: The Git commit SHA of the deployed code (auto-detected during build) +- `git_commit`: Short Git commit SHA (7 characters) of the deployed code, auto-detected during build using `git rev-parse --short HEAD` - `version`: Application version (defaults to 1.0.0, can be set via APP_VERSION env var) -This allows AI agents and monitoring tools to verify which version is currently running. +This allows AI agents and monitoring tools to verify which version is currently running. The short commit ID is industry standard for deployment tracking, providing a balance between uniqueness and readability. ---