Docker image create

From bdfinst/agentic-dev-team · View interactive version

Docker image create is an AI agent skill from the GitHub repository bdfinst/agentic-dev-team. Generate production-ready Dockerfiles from project source code. Detects language/framework automatically and produces multi-stage builds with minimal, distroless, or slim base images. Use this skill whenever the user wants to containerize an application, create a Dockerfile, dockerize a project, bui

How to use this skill

Skill file

Docker Image Creation

Generate production-ready Dockerfiles by analyzing language, framework, and dependencies. Output is a multi-stage build optimized for small image size, fast builds, and minimal attack surface.

Default base image strategy: distroless when possible (only the app and its runtime — no shell, no package manager, no OS utilities; minimal CVE exposure). Fall back to slim (node:22-slim, python:3.12-slim) when the runtime needs OS-level libraries or a shell for debugging.

Workflow

Step 1: Detect the project

Scan the project root to identify:

  1. Language + version (from version files / configs):
  1. Framework (drives build command + output structure):
  1. Package manager (drives install command):
  1. Entry point: package.json scripts.start / main, Procfile, existing Dockerfile CMD, or framework convention (main.go, app.py, Application.java).
  1. Existing Docker artifacts: .dockerignore, existing Dockerfile, docker-compose.yml.

Present a detection summary to the user and ask: "Want me to adjust anything before generating?"

Step 2: Ask about registry and build tools

Ask:

  1. Container registry? (Docker Hub, ghcr.io, ECR, GCR, ACR) — affects FROM paths and login steps.
  2. Build tool? Default: BuildKit (DOCKER_BUILDKIT=1). Enables cache mounts, secret mounts, and parallel stages.
  3. Generate .dockerignore? If missing or sparse.
  4. Generate docker-compose.yml? For local development.

Proceed with sensible defaults if the user says "just go with defaults."

Step 3: Generate the Dockerfile

Layer order (least-changed → most-changed) for cache efficiency: base image → system deps → dependency manifest + install → source code → build → final stage with only the runtime artifact.

Cache-friendly install — copy manifests first, install, then copy source:

COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build

Never COPY . . before install — busts the cache on every source change.

Stages: deps (install) → build (compile/bundle) → runtime (minimal base with artifact only). Two stages suffice for interpreted languages without a build step.

Base image table:

| Language | Build stage | Runtime stage |

|---|---|---|

| Go | golang:<version> | gcr.io/distroless/static-debian12 |

| Java | eclipse-temurin:<version> | gcr.io/distroless/java21-debian12 |

| Node.js | node:<version> | node:<version>-slim or gcr.io/distroless/nodejs22-debian12 |

| Python | python:<version> | python:<version>-slim |

| .NET | mcr.microsoft.com/dotnet/sdk:<version> | mcr.microsoft.com/dotnet/aspnet:<version>-alpine |

Pin major.minor (e.g., node:22.12, not node:latest). Digest-pin only for high-security environments.

Security defaults:

Health checks (when the app exposes HTTP):

HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
  CMD ["wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/health"] || exit 1

Distroless images lack wget/curl — skip HEALTHCHECK and rely on the orchestrator (Kubernetes liveness probes etc.).

OCI labels:

LABEL org.opencontainers.image.source="https://github.com/OWNER/REPO"
LABEL org.opencontainers.image.description="Brief description"

Step 4: Generate .dockerignore

If absent or sparse, write one tailored to the detected language. Common patterns:

.git
.github
node_modules
dist
build
*.md
.env*
.vscode
.idea
Dockerfile*
docker-compose*
.dockerignore
coverage
.nyc_output
__pycache__
*.pyc
.pytest_cache
.mypy_cache
bin/
obj/

Drop language-irrelevant patterns (no Python patterns for a Go project).

Step 5: Generate docker-compose.yml (if requested)

Development-focused: volume mounts for live reload, port mappings, env-file references, dependent services (database, cache) if detected.

Step 6: Provide build and run instructions

docker build -t my-app .
docker run -p 3000:3000 my-app

# With BuildKit
DOCKER_BUILDKIT=1 docker build -t my-app .

Include framework-specific notes (e.g., Next.js standalone mode requires output: 'standalone' in next.config.js).

Language-specific patterns

Node.js / Next.js (standalone)

Go

Python

C# / .NET

Java (Spring Boot)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.