Docker foundation
Skill ahtishamshahzad/agent_dev_flow/.ai/skills/devops/docker-foundation
Use to plan Docker images for services — multi-stage builds, small trusted base images, layer caching, non-root runtime, no secrets baked in, .dockerignore, and reproducible tags. For local dev orchestration or production images; does not scaffold application code.From its SKILL.md
npx -y skills add ahtishamshahzad/agent_dev_flow --skill docker-foundationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.9 KB, ~1.0k tokens by cl100k_base, as published. Nobody here has run it
Docker Foundation
Purpose
Produce container images that are small, reproducible, secure, and cache-efficient — for a backend service and for consistent local/CI environments — without baking in secrets or shipping bloated, root-running images.
When to Use
- When a service is containerized for deployment, or dev/CI needs reproducible environments.
- Not for choosing the deployment target (
deployment-selection) or scaffolding app code.
Inputs
- The service's runtime (Node version), build steps, and workspace context (
pnpm-workspaces/npm-workspaces). - Deployment target expectations (
deployment-selection,../../backend/backend-deployment).
Discovery Questions
- What is the runtime + exact version, and the build → run split (compile vs serve)?
- Is this a monorepo build (workspace-aware context, pruned dependencies)?
- What must be injected at runtime (config/secrets — never built in)?
Responsibilities
- Use multi-stage builds: a build stage (deps, compile) and a lean runtime stage copying only artifacts — no toolchain, dev deps, or source in the final image.
- Pick a small, trusted, pinned base image (specific digest/tag, slim/distroless where viable) —
latestis non-reproducible and a supply-chain risk (../../security/dependency-security). - Order layers for cache efficiency: copy manifests + lockfile and install before copying source, so code changes don't bust the dependency layer (monorepo: prune to the target package's deps).
- Run as non-root: dedicated user, minimal filesystem permissions.
- No secrets in the image or build args that persist in layers — config/secrets injected at runtime (
secrets-management,environment-management); use build secrets mounts if a build needs a token. - Add a thorough
.dockerignore(node_modules, .git, .env, tests) to shrink context and avoid leaking files. - Produce reproducible, meaningful tags (immutable, e.g. content/commit-based) that
../../backend/backend-deploymentpromotes across environments unchanged.
Required Workflow
- Define build vs runtime stages.
- Pick + pin a small trusted base image.
- Order layers for dependency caching (workspace-pruned in monorepos).
- Set non-root user +
.dockerignore. - Ensure runtime-injected config/secrets (none baked); define the tagging scheme.
Decision Rules
- Multi-stage always for compiled/Node services — runtime images carry artifacts, not toolchains.
- Pin base images by digest/specific tag — never
latest(reproducibility + supply chain). - Secrets are runtime, never image-layer; a secret in any layer is leaked to anyone with the image.
- One immutable image promoted across environments — differences are runtime config only (
../../backend/backend-deployment).
Rules
- No secrets baked into images or persisted build args.
- Non-root runtime.
- Base images pinned;
.dockerignorepresent.
Anti-Patterns
- Single-stage images shipping the full toolchain + source.
FROM node:latest(non-reproducible, unvetted).COPY . .before installing deps (cache-busting) or without.dockerignore(leaks .env/.git).- Secrets in
ENV/build args baked into layers. - Running as root.
Validation Checklist
- Multi-stage; lean runtime image.
- Small trusted base pinned by digest/tag.
- Layers ordered for dependency caching (workspace-pruned).
- Non-root user;
.dockerignorepresent. - No secrets in image/layers; runtime injection only.
- Reproducible immutable tags.
Definition of Done
Reproducible multi-stage images on a small pinned base, cache-efficient, non-root, secret-free (runtime-injected config), with a thorough .dockerignore and immutable tags ready for promotion across environments.
Related Skills
deployment-selection, ../../backend/backend-deployment, secrets-management, environment-management, pnpm-workspaces, npm-workspaces, ci-cd, ../../security/dependency-security.
Related Knowledge
../../../knowledge/ (runtime versions, target constraints).
Related References
../../../references/devops/ (Dockerfile patterns, when populated).
Context Loading Guidance
- Requires: runtime + build steps, workspace context, target expectations.
- Does not require: app feature code, deployment-target internals.
- May load:
secrets-management,deployment-selection. - Stop when: the image design (stages, base, caching, non-root, tags) is recorded.
Token Efficiency Guidance
The stage/layer plan + base-image + tag scheme is the artifact; don't paste full Dockerfiles into discussion.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.