Enterprise-Grade Dockerfile Templates for Modern Applications
A curated collection of security-optimized, production-hardened Dockerfile templates adhering to industry security standards.
# Download a template directly
curl -o Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/frameworks/react.Dockerfile
# Or copy from this repository
cp frameworks/react.Dockerfile Dockerfile
# Build and run your application
docker build -t my-app .
docker run -p 3000:3000 my-app# Create a custom Dockerfile by combining templates
cat languages/nodejs.Dockerfile \
patterns/multi-stage.Dockerfile \
patterns/security-hardened.Dockerfile > Dockerfile| Category | Templates | Description | Ideal Use Case |
|---|---|---|---|
| ποΈ Framework Templates | 13 templates | Complete, production-hardened templates for specific frameworks | Production deployments, rapid prototyping |
| π» Language Templates | 8 templates | Language-specific patterns designed for modular combination | Custom applications, development environments |
| π‘οΈ Pattern Templates | 6 templates | Reusable patterns (security, multi-stage, optimization) | Security hardening, performance optimization |
| π§ Tool Templates | 8 templates | Database, web server, and utility configurations | Infrastructure deployment, tool containerization |
- Non-root execution by default in all framework templates
- Specific version pinning (no
latesttags) - Security-hardened configurations following OWASP guidelines
- Regular security updates and vulnerability scanning
- Multi-stage builds for optimized image sizes
- Health checks for container orchestration
- Resource limits and proper signal handling
- Logging best practices implemented
- Clear documentation with practical examples
- Modular design for easy customization
- Consistent patterns across all templates
- Quick start guides for rapid onboarding
# Use React template for production
cp frameworks/react.Dockerfile Dockerfile
docker build -t react-app .
docker run -p 3000:3000 react-app# Node.js with security hardening and multi-stage builds
cat languages/nodejs.Dockerfile \
patterns/security-hardened.Dockerfile \
patterns/multi-stage.Dockerfile > Dockerfile# Deploy PostgreSQL with production configuration
cp tools/postgresql.Dockerfile Dockerfile
docker build -t postgres-db .
docker run -p 5432:5432 postgres-dbComplete, self-contained templates for specific frameworks:
react.Dockerfile- React with production optimizationsvue.Dockerfile- Vue.js with build toolingnextjs.Dockerfile- Next.js with SSR supportdjango.Dockerfile- Django with Gunicornflask.Dockerfile- Flask with production WSGIspring-boot.Dockerfile- Spring Boot with JVM optimizationslaravel.Dockerfile- Laravel with PHP-FPMangular.Dockerfile- Angular with build optimizationexpress.Dockerfile- Express.js with production settingssvelte.Dockerfile- Svelte with build pipelinefastapi.Dockerfile- FastAPI with Uvicornruby-on-rails.Dockerfile- Ruby on Rails with Pumadotnet-core.Dockerfile- .NET Core with runtime optimization
Language-specific patterns for combination:
nodejs.Dockerfile- Node.js runtime and toolingpython.Dockerfile- Python with package managementgo.Dockerfile- Go compilation and runtimejava.Dockerfile- Java/JVM environmentruby.Dockerfile- Ruby with gem managementphp.Dockerfile- PHP with extensionsrust.Dockerfile- Rust compilationtypescript.Dockerfile- TypeScript compilation
Reusable cross-cutting concerns:
multi-stage.Dockerfile- Multi-stage build patternssecurity-hardened.Dockerfile- Security hardening configurationsalpine.Dockerfile- Alpine Linux optimizationsdocker-compose.Dockerfile- Docker Compose integrationdevelopment.Dockerfile- Development environment setuphot-reload.Dockerfile- Hot reload for development
Database and infrastructure tools:
postgresql.Dockerfile- PostgreSQL databasenginx.Dockerfile- Nginx web servermysql.Dockerfile- MySQL databasemongodb.Dockerfile- MongoDB databaseredis.Dockerfile- Redis cachetraefik.Dockerfile- Traefik reverse proxycertbot.Dockerfile- Certbot for SSL certificateselasticsearch.Dockerfile- Elasticsearch search engine
- Always use specific versions - Never rely on
latesttags - Run as non-root user - All framework templates enforce this
- Regular vulnerability scanning - Use
docker scanregularly - Minimal base images - Start from minimal distributions like Alpine
- Multi-stage builds - Separate build and runtime stages
- Layer caching - Order instructions to maximize cache hits
- Image size optimization - Remove build dependencies in final stage
- Resource limits - Set memory and CPU constraints
- Regular updates - Update base images quarterly
- Version pinning - Pin all package versions
- Documentation - Keep usage examples current
- Testing - Test templates with each Docker version update
We welcome contributions! Please see our CONTRIBUTING.md for:
- Template creation guidelines
- Contribution workflow
- Code of conduct
- Testing requirements
- CONTRIBUTING.md - Contribution guidelines
- TEMPLATE_STANDARDS.md - Template creation standards
- AGENTS.md - AI agent handbook for maintenance
- .dockerignore Templates - 87+ .dockerignore templates
- .gitignore Templates - 129+ .gitignore templates
- Dockerfile.io - Browse and download templates
- dockerignore.com - .dockerignore template generator
- gitignores.com - .gitignore template generator
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check TEMPLATE_STANDARDS.md for template standards
- Issues: Use GitHub Issues
- Questions: Open an issue with the "question" label
Thank you for using Dockerfile Templates! π³
Maintained by Dockerfile.io