Skip to content

ronald2wing/Dockerfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dockerfile.io Templates

Production-Ready Dockerfile Templates for Modern Applications

Template Count License Website

A comprehensive collection of security-hardened, production-ready Dockerfile templates following industry best practices.

πŸš€ Quick Start

Get Started in 30 Seconds

# 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
docker build -t my-app .
docker run -p 3000:3000 my-app

Combine Templates for Custom Solutions

# Create custom Dockerfile by combining templates
cat languages/nodejs.Dockerfile \
    patterns/multi-stage.Dockerfile \
    patterns/security-hardened.Dockerfile > Dockerfile

πŸ“Š Template Ecosystem

Category Templates Description Best For
πŸ—οΈ Framework Templates 1 template Complete, production-ready templates Beginners, production deployments
πŸ’» Language Templates 1 template Language-specific patterns Custom applications, modular setups
πŸ›‘οΈ Pattern Templates 4 templates Reusable patterns (security, multi-stage, etc.) All projects, security hardening

Total: 6 templates across 3 categories

🎯 Why Choose Dockerfile.io Templates?

πŸ”’ Security First

  • Non-root users by default in all framework templates
  • Specific base image versions (no latest tags)
  • Security-hardened configurations with proper permissions
  • Health checks for container orchestration and monitoring

🏭 Production Ready

  • Multi-stage builds for minimal image sizes
  • Optimized layer caching for faster CI/CD pipelines
  • Industry best practices from Docker and community experts
  • Tested configurations that work in real production environments

🧩 Modular & Flexible

  • Combine templates like building blocks
  • Framework templates for quick starts
  • Language templates for custom applications
  • Common patterns for cross-cutting concerns

πŸ“ Template Categories

πŸ—οΈ Framework Templates (frameworks/)

Complete, self-contained templates for specific frameworks

  • Location: frameworks/
  • Usage: Use standalone - includes everything needed
  • Current Templates: React
  • Best For: Beginners, quick starts, production deployments

Example:

cp frameworks/react.Dockerfile Dockerfile

πŸ’» Language Templates (languages/)

Language-specific patterns designed for combination

  • Location: languages/
  • Usage: Combine with pattern templates
  • Current Templates: Node.js
  • Best For: Custom applications, modular architecture

Example:

cat languages/nodejs.Dockerfile \
    patterns/security-hardened.Dockerfile > Dockerfile

🧩 Pattern Templates (patterns/)

Reusable patterns for all projects

  • Location: patterns/
  • Usage: Combine with language or framework templates
  • Current Templates: Multi-stage builds, Security hardening, Alpine Linux, Docker Compose
  • Best For: Security hardening, performance optimization, OS-specific needs, tool integrations

Available Templates:

  • multi-stage.Dockerfile - Optimized build patterns
  • security-hardened.Dockerfile - Production security configurations
  • alpine.Dockerfile - Alpine Linux optimizations
  • docker-compose.Dockerfile - Docker Compose integration

πŸš€ Getting Started Guide

Option 1: Framework Template (Recommended for Beginners)

# 1. Choose your framework template
cp frameworks/react.Dockerfile Dockerfile

# 2. Get matching .dockerignore (optional but recommended)
curl -o .dockerignore https://raw.githubusercontent.com/ronald2wing/.dockerignore/master/frameworks/react.dockerignore

# 3. Build your application
docker build -t my-app .

# 4. Run your container
docker run -p 3000:3000 my-app

Option 2: Custom Combination (Advanced Users)

# 1. Create custom Dockerfile by combining templates
cat languages/nodejs.Dockerfile \
    patterns/multi-stage.Dockerfile \
    patterns/security-hardened.Dockerfile > Dockerfile

# 2. Review and customize
# Edit Dockerfile to match your application needs

# 3. Build with custom arguments
docker build \
  --build-arg NODE_ENV=production \
  --build-arg BUILD_ID=$(git rev-parse --short HEAD) \
  -t my-app:$(git rev-parse --short HEAD) .

# 4. Run with environment variables
docker run -d \
  -p 3000:3000 \
  -e NODE_ENV=production \
  --name my-app-container \
  my-app:latest

Option 3: Direct Download

# Download any template directly from GitHub
curl -o Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/frameworks/react.Dockerfile

# Or use wget
wget -O Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/languages/nodejs.Dockerfile

πŸ“‹ Practical Examples

Example 1: Node.js Web Application

# Complete production setup for Node.js
cat languages/nodejs.Dockerfile \
    patterns/multi-stage.Dockerfile \
    patterns/security-hardened.Dockerfile > Dockerfile

# Build for production
docker build --target runtime -t my-node-app:prod .

# Run with resource limits
docker run -d \
  -p 3000:3000 \
  --memory="512m" \
  --cpus="1.0" \
  my-node-app:prod

Example 2: React Application with Alpine

# React with Alpine Linux optimizations
cat frameworks/react.Dockerfile \
    patterns/alpine.Dockerfile > Dockerfile

# Build and run
docker build -t my-react-app .
docker run -p 3000:3000 my-react-app

Example 3: Development Environment

# Development setup with hot reload
cat languages/nodejs.Dockerfile > Dockerfile
# Then edit Dockerfile to uncomment development configurations

# Build development image
docker build -t my-app:dev .

# Run with volume mounting for live reload
docker run -d \
  -p 3000:3000 \
  -v $(pwd):/app \
  -v /app/node_modules \
  my-app:dev

πŸ”§ Template Features

Security Features

  • βœ… Non-root user execution - Reduced attack surface
  • βœ… Specific version pinning - No latest tag vulnerabilities
  • βœ… Minimal base images - Reduced CVE exposure
  • βœ… Proper file permissions - Principle of least privilege
  • βœ… Health checks - Automatic container monitoring
  • βœ… Resource limits - Prevention of resource exhaustion attacks

Performance Optimizations

  • βœ… Multi-stage builds - Minimal final image sizes
  • βœ… Layer caching optimization - Faster build times
  • βœ… Alpine Linux support - Smaller image footprints
  • βœ… Build argument support - Flexible configuration
  • βœ… Environment variable management - Runtime customization

Developer Experience

  • βœ… Clear documentation - Inline comments and examples
  • βœ… Modular design - Combine as needed
  • βœ… Production and development targets - Separate configurations
  • βœ… Best practice examples - Learn as you use
  • βœ… Community standards - Follows Docker best practices

πŸ“š Documentation

Core Documentation

Template Standards

All templates follow strict standards documented in TEMPLATE_STANDARDS.md:

  1. Consistent header format with attribution
  2. Metadata section with usage notes and combination guidance
  3. Security-first approach in framework templates
  4. Clear section organization with visual separators
  5. Comprehensive documentation with practical examples

πŸ› οΈ Development Workflow

Complete Development Setup

# 1. Get Dockerfile template
curl -o Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/frameworks/react.Dockerfile

# 2. Get .dockerignore template (security and performance)
curl -o .dockerignore https://raw.githubusercontent.com/ronald2wing/.dockerignore/master/frameworks/react.dockerignore

# 3. Get .gitignore template (repository optimization)
curl -o .gitignore https://raw.githubusercontent.com/ronald2wing/.gitignores/master/frameworks/react.gitignore

# 4. Build and test
docker build -t my-app .
docker run --rm -p 3000:3000 my-app

# 5. Deploy to production
docker tag my-app my-registry/my-app:latest
docker push my-registry/my-app:latest

Testing Templates

# Quick test of any template
mkdir test-template && cd test-template
cp ../path/to/template.Dockerfile Dockerfile

# Create minimal test files
echo '{"name": "test", "version": "1.0.0"}' > package.json
echo 'console.log("Test successful")' > index.js

# Test build and run
docker build --no-cache -t template-test .
docker run --rm template-test

# Cleanup
docker rmi template-test
cd .. && rm -rf test-template

πŸ† Best Practices

Security Best Practices

  1. Always use specific versions of base images
  2. Run as non-root user in production
  3. Use multi-stage builds to exclude build tools
  4. Scan images regularly for vulnerabilities
  5. Set resource limits to prevent DoS attacks
  6. Use .dockerignore to exclude sensitive files

Performance Best Practices

  1. Order instructions carefully for optimal layer caching
  2. Use Alpine or slim variants for smaller images
  3. Clean package caches in the same RUN instruction
  4. Use build arguments for environment-specific optimizations
  5. Consider multi-architecture builds for broader deployment

Maintenance Best Practices

  1. Update base images quarterly for security patches
  2. Review templates annually for new best practices
  3. Test with new Docker versions for compatibility
  4. Document changes clearly for users and contributors
  5. Engage with community for feedback and improvements

🀝 Contributing

We welcome contributions! Whether you're adding new templates, improving existing ones, or fixing bugs, your help is appreciated.

See CONTRIBUTING.md for detailed guidelines.

Ways to Contribute

  1. Add new templates for popular technologies
  2. Improve existing templates with new best practices
  3. Fix bugs or security issues in current templates
  4. Improve documentation and examples
  5. Add test cases for template validation

Quick Contribution Start

# 1. Fork and clone the repository
git clone https://github.com/your-username/Dockerfile.git
cd Dockerfile

# 2. Create a new template following TEMPLATE_STANDARDS.md
# 3. Test your template thoroughly
# 4. Submit a pull request

πŸ”— Related Projects

Template Ecosystem

Websites

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Docker Community - For establishing and evolving best practices
  • Open Source Maintainers - Whose work inspires our templates
  • Contributors - Everyone who has helped improve this collection
  • Users - For trusting these templates in production environments

Maintained by Dockerfile.io Β· View All Templates

Last Updated: 2026-01-23 Β· Template Count: 6

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published