← ClaudeAtlas

containerize-and-ship-a-servicelisted

Use when writing a Dockerfile or a CI/CD pipeline for a backend service — a multi-stage build (heavy builder → slim runtime), base images pulled through a dependency proxy / private registry, authenticating to private package registries during build and SCRUBBING those creds before the final stage, lockfile-first layer caching, purpose-specific images (app / DB-migration job / test), and a CI pipeline (install → lint → test → build → push → migrate → deploy) kept thin per repo by including one shared org template, with per-branch→environment deploy rules and secrets from CI variables (never baked in). Docker + GitLab CI reference, framework-flexible.
kennguyen887/agent-foundation · ★ 1 · DevOps & Infrastructure · score 77
Install: claude install-skill kennguyen887/agent-foundation
# Containerize & ship a service How a backend service is **built into an image** and **shipped through CI/CD**. Examples are Docker + GitLab CI with a Node/pnpm service; the principles port to any stack/CI. principle → **▸ Example** → **▸ Other stacks**. Branch→release flow itself is `git-flow`; DB migration rules are `database-migrations`; release backward-compat is `release-safety` — this skill is the *build + pipeline* mechanics. ## Core principle **A small, reproducible image with NO secrets baked in, shipped by a thin per-repo pipeline that includes one shared template, gated by branch.** Build creds live only in a throwaway build stage; runtime secrets come from the environment at deploy; the pipeline is maintained once, not per service. ## 1. Multi-stage build — heavy builder → slim runner Compile in a builder stage; copy only the build output + production deps into a clean runtime stage, so toolchains/dev-deps never ship. ```dockerfile FROM <registry>/node:22-alpine AS builder WORKDIR /app RUN corepack enable && corepack prepare pnpm@<ver> --activate COPY package.json pnpm-lock.yaml ./ # manifest first (cache) — see §4 RUN pnpm install --frozen-lockfile COPY . . RUN pnpm run build && pnpm store prune FROM <registry>/node:22-alpine AS runner # clean runtime base WORKDIR /app COPY package.json pnpm-lock.yaml ./ COPY --from=builder /app/dist ./ # only the build output RUN corepack enable && pnpm install --prod --frozen-lockfile && pnpm stor