From 55a022a95ba43c0a378e3d1e26dc89e9bd3ff355 Mon Sep 17 00:00:00 2001 From: demo-bot Date: Sun, 9 Aug 2026 15:10:48 +0000 Subject: [PATCH] decomposer: generate files for Create a production-suitable Dockerfile and minimal Docker Compose configuration for packaging and running the completed FastAPI endpoint monitoring service. --- src/containerizer/cli.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/containerizer/cli.py diff --git a/src/containerizer/cli.py b/src/containerizer/cli.py new file mode 100644 index 0000000..b327f4b --- /dev/null +++ b/src/containerizer/cli.py @@ -0,0 +1,40 @@ +import argparse +import json +import sys + +from .generate import containerize, dumps +from .verify import verify_with_docker + + +def main() -> None: + parser = argparse.ArgumentParser(description="Containerize an existing FastAPI service") + parser.add_argument("--input", default="-", help="contract JSON file, or - for stdin") + parser.add_argument("--service-dir", required=True, help="existing FastAPI repository root") + parser.add_argument("--output", default="-", help="result JSON file, or - for stdout") + parser.add_argument("--verify-docker", action="store_true", + help="actually build, start, probe (when configured), and stop Compose") + args = parser.parse_args() + raw = sys.stdin.read() if args.input == "-" else open(args.input).read() + payload = json.loads(raw) + result = containerize(payload, args.service_dir) + if args.verify_docker: + spec = payload["service_specification"] + cfg = spec.get("container", {}) + port = cfg.get("port", spec.get("port", 8000)) + health = cfg.get("health_endpoint", spec.get("health_endpoint")) + result["container_artifacts"]["docker_verification"] = verify_with_docker( + args.service_dir, port, health) + else: + result["container_artifacts"]["docker_verification"] = { + "executed": False, "passed": None, + "reason": "--verify-docker was not requested", + } + text = dumps(result) + if args.output == "-": + sys.stdout.write(text) + else: + open(args.output, "w").write(text) + + +if __name__ == "__main__": + main()