Docker-First & Image-First Architecture Skill
This skill defines the official architectural guidelines, containerization blueprints, and publishing standards across all services in the personal projects ecosystem. It enforces a Docker-First and Image-First doctrine to guarantee infrastructure portability from Vercel/Render edge environments to AWS (Terraform + ECS/EKS) and sovereign self-hosting.
1. Overview & Objective
Every service—regardless of language or framework—must be fully containerized, reproducible, and published to Docker Hub (shardendumishra22/*).
Portability Roadmap
- Phase 1 (Current): Hybrid Edge/PaaS (Vercel serverless frontends, Render container backends, Neon serverless PostgreSQL, Docker Hub registry).
- Phase 2 (Cloud Evolution): AWS Cloud Native (Terraform IaC, AWS ECS Fargate or EKS, Application Load Balancers, CloudFront, Docker Hub / ECR).
- Phase 3 (Sovereign Infrastructure): Self-Hosted Bare Metal / VPS (Docker Compose / Nomad / K3s, Traefik / Nginx 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 (via Corepack). 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 Docker Hub Registry: Every repository MUST include a GitHub Actions workflow building and publishing multi-platform or linux/amd64 images to
shardendumishra22/<image-name>.
3. Technology Blueprints
Blueprint A: Next.js 16 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 (Preact / Svelte 5 / Vite + Nginx)
- Builds static assets to
dist/ with pnpm --filter <app> 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 1.25 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 3.12 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.
Blueprint E: Express 5 + TypeScript + Drizzle API
- Compiles TypeScript to
dist/.
- Prunes dependencies with
pnpm install --prod --frozen-lockfile.
- Runtime stage:
node:22-alpine with non-root appuser.
4. Verification & Testing Runbook
# 1. Validate Docker daemon is operational
docker info
# 2. Build image locally with Buildx
docker build -t shardendumishra22/<service-name>:local .
# 3. Test local container execution & healthcheck
docker run -d --name test-<service-name> -p <port>:<port> shardendumishra22/<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 Docker Hub, 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 in the personal projects ecosystem. It enforces a **Docker-First and Image-First** doctrine to guarantee infrastructure portability from Vercel/Render edge environments to AWS (Terraform + ECS/EKS) and sovereign self-hosting.910---1112## 1. Overview & Objective1314Every service—regardless of language or framework—must be fully containerized, reproducible, and published to Docker Hub (`shardendumishra22/*`).1516### Portability Roadmap171. **Phase 1 (Current)**: Hybrid Edge/PaaS (Vercel serverless frontends, Render container backends, Neon serverless PostgreSQL, Docker Hub registry).182. **Phase 2 (Cloud Evolution)**: AWS Cloud Native (Terraform IaC, AWS ECS Fargate or EKS, Application Load Balancers, CloudFront, Docker Hub / ECR).193. **Phase 3 (Sovereign Infrastructure)**: Self-Hosted Bare Metal / VPS (Docker Compose / Nomad / K3s, Traefik / Nginx 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 (via Corepack). 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 Docker Hub Registry**: Every repository MUST include a GitHub Actions workflow building and publishing multi-platform or linux/amd64 images to `shardendumishra22/<image-name>`.3940---4142## 3. Technology Blueprints4344### Blueprint A: Next.js 16 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 (Preact / Svelte 5 / Vite + Nginx)50* Builds static assets to `dist/` with `pnpm --filter <app> 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 1.25 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 3.12 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### Blueprint E: Express 5 + TypeScript + Drizzle API65* Compiles TypeScript to `dist/`.66* Prunes dependencies with `pnpm install --prod --frozen-lockfile`.67* Runtime stage: `node:22-alpine` with non-root `appuser`.6869---7071## 4. Verification & Testing Runbook7273```bash74# 1. Validate Docker daemon is operational75docker info7677# 2. Build image locally with Buildx78docker build -t shardendumishra22/<service-name>:local .7980# 3. Test local container execution & healthcheck81docker run -d --name test-<service-name> -p <port>:<port> shardendumishra22/<service-name>:local82sleep 583docker ps --filter name=test-<service-name>84curl -f http://localhost:<port>/health || exit 185docker rm -f test-<service-name>8687# 4. Verify Compose environment88docker compose up -d89docker compose ps90docker compose down91```