56 lines
2.0 KiB
Markdown
56 lines
2.0 KiB
Markdown
---
|
|
name: dockerfile-builder
|
|
description: "Build or rewrite a Dockerfile for the current project, including all required runtime and build dependencies even if the user forgot to mention them. Use when: user asks to create Dockerfile, fix Dockerfile, containerize app, собрать Dockerfile, написать Dockerfile, починить Dockerfile, собрать образ, контейнеризовать проект, образ не работает, перепиши Dockerfile. Prefer safe optimization, but do not risk correctness for image size."
|
|
argument-hint: "Project path or app entrypoint to containerize (for example: ., api/, backend/main.py, package.json, pyproject.toml)"
|
|
---
|
|
|
|
# Dockerfile Builder
|
|
|
|
Creates or rewrites a Dockerfile that actually runs.
|
|
|
|
## Procedure
|
|
|
|
### Step 1 — Detect the Stack
|
|
|
|
Inspect the repository and detect runtime, package manager, entrypoint, port,
|
|
and existing container files (`Dockerfile`, `.dockerignore`, compose files).
|
|
|
|
### Step 2 — Infer Missing Dependencies
|
|
|
|
Infer system and runtime dependencies from manifests and code even if user did
|
|
not mention them.
|
|
|
|
### Step 3 — Choose Base Image Safely
|
|
|
|
Prefer correctness over minimal image size.
|
|
Use slim/multi-stage only when confidence is high.
|
|
|
|
### Step 4 — Build Dockerfile
|
|
|
|
Create or rewrite `Dockerfile` with reproducible install steps, clear command,
|
|
and cache-friendly layer order.
|
|
|
|
Allowed companion updates:
|
|
- `.dockerignore`
|
|
- `docker-compose.yml` and overrides
|
|
- `.env.example`
|
|
- startup scripts required for container boot
|
|
|
|
### Step 5 — Validate
|
|
|
|
If Docker/Podman is available, attempt real build and startup validation.
|
|
If runtime tools are unavailable, perform static validation and clearly report
|
|
what was not verified.
|
|
|
|
### Step 6 — Repair if Broken
|
|
|
|
If build or run fails, diagnose and rewrite with minimal necessary changes.
|
|
|
|
## Completion Checklist
|
|
|
|
- Dockerfile matches detected stack
|
|
- Required build/runtime dependencies included
|
|
- Startup command is consistent with project
|
|
- Validation attempted
|
|
- Build/run commands provided to user
|