ChatGPT Docker & DevOps Setup Guide Prompt
You are a senior DevOps engineer with expertise in containerisation, CI/CD pipelines, and cloud deployment.
Category
💻 Coding
Difficulty
Advanced
Models
3
Last Updated
2026-06-28
Works with
📄 Example output
⚠️ Common Mistakes
❓ FAQ
⚙️ Fill in your variables
📋 Prompt
You are a senior DevOps engineer with expertise in containerisation, CI/CD pipelines, and cloud deployment.
Application: [application type — web app/API/microservice/data pipeline]
Stack: [language/framework — Python/FastAPI/Node.js/React/etc]
Hosting: [hosting environment — AWS/GCP/Azure/Fly.io/Railway/VPS]
Requirements: [deployment requirements — zero-downtime/auto-scaling/HTTPS/multi-service]
Task: Create a complete Docker setup:
1. DOCKERFILE: Production-optimised multi-stage build
2. DOCKER-COMPOSE: Development + production configurations
3. .dockerignore: What to exclude
4. ENVIRONMENT VARIABLES: What to set + where + how to keep secrets safe
5. CI/CD PIPELINE: GitHub Actions workflow for build → test → deploy
6. HEALTH CHECKS: Container health monitoring setup
7. TROUBLESHOOTING GUIDE: Top 5 Docker issues for this stack + fixes
Application: [application type — web app/API/microservice/data pipeline]
Stack: [language/framework — Python/FastAPI/Node.js/React/etc]
Hosting: [hosting environment — AWS/GCP/Azure/Fly.io/Railway/VPS]
Requirements: [deployment requirements — zero-downtime/auto-scaling/HTTPS/multi-service]
Task: Create a complete Docker setup:
1. DOCKERFILE: Production-optimised multi-stage build
2. DOCKER-COMPOSE: Development + production configurations
3. .dockerignore: What to exclude
4. ENVIRONMENT VARIABLES: What to set + where + how to keep secrets safe
5. CI/CD PIPELINE: GitHub Actions workflow for build → test → deploy
6. HEALTH CHECKS: Container health monitoring setup
7. TROUBLESHOOTING GUIDE: Top 5 Docker issues for this stack + fixes
DOCKER SETUP: Python FastAPI app → Fly.io deployment
# Dockerfile (multi-stage, production-optimised)
```dockerfile
# Stage 1: Dependencies
FROM python:3.12-slim AS builder
WORKDIR /build
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Stage 2: Production image
FROM python:3.12-slim
WORKDIR /app
# Security: non-root user
RUN useradd --create-home appuser
USER appuser
# Copy installed packages from builder
COPY --from=builder /root/.local /home/appuser/.local
COPY . .
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
CMD python -c "import requests; requests.get('http://localhost:8000/health')"
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```
# docker-compose.yml (development)
```yaml
version: '3.9'
services:
api:
build: .
ports: ["8000:8000"]
volumes: [".:/app"] # hot-reload in dev
environment:
- DEBUG=true
- DATABASE_URL=${DATABASE_URL}
env_file: [.env]
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: appdb
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes: [postgres_data:/var/lib/postgresql/data]
volumes:
postgres_data:
```
# GitHub Actions CI/CD
```yaml
name: Deploy to Fly.io
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
```
# Dockerfile (multi-stage, production-optimised)
```dockerfile
# Stage 1: Dependencies
FROM python:3.12-slim AS builder
WORKDIR /build
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Stage 2: Production image
FROM python:3.12-slim
WORKDIR /app
# Security: non-root user
RUN useradd --create-home appuser
USER appuser
# Copy installed packages from builder
COPY --from=builder /root/.local /home/appuser/.local
COPY . .
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
CMD python -c "import requests; requests.get('http://localhost:8000/health')"
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```
# docker-compose.yml (development)
```yaml
version: '3.9'
services:
api:
build: .
ports: ["8000:8000"]
volumes: [".:/app"] # hot-reload in dev
environment:
- DEBUG=true
- DATABASE_URL=${DATABASE_URL}
env_file: [.env]
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: appdb
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes: [postgres_data:/var/lib/postgresql/data]
volumes:
postgres_data:
```
# GitHub Actions CI/CD
```yaml
name: Deploy to Fly.io
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
```
🏆
💡 Pro Tips
Best model for this prompt
DeepSeek
DeepSeek V3 / R1
Multi-stage builds are mandatory for production — development dependencies (pytest, black, mypy) should never be in your production image
Use specific version tags (python:3.12-slim, not python:latest) — 'latest' changes without warning and breaks your builds
Never put secrets in Dockerfiles or docker-compose.yml — use environment variables and a secrets manager
Run containers as non-root users — it's a security best practice that's easy to implement and required by some hosting platforms
COPY . . before installing dependencies — this invalidates cache every time you change any file
Not using .dockerignore — copies node_modules or .venv into the image, making it huge
Hard-coding DATABASE_URL or API keys in config files — use environment variables always
No health check — container orchestrators need health checks to know when to restart failed containers
- When should I use Docker vs. just deploying the app directly?Docker is valuable when: you have different environments (dev/staging/prod), the app has complex dependencies, you're running multiple services, or you want reproducible deployments. For a simple static site or serverless function, Docker adds complexity without benefit.
- What's the difference between docker-compose and Kubernetes?Docker Compose: runs multiple containers on one machine, great for development and small production deployments. Kubernetes: orchestrates containers across multiple machines, provides auto-scaling, self-healing, rolling updates — for production at scale. Most apps don't need Kubernetes; start with Compose or a PaaS (Fly.io, Railway).
- How do I handle database migrations with Docker?Add a migration step before the app starts: in your entrypoint script, run `python manage.py migrate` (Django) or `alembic upgrade head` (SQLAlchemy) before starting the server. In Kubernetes, use an init container for migrations.
- Which AI model is best for DevOps help?DeepSeek V3 is strong for specific technical configurations. Claude is better for explaining the reasoning behind DevOps decisions and writing comprehensive guides. For complex multi-service architectures, Claude's ability to reason about system design is valuable.