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:
Yaojia Wang
2025-11-04 23:25:22 +01:00
parent ba880104c7
commit d11df78d1f
3 changed files with 128 additions and 36 deletions

View File

@@ -1,18 +1,11 @@
# .dockerignore for ColaFlow API
# Optimizes Docker build context by excluding unnecessary files
# Binaries
# ================================================================================================
# Build Artifacts
# ================================================================================================
**/bin/
**/obj/
# Visual Studio / Rider
.vs/
.idea/
*.user
*.suo
*.userosscache
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
@@ -24,20 +17,68 @@ bld/
[Oo]bj/
[Ll]og/
# Test results
# ================================================================================================
# IDE and Editor Files
# ================================================================================================
.vs/
.vscode/
.idea/
*.user
*.suo
*.userosscache
*.sln.docstates
*.swp
*~
# ================================================================================================
# Test Results
# ================================================================================================
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.trx
*.coverage
*.coveragexml
TestResults/
# ================================================================================================
# NuGet
# ================================================================================================
*.nupkg
*.snupkg
packages/
.nuget/
# Others
# ================================================================================================
# Git
# ================================================================================================
.git/
.gitignore
.gitattributes
# ================================================================================================
# Docker
# ================================================================================================
Dockerfile
.dockerignore
docker-compose*.yml
# ================================================================================================
# Documentation and Others
# ================================================================================================
*.md
*.log
*.bak
*.tmp
.DS_Store
Thumbs.db
.editorconfig
# ================================================================================================
# Environment and Secrets (should never be in Docker context)
# ================================================================================================
.env
.env.local
appsettings.Development.json
appsettings.*.json
*.pfx
*.pem