[PR #615] feat(nginx-flask-mysql): Add production-ready improvements #1199

Closed
opened 2026-03-07 21:30:43 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/docker/awesome-compose/pull/615

State: closed
Merged: No


Overview\n\nThis PR enhances the nginx-flask-mysql example with critical production improvements that make the application more robust, observable, and maintainable.\n\n## 🔧 Bug Fixes\n\n### Flask/Werkzeug Compatibility Issue\n- Problem: Container was continuously restarting due to \n- Solution: Pin Werkzeug to version 2.2.2 which is compatible with Flask 2.0.1\n- Impact: Application now starts successfully without crashes\n\n## 🏥 Healthchecks (HIGH Priority)\n\n### Backend Service\n- Added \ endpoint to Flask application\n- Installed \ in backend container for healthcheck support\n- Configured healthcheck with 30s interval, 10s timeout, 3 retries, 40s start period\n\n### Proxy Service \n- Added \ endpoint to nginx configuration\n- Configured healthcheck with 30s interval, 10s timeout, 3 retries, 10s start period\n\n### Database Service\n- Optimized healthcheck interval from 3s to 10s (less aggressive)\n- Maintained proper timeout and retry configuration\n\n### Service Dependencies\n- Proxy now waits for backend to be healthy before starting\n- Backend waits for database to be healthy before starting\n- Ensures proper startup order and prevents 502 errors\n\nBenefits:\n Docker Compose knows when services are actually ready \n Automatic detection of unhealthy containers \n Faster failure detection and recovery \n Better observability of service health\n\n## 📝 Logging Configuration (MEDIUM Priority)\n\n### All Services\n- Configured JSON file logging driver\n- Max 10MB per log file with 3 rotated files (30MB per service)\n- Added service labels for easier log filtering\n- Total maximum log storage: ~90MB for all services\n\nBenefits:\n Prevents unbounded log growth \n Protects against disk space exhaustion \n Maintains recent logs for troubleshooting \n Easier log management and filtering\n\n## 🔄 Restart Policy Optimization (MEDIUM Priority)\n\n### All Services\n- Changed restart policy from \ to \n\nBehavior Changes:\n\n| Scenario | Before () | After () |\n|----------|---------------------|----------------------------|\n| Container crashes | Restarts | Restarts |\n| Docker daemon restarts | Restarts | Restarts |\n| System reboot | Restarts | Restarts |\n| Manual \ | Restarts anyway | Stays stopped |\n| \ | Restarts anyway | Stays stopped |\n\nBenefits:\n Respects intentional stops \n Better for maintenance windows \n Cleaner development workflow \n Production best practice \n Same crash recovery behavior\n\n## 📊 Testing\n\nAll changes have been thoroughly tested:\n\n- All containers start successfully\n- All services show "healthy" status\n- Main application works correctly (<div> Hello Blog post #1
Hello Blog post #2
Hello Blog post #3
Hello Blog post #4
)\n- Health endpoints respond correctly\n- Log rotation verified on all services\n- Restart policy verified\n- Service startup order verified\n\n## 📝 Files Modified\n\n\n\n## 🎯 Impact\n\nThese improvements make the nginx-flask-mysql example:\n- More production-ready with proper healthchecks\n- More reliable with dependency ordering\n- More maintainable with log rotation\n- More user-friendly with better restart behavior\n- Bug-free with Flask/Werkzeug compatibility fix\n\n## 🔮 Future Improvements\n\nWhile these changes significantly improve the example, for true production deployment, consider:\n- Using Gunicorn instead of Flask development server\n- Removing backend port exposure (use only internal Docker networks)\n- Adding resource limits\n- Implementing HTTPS/TLS\n- Updating to latest stable base images\n- Adding proper secrets management\n\n## 📚 Related Issues\n\nThis PR addresses common pain points with Docker Compose examples:\n- Containers failing to start due to dependency issues\n- Missing healthchecks causing 502 errors\n- Unbounded log growth\n- Confusing restart behavior\n\n---\n\nType of Change:\n- [x] Bug fix (Flask/Werkzeug compatibility)\n- [x] New feature (healthchecks, logging configuration)\n- [x] Breaking change (restart policy behavior change)\n- [x] Documentation update (commit message explains changes)\n\nChecklist:\n- [x] Code follows project style\n- [x] Self-review completed\n- [x] Changes tested locally\n- [x] All containers start and run successfully\n- [x] Health endpoints respond correctly

**Original Pull Request:** https://github.com/docker/awesome-compose/pull/615 **State:** closed **Merged:** No --- ## Overview\n\nThis PR enhances the nginx-flask-mysql example with critical production improvements that make the application more robust, observable, and maintainable.\n\n## 🔧 Bug Fixes\n\n### Flask/Werkzeug Compatibility Issue\n- **Problem**: Container was continuously restarting due to \n- **Solution**: Pin Werkzeug to version 2.2.2 which is compatible with Flask 2.0.1\n- **Impact**: Application now starts successfully without crashes\n\n## 🏥 Healthchecks (HIGH Priority)\n\n### Backend Service\n- Added \ endpoint to Flask application\n- Installed \ in backend container for healthcheck support\n- Configured healthcheck with 30s interval, 10s timeout, 3 retries, 40s start period\n\n### Proxy Service \n- Added \ endpoint to nginx configuration\n- Configured healthcheck with 30s interval, 10s timeout, 3 retries, 10s start period\n\n### Database Service\n- Optimized healthcheck interval from 3s to 10s (less aggressive)\n- Maintained proper timeout and retry configuration\n\n### Service Dependencies\n- Proxy now waits for backend to be healthy before starting\n- Backend waits for database to be healthy before starting\n- Ensures proper startup order and prevents 502 errors\n\n**Benefits:**\n✅ Docker Compose knows when services are actually ready \n✅ Automatic detection of unhealthy containers \n✅ Faster failure detection and recovery \n✅ Better observability of service health\n\n## 📝 Logging Configuration (MEDIUM Priority)\n\n### All Services\n- Configured JSON file logging driver\n- Max 10MB per log file with 3 rotated files (30MB per service)\n- Added service labels for easier log filtering\n- Total maximum log storage: ~90MB for all services\n\n**Benefits:**\n✅ Prevents unbounded log growth \n✅ Protects against disk space exhaustion \n✅ Maintains recent logs for troubleshooting \n✅ Easier log management and filtering\n\n## 🔄 Restart Policy Optimization (MEDIUM Priority)\n\n### All Services\n- Changed restart policy from \ to \n\n**Behavior Changes:**\n\n| Scenario | Before (\) | After (\) |\n|----------|---------------------|----------------------------|\n| Container crashes | ✅ Restarts | ✅ Restarts |\n| Docker daemon restarts | ✅ Restarts | ✅ Restarts |\n| System reboot | ✅ Restarts | ✅ Restarts |\n| Manual \ | ❌ Restarts anyway | ✅ Stays stopped |\n| \ | ❌ Restarts anyway | ✅ Stays stopped |\n\n**Benefits:**\n✅ Respects intentional stops \n✅ Better for maintenance windows \n✅ Cleaner development workflow \n✅ Production best practice \n✅ Same crash recovery behavior\n\n## 📊 Testing\n\nAll changes have been thoroughly tested:\n\n- ✅ All containers start successfully\n- ✅ All services show "healthy" status\n- ✅ Main application works correctly (\<div> Hello Blog post #1</div><div> Hello Blog post #2</div><div> Hello Blog post #3</div><div> Hello Blog post #4</div>)\n- ✅ Health endpoints respond correctly\n- ✅ Log rotation verified on all services\n- ✅ Restart policy verified\n- ✅ Service startup order verified\n\n## 📝 Files Modified\n\n\\n\n## 🎯 Impact\n\nThese improvements make the nginx-flask-mysql example:\n- More production-ready with proper healthchecks\n- More reliable with dependency ordering\n- More maintainable with log rotation\n- More user-friendly with better restart behavior\n- Bug-free with Flask/Werkzeug compatibility fix\n\n## 🔮 Future Improvements\n\nWhile these changes significantly improve the example, for true production deployment, consider:\n- Using Gunicorn instead of Flask development server\n- Removing backend port exposure (use only internal Docker networks)\n- Adding resource limits\n- Implementing HTTPS/TLS\n- Updating to latest stable base images\n- Adding proper secrets management\n\n## 📚 Related Issues\n\nThis PR addresses common pain points with Docker Compose examples:\n- Containers failing to start due to dependency issues\n- Missing healthchecks causing 502 errors\n- Unbounded log growth\n- Confusing restart behavior\n\n---\n\n**Type of Change:**\n- [x] Bug fix (Flask/Werkzeug compatibility)\n- [x] New feature (healthchecks, logging configuration)\n- [x] Breaking change (restart policy behavior change)\n- [x] Documentation update (commit message explains changes)\n\n**Checklist:**\n- [x] Code follows project style\n- [x] Self-review completed\n- [x] Changes tested locally\n- [x] All containers start and run successfully\n- [x] Health endpoints respond correctly
GiteaMirror added the pull-request label 2026-03-07 21:30:43 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-compose#1199