Production-Ready Dockerfile Templates for Modern Applications
Website β’ GitHub β’ Issues β’ Contribute
- π Quick Start
- π Template Overview
- ποΈ Framework Templates
- π» Language Templates
- π‘οΈ Pattern Templates
- π§ Tool Templates
- π§ Advanced Usage
- π‘οΈ Security Best Practices
- π Performance Optimization
- π€ Contributing
- π Documentation
- π Ecosystem
# 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 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| 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 |
- Non-root execution in all framework templates
- Version-pinned base images (no
latesttags) - OWASP-compliant security configurations
- Regular security updates and vulnerability scanning
- Multi-stage builds for minimal 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
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-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 |
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 |
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 |
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 DockerfileFor a custom application:
# Language + patterns
cat languages/go.Dockerfile patterns/security-hardened.Dockerfile > Dockerfile# 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}# 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-appFull-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-appSecure 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-devProduction API (FastAPI + Monitoring + Security):
cat frameworks/fastapi.Dockerfile \
patterns/security-hardened.Dockerfile \
patterns/monitoring.Dockerfile > Dockerfile
docker build -t production-api .# 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 .# 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 .# β Never use latest
# FROM node:latest
# β
Always specify version
FROM node:20.11.0-alpine# 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# Scan built images for vulnerabilities
docker scan my-app
# Use Docker Scout for comprehensive analysis
docker scout quickview my-app# 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# 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)# 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"]# 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/*We welcome contributions! Whether you're fixing a bug, adding a new template, or improving documentation, your help is appreciated.
Quick Contribution Guide:
- Fork the repository
- Create a new branch:
git checkout -b feat/your-feature - Make your changes following TEMPLATE_STANDARDS.md
- Test your template:
docker build --no-cache -t test . - Commit your changes:
git commit -m "feat: add your feature" - Push to your fork:
git push origin feat/your-feature - Open a Pull Request
For detailed guidelines, see CONTRIBUTING.md.
| Document | Purpose |
|---|---|
| CONTRIBUTING.md | Complete 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 - Explore .dockerignore templates
- gitignores.com - Discover .gitignore templates
Maintained by Dockerfile.io