- refactor(scaffold): move Docker/compose templates and three-stage doc into new containerize-project skill; build-* skills delegate their Docker step - fix(scaffold): drop source mount from the production compose service - fix(scaffold): add .dockerignore templates so COPY . . excludes .git/.env/data - feat(scaffold): run production stages as non-root app user; pin uv install via COPY --from=ghcr.io/astral-sh/uv:0.7 - docs(README): list containerize-project and add-docker-secrets; remove the now-empty _concepts section Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3.5 KiB
3.5 KiB
name: containerize-project
description: Add a three-stage Docker setup (base/production/development) to a project — Dockerfile, docker-compose.yml, .dockerignore, and Docker recipes in the justfile. Detects the ecosystem from marker files (pyproject.toml → uv on python-slim; DESCRIPTION → renv on rocker/r-ver; _targets.R → renv on rocker/verse). Hardened defaults: non-root production user, pinned package-manager install, no source mount in the production service. Materialises files and stops on
jj diff for review before any commit. Use when the user says "containerize", "dockerize", "add docker", "/containerize-project", or a scaffold skill (build-py-project, build-r-package, build-r-analysis) delegates Docker setup here.
containerize-project
When to use
- User says "containerize", "dockerize", "add docker", "/containerize-project".
- A
build-*scaffold skill reaches its Docker step and delegates here. - An existing uv or renv project needs the standard three-stage setup.
Process
- Detect ecosystem (in this order; ask if none or several match):
Marker Variant Templates pyproject.tomlpython Dockerfile.python.tpl,docker-compose.python.yml.tpl,dockerignore.python.tplDESCRIPTIONr-package Dockerfile.r-package.tpl,docker-compose.r.yml.tpl,dockerignore.r.tpl_targets.Rr-analysis Dockerfile.r-analysis.tpl,docker-compose.r.yml.tpl,dockerignore.r.tpl - Materialise with placeholder substitution:
Dockerfile← variant Dockerfile templatedocker-compose.yml← variant compose template.dockerignore← variant dockerignore template
- Justfile recipes from
justfile-docker.tpl:- No
justfile→ create one with the standard header (set dotenv-load := false,default: @just --list) plus the Docker section. justfileexists without abuild-devrecipe → append the Docker section.build-devalready present → leave the justfile alone.
- No
- Stop. Do not run
jj describe. Tell the user:"Review with
jj diff. Thenjust build-devto verify the toolchain. Describe with/jj-atomicwhen satisfied."
Placeholders
- python:
<project-name>(kebab-case),<package_name>(snake_case). - r-package:
<package-name>. - r-analysis:
<project-name>(snake_case).
Guardrails
- Never overwrite an existing
Dockerfile,docker-compose.yml, or.dockerignorewithout explicit confirmation — show a diff first. - Never put credentials in
ENV,ARG, orCOPY-ed files — that'sadd-docker-secretsterritory. - Never add a source mount to the production service — it overrides the baked image and defeats immutability.
- The development stage runs as root deliberately (bind mounts +
interactive installs); production runs as
app. Don't "fix" either. - Keep the pinned uv image tag; never switch to
:latest.
See also
- three-stage-dockerfile.md — rationale for the base/production/development pattern, caveats, anti-patterns.
../add-docker-secrets/SKILL.md— build-time and runtime secrets once the project needs credentials.../build-py-project/SKILL.md,../build-r-package/SKILL.md,../build-r-analysis/SKILL.md— scaffolds that delegate their Docker step here.