Files
crucible-agent-create-produ…/README.md

1.9 KiB

FastAPI containerizer (step 4)

This tool adds container files to an existing completed FastAPI repository; it never scaffolds or replaces the application. It preserves all four input objects and emits container_artifacts, including exact file content and SHA-256 digests.

Preconditions

The service must contain the configured import module (default app.main:app) and a requirements.lock containing the complete dependency closure as exact name==version pins. The image installs that closure with --no-deps, preventing undeclared dependency resolution. If health_endpoint is configured, generation fails unless that route literal occurs in Python source; otherwise no health check is emitted.

Run

python -m pip install -e .
containerize-fastapi --input prior-step.json --service-dir /path/to/existing/service \
  --output step-4.json --verify-docker

Without --verify-docker, output explicitly records that Docker was not executed. With it, container_artifacts.docker_verification records build/up/down commands, exit codes, bounded logs, and probe status.

Generated files and key lines:

  • Dockerfile: FROM python:3.12.8-slim-bookworm, pip ... --no-deps -r requirements.lock, USER 10001:10001, and exec-form python -m uvicorn app.main:app ....
  • .dockerignore: excludes VCS, virtualenvs, caches, secrets, tests, docs, and container files from context.
  • compose.yaml: one api service, local build context, port mapping, read-only root, /tmp tmpfs, init, no-new-privileges, and no external services. Health check is conditional.

Verification

python -m unittest discover -s tests -v
# Requires a running Docker engine and performs a real build/start/HTTP probe/stop:
./scripts/integration.sh

The integration script creates only a disposable fixture to verify this transformation tool. In normal use, artifacts are written directly into the supplied completed service repository.