Skip to content
Back to skills

Dockerfile Builder

BSecurity

Draft efficient, secure, and minimal multi-stage Dockerfiles.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
developmentgobashnodenodejsdockerapisecurity

Works with

  • api

Security analysis

B85/100
  • highPerforms destructive filesystem operations

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

Scanned September 27, 2026

npx -y skills add RMAzrim/opencode-artes --skill dockerfile-builder --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dockerfile Builder?

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

Security grade badge for Dockerfile Builder
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/rmazrim-dockerfile-builder/badge)](https://www.skillsdirectory.com/skills/rmazrim-dockerfile-builder)

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: Dockerfile Builder
description: Draft efficient, secure, and minimal multi-stage Dockerfiles.
metadata:
  source: skills/dockerfile-builder/dockerfile-builder.md
---

# Dockerfile Builder

## Prerequisites & Dependencies
- Docker Engine 20.10+ (Docker Desktop or Podman with BuildKit enabled)
- Project source with a dependency manifest (`package.json`, `requirements.txt`, `go.mod`, `pom.xml`, ...)
- No API keys required; a `.dockerignore` must exist so secrets (`.env`, key files) never enter image layers

## Execution Steps
1. Choose slim, version-pinned base images: a toolchain image for the build stage, a minimal runtime base (`*-alpine`, `distroless`, or `*-slim`).
2. Structure the file as multi-stage: compile/install in a `build` stage, copy only produced artifacts into the `runtime` stage.
3. Order layers for cache efficiency: copy dependency manifests first, install dependencies, then copy source last.
4. Harden security: run as a non-root user (`USER`), never bake secrets via `ARG`, and clean package caches (`--no-cache`, `rm -rf /var/lib/apt/lists/*`).
5. Add `HEALTHCHECK`, required `EXPOSE`/`ENV` declarations, and an exec-form `ENTRYPOINT`/`CMD`.
6. Build, inspect layer history and image size, then scan for CVEs; iterate until size and vulnerability profile are acceptable.

```dockerfile
# syntax=docker/dockerfile:1.7
FROM node:20-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --ignore-scripts
COPY src ./src
RUN npm run build && npm prune --omit=dev

FROM gcr.io/distroless/nodejs20-debian12:nonroot AS runtime
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
EXPOSE 3000
USER nonroot
HEALTHCHECK CMD ["node", "-e", "fetch('http://localhost:3000/health')"]
```

```bash
DOCKER_BUILDKIT=1 docker build -t app:local .
docker history app:local --no-trunc
docker scout cves app:local
```

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.

Comments

Loading comments…

Newsletter

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