Docker-First & Image-First Architecture Skill
This skill defines the official architectural guidelines, containerization blueprints, and publishing standards across all services. It enforces a Docker-First and Image-First doctrine to guarantee infrastructure portability from serverless/PaaS edge environments to cloud container platforms (AWS ECS/EKS) and sovereign self-hosting.
1. Overview & Objective
Every service—regardless of language or framework—must be fully containerized, reproducible, and ready for container registry publication (<registry-user>/<image-name>).
Portability Roadmap
- Phase 1 (Edge/PaaS): Edge/serverless frontends, containerized backends, managed/serverless PostgreSQL, container registry.
- Phase 2 (Cloud Native): Cloud Infrastructure as Code (Terraform, ECS Fargate / EKS, Load Balancers, CloudFront, Container Registry).
- Phase 3 (Sovereign Infrastructure): Self-Hosted Bare Metal / VPS (Docker Compose / Nomad / K3s, reverse proxy, automated backup sync).
2. Core Directives & Toolchain Standards
[!IMPORTANT]
OPTIMAL TOOLCHAIN MANDATE: Always employ the fastest, most deterministic tools:
- Node.js / TypeScript:
pnpm exclusively. Never use npm or legacy yarn.
- Python:
uv exclusively (ghcr.io/astral-sh/uv:latest). Never use plain pip or slow virtualenv setups.
- Go: Static compilation (
CGO_ENABLED=0, -ldflags="-w -s"). Never deploy dynamic glibc-dependent Go binaries.
- Static Frontends (Preact / Svelte / React): Multi-stage
pnpm builder with nginx:alpine runner.
Mandatory Container Hardening Rules:
- Multi-Stage Builds: Build tooling, SDKs, and source compilers MUST NEVER exist in the production runtime stage.
- Non-Root Execution: Every runtime image MUST define and execute as an unprivileged user (
nextjs, appuser, workeruser).
- Healthcheck Directives: Every service image MUST include an active
HEALTHCHECK probing its readiness endpoint.
- Minimal Attack Surface: Base runtime stages on
alpine:3.21, python:3.12-slim, or distroless.
- Context Efficiency: Every project MUST contain a
.dockerignore pruning node_modules, .git, test artifacts, and caches.
- Automated Container Registry: Every repository SHOULD include a GitHub Actions workflow building and publishing images to a container registry (
<registry-user>/<image-name>).
3. Technology Blueprints
Blueprint A: Next.js Standalone (Node 22 + pnpm)
next.config.ts must set output: "standalone".
- Multi-stage build copies
.next/standalone, .next/static, and public.
- Runs as
nextjs:nodejs on port 3000.
Blueprint B: Static SPAs (Vite / Preact / Svelte + Nginx)
- Builds static assets to
dist/ with pnpm build.
- Deploys into
nginx:alpine.
- Custom
nginx.conf handles SPA routing fallback (try_files $uri $uri/ /index.html;), gzip compression, and /health.
Blueprint C: Go API / Microservice
golang:alpine builder with go mod download.
- Static compilation:
CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /bin/server ..
- Runtime stage:
alpine:3.21 with ca-certificates, tzdata, curl, running as appuser.
Blueprint D: Python AI / API Service (FastAPI + uv)
- Installs
uv from ghcr.io/astral-sh/uv:latest.
uv sync --frozen --no-dev --no-install-project with UV_COMPILE_BYTECODE=1.
- Runtime stage:
python:3.12-slim with unprivileged appuser.
4. Verification & Testing Runbook
# 1. Validate Docker daemon is operational
docker info
# 2. Build image locally with Buildx
docker build -t <service-name>:local .
# 3. Test local container execution & healthcheck
docker run -d --name test-<service-name> -p <port>:<port> <service-name>:local
sleep 5
docker ps --filter name=test-<service-name>
curl -f http://localhost:<port>/health || exit 1
docker rm -f test-<service-name>
# 4. Verify Compose environment
docker compose up -d
docker compose ps
docker compose down
1---2name: docker-first-architecture3description: Rules, architectures, multi-stage Dockerfile blueprints, and container-first workflows for all microservices, frontends, and backends targeting container registries, AWS ECS/EKS, and self-hosting.4---56# Docker-First & Image-First Architecture Skill78This skill defines the official architectural guidelines, containerization blueprints, and publishing standards across all services. It enforces a **Docker-First and Image-First** doctrine to guarantee infrastructure portability from serverless/PaaS edge environments to cloud container platforms (AWS ECS/EKS) and sovereign self-hosting.910---1112## 1. Overview & Objective1314Every service—regardless of language or framework—must be fully containerized, reproducible, and ready for container registry publication (`<registry-user>/<image-name>`).1516### Portability Roadmap171. **Phase 1 (Edge/PaaS)**: Edge/serverless frontends, containerized backends, managed/serverless PostgreSQL, container registry.182. **Phase 2 (Cloud Native)**: Cloud Infrastructure as Code (Terraform, ECS Fargate / EKS, Load Balancers, CloudFront, Container Registry).193. **Phase 3 (Sovereign Infrastructure)**: Self-Hosted Bare Metal / VPS (Docker Compose / Nomad / K3s, reverse proxy, automated backup sync).2021---2223## 2. Core Directives & Toolchain Standards2425> [!IMPORTANT]26> **OPTIMAL TOOLCHAIN MANDATE**: Always employ the fastest, most deterministic tools:27> - **Node.js / TypeScript**: `pnpm` exclusively. Never use `npm` or legacy `yarn`.28> - **Python**: `uv` exclusively (`ghcr.io/astral-sh/uv:latest`). Never use plain `pip` or slow virtualenv setups.29> - **Go**: Static compilation (`CGO_ENABLED=0`, `-ldflags="-w -s"`). Never deploy dynamic glibc-dependent Go binaries.30> - **Static Frontends (Preact / Svelte / React)**: Multi-stage `pnpm` builder with `nginx:alpine` runner.3132### Mandatory Container Hardening Rules:331. **Multi-Stage Builds**: Build tooling, SDKs, and source compilers MUST NEVER exist in the production runtime stage.342. **Non-Root Execution**: Every runtime image MUST define and execute as an unprivileged user (`nextjs`, `appuser`, `workeruser`).353. **Healthcheck Directives**: Every service image MUST include an active `HEALTHCHECK` probing its readiness endpoint.364. **Minimal Attack Surface**: Base runtime stages on `alpine:3.21`, `python:3.12-slim`, or `distroless`.375. **Context Efficiency**: Every project MUST contain a `.dockerignore` pruning `node_modules`, `.git`, test artifacts, and caches.386. **Automated Container Registry**: Every repository SHOULD include a GitHub Actions workflow building and publishing images to a container registry (`<registry-user>/<image-name>`).3940---4142## 3. Technology Blueprints4344### Blueprint A: Next.js Standalone (Node 22 + pnpm)45- `next.config.ts` must set `output: "standalone"`.46- Multi-stage build copies `.next/standalone`, `.next/static`, and `public`.47- Runs as `nextjs:nodejs` on port 3000.4849### Blueprint B: Static SPAs (Vite / Preact / Svelte + Nginx)50- Builds static assets to `dist/` with `pnpm build`.51- Deploys into `nginx:alpine`.52- Custom `nginx.conf` handles SPA routing fallback (`try_files $uri $uri/ /index.html;`), gzip compression, and `/health`.5354### Blueprint C: Go API / Microservice55- `golang:alpine` builder with `go mod download`.56- Static compilation: `CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o /bin/server .`.57- Runtime stage: `alpine:3.21` with `ca-certificates`, `tzdata`, `curl`, running as `appuser`.5859### Blueprint D: Python AI / API Service (FastAPI + uv)60- Installs `uv` from `ghcr.io/astral-sh/uv:latest`.61- `uv sync --frozen --no-dev --no-install-project` with `UV_COMPILE_BYTECODE=1`.62- Runtime stage: `python:3.12-slim` with unprivileged `appuser`.6364---6566## 4. Verification & Testing Runbook6768```bash69# 1. Validate Docker daemon is operational70docker info7172# 2. Build image locally with Buildx73docker build -t <service-name>:local .7475# 3. Test local container execution & healthcheck76docker run -d --name test-<service-name> -p <port>:<port> <service-name>:local77sleep 578docker ps --filter name=test-<service-name>79curl -f http://localhost:<port>/health || exit 180docker rm -f test-<service-name>8182# 4. Verify Compose environment83docker compose up -d84docker compose ps85docker compose down86```