feat: Improve docker-compose.yaml with production-ready best practices #567
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Enhanced the
docker-compose.yamlfile with Docker Compose best practices for improved reliability, security, and maintainability.Changes Made
1. Version Specification
version: '3.9'for better compatibility and explicit version control2. Build Configuration
NODE_VERSION: 20.18.1PNPM_VERSION: 10.11.1NGINX_VERSION: 1.27-alpine(prod only)imagetags for better image management (devops-daily:dev,devops-daily:prod)3. Networking
devops-daily-network)4. Health Checks
Dev service:
Prod service:
5. Resource Limits
Prevents resource exhaustion and runaway containers:
Dev service:
Prod service:
6. Logging Configuration
7. Container Labels
Added descriptive labels for better organization:
8. Security Improvements
/root/.local/share/pnpm/store→/app/.pnpm-store9. Documentation
.env.examplefile documenting all environment variables.envand customizeBenefits
✅ Reliability: Health checks ensure services are actually responding, not just running
✅ Resource Management: Prevents containers from consuming all system resources
✅ Log Management: Automatic log rotation prevents disk space issues
✅ Security: Non-root paths for development container
✅ Maintainability: Labels and explicit configuration make debugging easier
✅ Consistency: Build args ensure same versions as standalone Dockerfiles
✅ Network Isolation: Custom network provides better service communication
Testing
Compatibility
All changes are backward compatible. Existing workflows will continue to function.
Related
.github/workflows/docker-validate.ymlvalidation workflow