Add Git commit ID tracking to health endpoint
Features:
- Health endpoint now returns git_commit SHA and version
- Auto-detects git commit during Docker build
- Falls back to 'unknown' if git info unavailable
- Allows AI agents to verify deployed version
Changes:
1. server.js: Add git_commit and version to /health response
2. Dockerfile: Add git installation and commit detection
3. Dockerfile: Accept GIT_COMMIT and APP_VERSION build args
4. docker-compose.yml: Pass build args and env vars for versioning
5. README.md: Document version tracking in health endpoint
Example response:
{
"status": "healthy",
"postgres": "connected",
"redis": "connected",
"timestamp": "2026-02-14T10:30:00.000Z",
"git_commit": "eb6b6e0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q",
"version": "1.0.0"
}
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
30
README.md
30
README.md
@@ -275,13 +275,25 @@ saac deployments
|
||||
### Step 7: Verify Deployment
|
||||
|
||||
```bash
|
||||
# Check health endpoint
|
||||
# Check health endpoint (includes git commit ID)
|
||||
curl https://template-001.startanaicompany.com/health
|
||||
|
||||
# You should see a response like:
|
||||
# {
|
||||
# "status": "healthy",
|
||||
# "postgres": "connected",
|
||||
# "redis": "connected",
|
||||
# "timestamp": "2026-02-14T10:30:00.000Z",
|
||||
# "git_commit": "eb6b6e0...",
|
||||
# "version": "1.0.0"
|
||||
# }
|
||||
|
||||
# View the website
|
||||
curl https://template-001.startanaicompany.com
|
||||
```
|
||||
|
||||
**Note:** The `git_commit` field in the health endpoint shows which version is deployed, making it easy for AI agents to track deployments.
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
@@ -395,7 +407,7 @@ Returns the main template website with information about the deployment.
|
||||
|
||||
### GET /health
|
||||
|
||||
Health check endpoint that verifies connections to PostgreSQL and Redis.
|
||||
Health check endpoint that verifies connections to PostgreSQL and Redis, and returns deployment version information.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
@@ -403,7 +415,9 @@ Health check endpoint that verifies connections to PostgreSQL and Redis.
|
||||
"status": "healthy",
|
||||
"postgres": "connected",
|
||||
"redis": "connected",
|
||||
"timestamp": "2026-02-14T10:30:00.000Z"
|
||||
"timestamp": "2026-02-14T10:30:00.000Z",
|
||||
"git_commit": "eb6b6e0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -411,10 +425,18 @@ Health check endpoint that verifies connections to PostgreSQL and Redis.
|
||||
```json
|
||||
{
|
||||
"status": "unhealthy",
|
||||
"error": "Connection error message"
|
||||
"error": "Connection error message",
|
||||
"git_commit": "eb6b6e0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
**Version Tracking:**
|
||||
- `git_commit`: The Git commit SHA of the deployed code (auto-detected during build)
|
||||
- `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.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Reference in New Issue
Block a user