From fba5e7c7be55d78a6641f0ce9d285598aeeb56ef Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Thu, 28 May 2026 22:11:32 +0200 Subject: [PATCH] fix: add Dockerfile logging and force unix line endings for Docker builds The container build fails with 'unknown instruction: curl' on line 6, which suggests the Dockerfile continuation characters or line endings may be malformed. Add defensive logging to diagnose: - Force newline='\n' in all write_text calls in build_image for consistent Unix line endings regardless of platform - Log compiled Dockerfile and entrypoint content at INFO/DEBUG level - Log Dockerfile byte count when written This will let us see exactly what Docker is receiving in the next build attempt. --- apps/api/src/api/tool_instances.py | 5 +++++ apps/api/src/services/docker_build.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/api/src/api/tool_instances.py b/apps/api/src/api/tool_instances.py index bf661f9..18dd13c 100644 --- a/apps/api/src/api/tool_instances.py +++ b/apps/api/src/api/tool_instances.py @@ -1071,6 +1071,11 @@ async def _prepare_manifest_instance( dockerfile = compile_dockerfile(manifest) entrypoint = compile_entrypoint(manifest) + logger.info("Compiled Dockerfile for instance %s (%d chars)", instance.id, len(dockerfile)) + logger.debug("Dockerfile content: %s", dockerfile) + logger.info("Compiled entrypoint for instance %s", instance.id) + logger.debug("Entrypoint content: %s", entrypoint) + build_ctx = { "Dockerfile": dockerfile, ".headquarter/entrypoint.sh": entrypoint, diff --git a/apps/api/src/services/docker_build.py b/apps/api/src/services/docker_build.py index b556f81..0dad9a9 100644 --- a/apps/api/src/services/docker_build.py +++ b/apps/api/src/services/docker_build.py @@ -22,8 +22,9 @@ def build_image(instance_dir: str, dockerfile: str, tag: str, build_context: dic # Write Dockerfile dockerfile_path = Path(instance_dir) / "Dockerfile" - dockerfile_path.write_text(dockerfile) - logger.debug("Wrote Dockerfile to %s", dockerfile_path) + dockerfile_path.write_text(dockerfile, newline="\n") + logger.info("Wrote Dockerfile to %s (%d bytes)", dockerfile_path, len(dockerfile)) + logger.debug("Dockerfile content:\n%s", dockerfile) # Write build context files if build_context: @@ -37,7 +38,7 @@ def build_image(instance_dir: str, dockerfile: str, tag: str, build_context: dic raise ValueError(f"Build context file path '{file_path}' escapes instance directory") full_path.parent.mkdir(parents=True, exist_ok=True) - full_path.write_text(content) + full_path.write_text(content, newline="\n") logger.debug("Wrote build context file: %s", full_path) # Build image