Skip to content

The repository is well-structured with comprehensive templates covering frameworks (Next.js, Django, Laravel), languages (Node.js, Python, Go), security patterns, and infrastructure tools. The focus on security-first design with non-root execution, version pinning, and multi-stage builds makes it particularly valuable for production deployments.

License

Notifications You must be signed in to change notification settings

ronald2wing/Dockerfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

Dockerfile Templates

Production-Ready Dockerfile Templates for Modern Applications

Template Count License Contributions Welcome

Website β€’ GitHub β€’ Issues β€’ Contribute

πŸ“‹ Table of Contents

πŸš€ Quick Start

Get Started in 30 Seconds

# 1. Select a template
cp frameworks/nextjs.Dockerfile Dockerfile

# 2. Build your container image
docker build -t my-app .

# 3. Launch your application
docker run -p 3000:3000 my-app

Combine Templates for Advanced Applications

# Combine Next.js with PostgreSQL for a complete full-stack application
cat frameworks/nextjs.Dockerfile tools/postgresql.Dockerfile > Dockerfile
docker build -t fullstack-app .
docker run -p 3000:3000 -p 5432:5432 fullstack-app

πŸ“Š Template Overview

Category Templates Purpose Best For
πŸ—οΈ Frameworks 29 Complete production-ready templates Web apps, APIs, full-stack applications
πŸ’» Languages 19 Language-specific runtime configurations Custom applications, microservices
πŸ›‘οΈ Patterns 16 Reusable security & optimization patterns Security hardening, performance tuning
πŸ”§ Tools 23 Database, server & utility configurations Infrastructure, databases, monitoring

🎯 Key Benefits

πŸ”’ Security by Design

  • Non-root execution in all framework templates
  • Version-pinned base images (no latest tags)
  • OWASP-compliant security configurations
  • Regular security updates and vulnerability scanning

🏭 Production Ready

  • Multi-stage builds for minimal image sizes
  • Health checks for container orchestration
  • Resource limits and proper signal handling
  • Logging best practices implemented

πŸ› οΈ Developer Experience

  • Clear documentation with practical examples
  • Modular design for easy customization
  • Consistent patterns across all templates
  • Quick start guides for rapid onboarding

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

Complete, production-hardened templates for specific frameworks:

Framework Description Use Case
react.Dockerfile React with production optimizations Single-page applications
vue.Dockerfile Vue.js with build tooling Progressive web apps
nextjs.Dockerfile Next.js with SSR support Full-stack React applications
django.Dockerfile Django with Gunicorn Python web applications
flask.Dockerfile Flask with production WSGI Python microservices
spring-boot.Dockerfile Spring Boot with JVM optimizations Java enterprise applications
laravel.Dockerfile Laravel with PHP-FPM PHP web applications
angular.Dockerfile Angular with build optimization Enterprise web applications
express.Dockerfile Express.js with production settings Node.js APIs
svelte.Dockerfile Svelte with build pipeline Reactive web applications
sveltekit.Dockerfile SvelteKit with SSR support Full-stack Svelte applications
fastapi.Dockerfile FastAPI with Uvicorn High-performance Python APIs
ruby-on-rails.Dockerfile Ruby on Rails with Puma Ruby web applications
dotnet.Dockerfile .NET Core with runtime optimization C# applications
astro.Dockerfile Astro with static site generation Content-focused websites
nuxt.Dockerfile Nuxt.js with Vue.js SSR Vue.js full-stack applications
gatsby.Dockerfile Gatsby static site generator Static websites & blogs
remix.Dockerfile Remix full-stack framework Modern web applications
nestjs.Dockerfile NestJS TypeScript framework Enterprise Node.js applications
fastify.Dockerfile Fastify high-performance web framework High-throughput APIs
ember.Dockerfile Ember.js with production build Ambitious web applications
phoenix.Dockerfile Phoenix (Elixir) framework Real-time applications
play-framework.Dockerfile Play Framework (Scala) Scala web applications
gin.Dockerfile Gin (Go) web framework Go microservices
fiber.Dockerfile Fiber (Go) high-performance framework High-performance Go apps
koa.Dockerfile Koa (Node.js) middleware framework Modern Node.js applications
solidjs.Dockerfile SolidJS reactive framework Performance-critical apps
qwik.Dockerfile Qwik resumable framework Instant-loading applications
adonisjs.Dockerfile AdonisJS Node.js framework Full-featured Node.js apps

πŸ’» Language Templates (languages/)

Language-specific patterns designed for modular combination:

Language Description Best Combined With
node.Dockerfile Node.js runtime and tooling Any pattern template
python.Dockerfile Python with package management patterns/security-hardened.Dockerfile
go.Dockerfile Go compilation and runtime patterns/alpine.Dockerfile
java.Dockerfile Java/JVM environment patterns/multi-stage.Dockerfile
ruby.Dockerfile Ruby with gem management patterns/development.Dockerfile
php.Dockerfile PHP with extensions frameworks/laravel.Dockerfile
rust.Dockerfile Rust compilation patterns/distroless.Dockerfile
typescript.Dockerfile TypeScript compilation languages/node.Dockerfile
csharp.Dockerfile C#/.NET development patterns/docker-compose.Dockerfile
kotlin.Dockerfile Kotlin JVM applications patterns/microservices.Dockerfile
swift.Dockerfile Swift server-side applications patterns/security-hardened.Dockerfile
elixir.Dockerfile Elixir runtime and tooling frameworks/phoenix.Dockerfile
scala.Dockerfile Scala with sbt build tool patterns/ci-cd.Dockerfile
haskell.Dockerfile Haskell with GHC compiler patterns/multi-stage.Dockerfile
deno.Dockerfile Deno JavaScript/TypeScript runtime patterns/edge-computing.Dockerfile
bun.Dockerfile Bun JavaScript runtime patterns/hot-reload.Dockerfile
dart.Dockerfile Dart for Flutter and server apps patterns/serverless.Dockerfile
julia.Dockerfile Julia for scientific computing patterns/gpu-accelerated.Dockerfile
r.Dockerfile R for statistical computing patterns/monitoring.Dockerfile

πŸ›‘οΈ Pattern Templates (patterns/)

Reusable cross-cutting concerns for any application:

Pattern Description Use Case
multi-stage.Dockerfile Multi-stage build patterns Production image optimization
security-hardened.Dockerfile Security hardening configurations Compliance, sensitive data
alpine.Dockerfile Alpine Linux optimizations Minimal image sizes
docker-compose.Dockerfile Docker Compose integration Local development, testing
development.Dockerfile Development environment setup Developer onboarding
hot-reload.Dockerfile Hot reload for development Rapid iteration
ci-cd.Dockerfile CI/CD pipeline integration Automated deployments
monitoring.Dockerfile Application monitoring Production observability
microservices.Dockerfile Microservices architecture Distributed systems
serverless.Dockerfile Serverless application optimizations Cloud functions
edge-computing.Dockerfile Edge computing optimizations Low-latency applications
gpu-accelerated.Dockerfile GPU acceleration support ML/AI workloads
zero-downtime.Dockerfile Zero-downtime deployment High-availability systems
blue-green.Dockerfile Blue-green deployment strategy Risk-free deployments
distroless.Dockerfile Distroless minimal containers Security-critical applications
wasm.Dockerfile WebAssembly container patterns Cross-platform binaries

πŸ”§ Tool Templates (tools/)

Database and infrastructure tools for production environments:

Tool Description Common Use
postgresql.Dockerfile PostgreSQL database Primary data store
nginx.Dockerfile Nginx web server Reverse proxy, load balancing
mysql.Dockerfile MySQL database Relational database
mongodb.Dockerfile MongoDB database NoSQL document store
redis.Dockerfile Redis cache Caching, session storage
traefik.Dockerfile Traefik reverse proxy Dynamic routing
certbot.Dockerfile Certbot for SSL certificates TLS/SSL management
elasticsearch.Dockerfile Elasticsearch search engine Search, analytics
sqlite.Dockerfile SQLite embedded database Local development, testing
haproxy.Dockerfile HAProxy load balancer High-availability setups
kafka.Dockerfile Apache Kafka message broker Event streaming
rabbitmq.Dockerfile RabbitMQ message broker Message queuing
memcached.Dockerfile Memcached distributed caching Performance optimization
cassandra.Dockerfile Apache Cassandra NoSQL database Scalable NoSQL storage
mariadb.Dockerfile MariaDB relational database MySQL alternative
grafana.Dockerfile Grafana monitoring and visualization Metrics dashboards
prometheus.Dockerfile Prometheus monitoring system Metrics collection
varnish.Dockerfile Varnish HTTP accelerator cache Content delivery optimization
minio.Dockerfile MinIO S3-compatible object storage Object storage
influxdb.Dockerfile InfluxDB time series database Time-series data
timescaledb.Dockerfile TimescaleDB time-series PostgreSQL Time-series on PostgreSQL
clickhouse.Dockerfile ClickHouse column-oriented database Analytics, OLAP
neo4j.Dockerfile Neo4j graph database Graph data, relationships

πŸš€ Getting Started Guide

Step 1: Choose Your Template

For a complete application:

# Web framework
cp frameworks/nextjs.Dockerfile Dockerfile

# API framework
cp frameworks/fastapi.Dockerfile Dockerfile

# Full-stack framework
cp frameworks/remix.Dockerfile Dockerfile

For a custom application:

# Language + patterns
cat languages/go.Dockerfile patterns/security-hardened.Dockerfile > Dockerfile

Step 2: Customize Your Template

# Edit your Dockerfile to match your project structure
# Most templates include configuration options like:

# Build arguments
ARG NODE_ENV=production
ARG PORT=3000

# Environment variables
ENV NODE_ENV=${NODE_ENV}
ENV PORT=${PORT}

Step 3: Build and Run

# Build with custom arguments
docker build --build-arg NODE_ENV=development -t my-app .

# Run with environment variables
docker run -p 3000:3000 -e NODE_ENV=development my-app

# Run in detached mode
docker run -d -p 3000:3000 --name my-app-container my-app

πŸ”§ Advanced Usage

Template Combination Patterns

Full-Stack Application (Next.js + PostgreSQL):

cat frameworks/nextjs.Dockerfile tools/postgresql.Dockerfile > Dockerfile
docker build -t fullstack-app .
docker run -p 3000:3000 -p 5432:5432 fullstack-app

Secure Microservice (Go + Alpine + Security Hardening):

cat languages/go.Dockerfile \
    patterns/alpine.Dockerfile \
    patterns/security-hardened.Dockerfile > Dockerfile
docker build -t secure-microservice .

Development Environment (Python + Hot Reload):

cat languages/python.Dockerfile patterns/hot-reload.Dockerfile > Dockerfile
docker build -t python-dev .
docker run -p 8000:8000 -v $(pwd):/app python-dev

Production API (FastAPI + Monitoring + Security):

cat frameworks/fastapi.Dockerfile \
    patterns/security-hardened.Dockerfile \
    patterns/monitoring.Dockerfile > Dockerfile
docker build -t production-api .

Multi-Stage Build Optimization

# Use multi-stage builds for minimal production images
cat frameworks/react.Dockerfile patterns/multi-stage.Dockerfile > Dockerfile

# Build specific targets
docker build --target development -t my-app-dev .
docker build --target production -t my-app-prod .

Environment-Specific Configurations

# Development build
docker build --build-arg NODE_ENV=development -t my-app-dev .

# Production build with optimizations
docker build --build-arg NODE_ENV=production --build-arg OPTIMIZE=true -t my-app-prod .

# Test build
docker build --build-arg NODE_ENV=test -t my-app-test .

πŸ›‘οΈ Security Best Practices

1. Always Use Specific Versions

# ❌ Never use latest
# FROM node:latest

# βœ… Always specify version
FROM node:20.11.0-alpine

2. Run as Non-Root User

# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
    adduser -S -u 1001 -G appgroup appuser

# Set permissions
RUN chown -R appuser:appgroup /app

# Switch to non-root user
USER appuser

3. Regular Security Scanning

# Scan built images for vulnerabilities
docker scan my-app

# Use Docker Scout for comprehensive analysis
docker scout quickview my-app

4. Minimal Base Images

# Use Alpine Linux for minimal size
cat languages/go.Dockerfile patterns/alpine.Dockerfile > Dockerfile

# Use Distroless for maximum security
cat languages/go.Dockerfile patterns/distroless.Dockerfile > Dockerfile

πŸ“ˆ Performance Optimization

1. Layer Caching Strategy

# Order instructions to maximize cache hits
# 1. Install dependencies (changes least)
# 2. Copy package files
# 3. Install application dependencies
# 4. Copy application code (changes most)

2. Multi-Stage Builds

# Build stage
FROM node:20 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Production stage
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
RUN npm ci --only=production
CMD ["node", "dist/index.js"]

3. Image Size Reduction

# Use .dockerignore to exclude unnecessary files
cat .dockerignore

# Clean package manager caches
RUN npm cache clean --force
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

🀝 Contributing

We welcome contributions! Whether you're fixing a bug, adding a new template, or improving documentation, your help is appreciated.

Quick Contribution Guide:

  1. Fork the repository
  2. Create a new branch: git checkout -b feat/your-feature
  3. Make your changes following TEMPLATE_STANDARDS.md
  4. Test your template: docker build --no-cache -t test .
  5. Commit your changes: git commit -m "feat: add your feature"
  6. Push to your fork: git push origin feat/your-feature
  7. Open a Pull Request

For detailed guidelines, see CONTRIBUTING.md.

πŸ“š Documentation

Document Purpose
CONTRIBUTING.md Complete contribution guidelines
TEMPLATE_STANDARDS.md Template creation standards
AGENTS.md AI agent handbook for maintenance

🌐 Ecosystem

Related Projects


Maintained by Dockerfile.io

About

The repository is well-structured with comprehensive templates covering frameworks (Next.js, Django, Laravel), languages (Node.js, Python, Go), security patterns, and infrastructure tools. The focus on security-first design with non-root execution, version pinning, and multi-stage builds makes it particularly valuable for production deployments.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published