fix(backend): Fix Dockerfile and add health check endpoint for Docker
This commit fixes the backend Docker configuration to enable one-click backend startup for frontend developers. Changes: - Updated Dockerfile with correct paths for modular monolith architecture * Added all module projects (Identity, ProjectManagement, IssueManagement) * Optimized layer caching by copying .csproj files first * Used alpine runtime image for smaller size (~500MB reduction) * Added non-root user (appuser) for security * Simplified to single HTTP port (8080) for development - Enhanced .dockerignore to optimize build context * Excluded unnecessary files (docs, git, docker files) * Added environment and secret file exclusions - Added /health endpoint to Program.cs * Required for Docker HEALTHCHECK functionality * Enables docker-compose to verify backend is ready Testing: - Docker build succeeds in ~14 seconds (after first build) - Backend container starts and passes health check - Swagger UI accessible at http://localhost:5000/scalar/v1 - Health endpoint returns "Healthy" at http://localhost:5000/health This implements Phase 1 of DOCKER-DEVELOPMENT-ENVIRONMENT.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -156,6 +156,9 @@ builder.Services.AddScoped<ColaFlow.Modules.ProjectManagement.Application.Servic
|
||||
// Configure OpenAPI/Scalar
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
// Add Health Checks (required for Docker health check)
|
||||
builder.Services.AddHealthChecks();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline
|
||||
@@ -188,6 +191,9 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
// Map Health Check endpoint (required for Docker health check)
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
// Map SignalR Hubs (after UseAuthorization)
|
||||
app.MapHub<ProjectHub>("/hubs/project");
|
||||
app.MapHub<NotificationHub>("/hubs/notification");
|
||||
|
||||
Reference in New Issue
Block a user