Skip to content

feat(backend): add GIT_SHA environment variable for version tracking … - #117

Merged
Johnny-Dang merged 1 commit into
mainfrom
Tuan
Jul 12, 2026
Merged

feat(backend): add GIT_SHA environment variable for version tracking …#117
Johnny-Dang merged 1 commit into
mainfrom
Tuan

Conversation

@Johnny-Dang

@Johnny-Dang Johnny-Dang commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

…and migration diagnostics

This update introduces the GIT_SHA environment variable to capture the commit SHA during the Docker image build process. This allows the application to log the specific commit that is running, aiding in debugging and tracking issues in production.

Changes include:

  • Added GIT_SHA to the environment variables in docker-compose and Dockerfiles.
  • Implemented logging of GIT_SHA and migration status in the application startup process.
  • Introduced AdminMigrationController for runtime migration management and status reporting.

This enhancement improves traceability and operational insights for database migrations.

Summary by CodeRabbit

  • New Features

    • Added admin-only tools to view migration status and history, and apply pending database migrations.
    • Containers now expose build commit information for diagnostics.
    • Added container health monitoring through a live health endpoint.
  • Bug Fixes

    • Improved detection and reporting of database migration mismatches.
    • Application startup now stops when automatic database migration fails, preventing an unhealthy service from running.
  • Chores

    • Improved container build configuration and runtime readiness checks.
    • Production deployments now provide a default build identifier when unavailable.

…and migration diagnostics

This update introduces the GIT_SHA environment variable to capture the commit SHA during the Docker image build process. This allows the application to log the specific commit that is running, aiding in debugging and tracking issues in production.

Changes include:
- Added GIT_SHA to the environment variables in docker-compose and Dockerfiles.
- Implemented logging of GIT_SHA and migration status in the application startup process.
- Introduced AdminMigrationController for runtime migration management and status reporting.

This enhancement improves traceability and operational insights for database migrations.
@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
menu-green-system Ready Ready Preview, Comment Jul 12, 2026 3:49am

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c2c5bc63-4a27-4a91-b65e-bd104a4ada69

📥 Commits

Reviewing files that changed from the base of the PR and between 14c5274 and 6a75239.

📒 Files selected for processing (6)
  • .github/workflows/backend-ci.yml
  • Dockerfile
  • backend/Dockerfile
  • backend/MenuGreen.API/Controllers/AdminMigrationController.cs
  • backend/MenuGreen.API/Program.cs
  • docker-compose.prod.yml

📝 Walkthrough

Walkthrough

Docker images now carry commit metadata and health checks. Application startup logs and validates migration state, while an admin-only controller exposes migration status, history, and application endpoints.

Changes

Migration and runtime operations

Layer / File(s) Summary
Container metadata and health checks
.github/workflows/backend-ci.yml, Dockerfile, backend/Dockerfile, docker-compose.prod.yml
Docker builds pass GIT_SHA, runtime images expose it through the environment, add curl-based health checks, and define runtime ports and entrypoints.
Startup migration diagnostics
backend/MenuGreen.API/Program.cs
Non-development startup logs migration and version information, detects migration drift, verifies applied migrations, and rethrows migration failures.
Admin migration management
backend/MenuGreen.API/Controllers/AdminMigrationController.cs
Admin-only endpoints return migration status and history, and apply pending migrations with before-and-after details and failure handling.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant AdminMigrationController
  participant ApplicationDbContext
  participant Database
  Admin->>AdminMigrationController: Request migration status or apply
  AdminMigrationController->>ApplicationDbContext: Read migration state
  ApplicationDbContext->>Database: Query history or apply migrations
  Database-->>ApplicationDbContext: Migration results
  ApplicationDbContext-->>AdminMigrationController: Updated migration state
  AdminMigrationController-->>Admin: Return diagnostics or apply result
Loading

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Tuan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Johnny-Dang
Johnny-Dang merged commit 2cd50c9 into main Jul 12, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant