Skip to content
Back to skills

Docker Deploy

BSecurity

How to write Dockerfiles and one docker-compose.yml that starts every service with one command (Compose task, every target), and the deploy steps (Deploy task, mvp and production). Used by devops-engineer only.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentspythongosqlnodefastapidjangodockergitapidatabase

Works with

  • api
  • mcp

Security analysis

B75/100
  • criticalExfiltrates credentials via HTTP — exact pattern from Snyk ToxicSkills study

Pro shows the line behind each finding and how to fix it

Scanned December 3, 2026

npx -y skills add sayeed1999/aidlc-agent-crew --skill docker-deploy --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker Deploy?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker Deploy
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/sayeed1999-docker-deploy/badge)](https://www.skillsdirectory.com/skills/sayeed1999-docker-deploy)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: docker-deploy
description: How to write Dockerfiles and one docker-compose.yml that starts every service with one command (Compose task, every target), and the deploy steps (Deploy task, mvp and production). Used by devops-engineer only.
---

# docker-deploy

Two tasks use this skill:
- `Compose` (every target, right after the foundation tasks): Dockerfiles, `.dockerignore`, `docker-compose.yml`, root `.env.example`. Steps 1 to 6.
- `Deploy` (`mvp` and `production`, last): `Caddyfile` when needed, `docs/deploy.md`, full verification. Steps 1, 5, 7, and 6.
- `Update Compose`: steps 1 to 6 for the changed services only.

## Steps
### 1. Read
- `docs/architecture.md`: section 3 roots, section 4 commands, section 11 services, the hosting answer.
- The `.env.example` of each root.

### 2. Write the api Dockerfile
- Multi-stage. Run as a non-root user. Expose the port in section 11.
- `fastapi` and `django`: base `python:3.12-slim`. Copy `uv` from `ghcr.io/astral-sh/uv:<pinned>`. Copy `pyproject.toml` and `uv.lock` first, then `uv sync --frozen --no-dev`, then the code.
- `django`: serve with `gunicorn`. Run `collectstatic` at build time.
- `go`: build with `golang:<pinned>-alpine`, `CGO_ENABLED=0`. Build one binary with the `serve`, `migrate`, and `seed` subcommands. Copy `migrations/`. Run on `alpine:<pinned>` (it has `wget` for the healthcheck).
- Several services sharing `internal/`: build context is the repo root, `dockerfile: <service>/Dockerfile`. Copy the root manifest and lock file, `internal/`, `external-services/`, MCP folders in use, and the service folder. Python: `uv sync --frozen --no-dev --package <service>`.
- Python external services and MCP folders are uv workspace members. Copy them before `uv sync`.

### 3. Write the web Dockerfile
- Multi-stage: install, build, run. Base: current Node LTS, major version pinned, `-alpine`.
- `next.config.ts` must have `output: "standalone"`. If not, write a handoff to frontend-engineer.
- Run `node server.js` with `HOSTNAME=0.0.0.0`.
- `NEXT_PUBLIC_API_URL` is baked in at build time. Pass it as a build arg from compose.
- Run as a non-root user.

### 4. Write `.dockerignore` per root (one at the repo root when the build context is the repo root)
- `node_modules`, `.next`, `.venv`, `__pycache__`, `.env`, `.git`, `tests`, `*.db`

### 5. Write `docker-compose.yml` and the root `.env.example`
- One file starts every service in section 11.
- `db` (`mvp` and `production`): `postgres:18`, named volume, `pg_isready` healthcheck, no published port.
- Every service: `env_file: <service-root>/.env`, so engineers add variables to their root's `.env.example` and never edit compose. Compose `environment:` only for values that wire services together (for example `DATABASE_URL` host).
- `api`: build the backend root, healthcheck on `/health`.
  - With `db`: `depends_on` db with `condition: service_healthy`.
  - Prototype: named volume for the SQLite file. `DATABASE_URL` points into it.
  - Command: migrate, then seed, then serve, using the section 4 commands. Example (`fastapi`): `sh -c "alembic upgrade head && python -m seed && uvicorn main:app --host 0.0.0.0 --port 8000"`. `go`: `sh -c "./api migrate && ./api seed && ./api serve"`.
  - Several services: only the service named in section 11 as the migration owner migrates and seeds. The others `depends_on` it healthy.
  - `SEED_MODE`: `demo` for prototype, `reference` for `mvp` and `production`.
- `web`: build the web root with the build arg, `depends_on` api healthy.
- `caddy` (Deploy task, own server only): ports 80 and 443, `Caddyfile` sends the domain to `web` and `/api/*` to `api`, a volume for certificates.
- `restart: unless-stopped` on every service.
- Root `.env.example`: every variable compose needs, placeholder values like `change-me`.

### 6. Verify
- `docker compose config` passes.
- `docker compose up --build -d`. Wait until every service is healthy.
- `curl` the api `/health` and the web root. Both return 200.
- Storage level 4: one list endpoint returns seeded rows.
- `docker compose down`.
- Docker not available: raise an `env` blocker (`skills/flow`) with these commands. Mark the task `blocked`, not `built`.

### 7. Write `docs/deploy.md` (Deploy task)
- Sections: Run locally, Deploy, HTTPS, Backup and restore, Update, Roll back, Logs.
- Each section is a short list of copy-paste commands. No Docker tutorial.
- Backup: `docker compose exec db pg_dump -U <user> <db> > backup.sql`. Restore: the matching `psql` command.
- Deploy: follow the hosting answer in `docs/architecture.md`.
- Target `production`: add a daily backup cron line and a restore test.

## Healthcheck notes
- `python:slim` has no `curl`. Use `python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"`.
- Alpine has `wget`. Use `wget -qO- http://localhost:<port>/<path>`.

## Later changes
- After the Compose task, the service owner edits its own `Dockerfile` and `.env.example`.
- A new service, port, volume, or wiring change in `docker-compose.yml`: the owner writes a handoff to devops-engineer (`Update Compose`).

## MUST
- Use only the ports, env vars, and commands in `docs/architecture.md`.
- Pin every image tag to a version.
- Run every container as non-root.

## NEVER
- Deploy, log in to a cloud account, or spend money. Write the steps. The user runs them.
- Put secrets in a Dockerfile, in compose, or in an image.
- Publish the db port to the internet. Local dev may bind it to `127.0.0.1` only.
- Use the `latest` tag.
- Set `SEED_MODE=demo` in a production example.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.