Hey,

Issue #013. Let's get into it.

---

⚙️ **AI TOOL OF THE WEEK: Docker + Claude = Instant Dockerfile Debugging**

Before we get into Docker itself — a practical AI move. When your container fails to build or exits unexpectedly, paste the error and your Dockerfile into Claude with this prompt: *"This Docker build is failing. Here's the Dockerfile and the error output. What's wrong and how do I fix it?"* Claude is remarkably good at spotting Dockerfile issues — wrong base image, layer ordering problems, missing COPY paths. Faster than Stack Overflow, more specific than the docs.

---

🚀 **DEVOPS: Docker in 15 Minutes**

Docker has a reputation for being complicated. It's not. Most of that reputation comes from people learning the wrong 80% first. Here's the 20% that covers everything you'll actually need.

**Why Docker:**
The problem it solves: *it works on my machine.* Docker packages your app and everything it needs — runtime, dependencies, config — into a single image. Same image runs in local, CI, staging, and production. The environment is no longer a variable.

**The Dockerfile — 5 instructions cover most of what you need:**

```dockerfile
FROM python:3.12-slim        # base image — always pin a version
WORKDIR /app                 # set working directory first
COPY requirements.txt .      # copy dependency file
RUN pip install -r requirements.txt  # install dependencies
COPY . .                     # copy source code
CMD ["python", "main.py"]    # default run command
```

Never use `latest` in production. Pin a version so your builds are reproducible.

**Multi-stage builds — the optimization most people skip:**

```dockerfile
# Stage 1: build
FROM node:20 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# Stage 2: runtime
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
CMD ["node", "dist/index.js"]
```

Result: production image that's often 10x smaller. Smaller = faster pulls, smaller attack surface, lower storage costs. One Dockerfile, two `FROM` statements.

**Docker Compose — for local multi-service development:**

```yaml
services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgres://user:pass@postgres:5432/mydb
    depends_on:
      - postgres

  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: mydb
    volumes:
      - pgdata:/var/lib/postgresql/data

volumes:
  pgdata:
```

`docker compose up` — your app and database, running together, zero manual setup. Services reference each other by name (`postgres`, not `localhost`).

**The registry workflow:**
```bash
docker build -t myapp:1.0.0 .
docker tag myapp:1.0.0 ghcr.io/yourname/myapp:1.0.0
docker push ghcr.io/yourname/myapp:1.0.0
# on the server:
docker pull ghcr.io/yourname/myapp:1.0.0
docker run -p 3000:3000 ghcr.io/yourname/myapp:1.0.0
```

In a GitHub Actions pipeline: four lines. Free private images on GitHub Container Registry.

**Three failures you will hit:**

*Container exits immediately:* `CMD` is wrong or your entrypoint script has an error. Debug with `docker run -it myapp:1.0.0 bash` to get an interactive shell.

*Can't connect to the database:* You're connecting to `localhost` inside the container. In Compose, use the service name (`postgres`). Outside Compose on Mac: `host.docker.internal`.

*Image is enormous:* You're copying `node_modules` or `.git`. Create a `.dockerignore` file (same syntax as `.gitignore`). Add `node_modules`, `.git`, `.env`. Rebuild.

Full Dockerfile, Compose file, and multi-stage example on GitHub.

---

⛓️ **CRYPTO/WEB3 SIGNAL**

Docker is now standard in Web3 infrastructure. Every validator node, every indexer, every RPC endpoint runs in a container. If you can Docker, you can run your own nodes — which means you can participate in networks that pay operators. Ethereum validators, Graph Protocol indexers, and Chainlink nodes all have Docker-based setup guides. Worth knowing.

---

🔗 **3 LINKS WORTH YOUR TIME**

[EP013 Dockerfile examples on GitHub](https://github.com/mttaylor/deployordiecontent) — Dockerfile, Compose, multi-stage, .dockerignore

[Docker Hub official images](https://hub.docker.com/search?q=&type=image&image_filter=official) — always start here, not random community images

[GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) — free private image hosting if you're already on GitHub

---

That's Issue #013.

Forward it to one engineer. Still the only growth strategy running.

— Deploy or Die

Keep reading