Examples
Real-world examples showing Dockerizer in action with different frameworks and configurations.
Quick Examples
Basic Generation
cd my-project
dockerizer
Preview First
dockerizer plan
# Review output
dockerizer
Force AI
export OPENAI_API_KEY="sk-..."
dockerizer --ai
CI/CD Pipeline
dockerizer --force --quiet
docker build -t app .
Next.js Application
Dockerizer automatically detects Next.js projects and generates optimized configurations with standalone output.
Command
cd my-nextjs-app
dockerizer
Detection Output
Scanning project...
Detected: Next.js (confidence: 95%)
- Node version: 20
- Package manager: npm
- TypeScript: yes
- Output mode: standalone
Generating files...
✓ Dockerfile
✓ docker-compose.yml
✓ .dockerignore
Done!
Generated Dockerfile
FROM node:20-alpine AS base
FROM base AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
CMD ["node", "server.js"]
FastAPI Application
FastAPI projects are detected with uvicorn as the ASGI server.
Command
cd my-fastapi-app
dockerizer
Detection Output
Scanning project...
Detected: FastAPI (confidence: 90%)
- Python version: 3.12
- Package manager: pip
- Main file: main.py
- ASGI server: uvicorn
Generating files...
✓ Dockerfile
✓ docker-compose.yml
✓ .dockerignore
Done!
Generated Dockerfile
FROM python:3.12-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
FROM python:3.12-slim AS runner
WORKDIR /app
RUN useradd --create-home --shell /bin/bash appuser
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY . .
RUN chown -R appuser:appuser /app
USER appuser
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
Gin (Go) Application
Go projects are compiled to static binaries for minimal final images.
Command
cd my-gin-app
dockerizer
Generated Dockerfile
FROM golang:1.22-alpine AS builder
WORKDIR /app
RUN apk add --no-cache git ca-certificates
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /app/server .
FROM alpine:latest
WORKDIR /app
RUN apk --no-cache add ca-certificates
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
COPY --from=builder /app/server /app/server
RUN chown -R appuser:appgroup /app
USER appuser
EXPOSE 8080
CMD ["/app/server"]
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
Django Application
Django projects include static file collection and Gunicorn WSGI server.
Command
cd my-django-app
dockerizer
Generated docker-compose.yml
version: '3.8'
services:
web:
build: .
ports:
- "8000:8000"
environment:
- DEBUG=0
- DATABASE_URL=postgres://postgres:postgres@db:5432/app
depends_on:
- db
restart: unless-stopped
db:
image: postgres:15-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=app
restart: unless-stopped
volumes:
postgres_data:
Advanced Examples
Custom Output Directory
# Generate files in a specific directory
dockerizer --output ./docker
# Results in:
# ./docker/Dockerfile
# ./docker/docker-compose.yml
# ./docker/.dockerignore
AI-Powered Generation
# When detection confidence is low or for unknown frameworks
export ANTHROPIC_API_KEY="sk-ant-..."
dockerizer --ai --ai-provider anthropic
# Or with OpenAI
export OPENAI_API_KEY="sk-..."
dockerizer --ai --ai-provider openai --ai-model gpt-4
CI/CD Integration
# GitHub Actions example
- name: Generate Dockerfile
run: |
curl -fsSL https://dockerizer.dev/install.sh | sh
dockerizer --force --quiet
- name: Build and Push
run: |
docker build -t myapp:${{ github.sha }} .
docker push myapp:${{ github.sha }}
Monorepo Setup
# Generate for specific service in monorepo
dockerizer ./services/api
dockerizer ./services/web
dockerizer ./services/worker
Need help? Check the CLI Reference for all available options or AI Configuration for setting up AI providers.