fix: use single backslash for Dockerfile line continuations

The compile_dockerfile function used \\\\ in Python string literals,
which produces \ (two backslashes) in the Dockerfile output. Docker's
legacy builder requires a single backslash \ for line continuation.

This caused 'unknown instruction: curl' because Docker saw the first as the continuation and the second \ as a literal character before the
newline, breaking the RUN command parsing.

Fix: change all \\ to \ in Python string literals within
compile_dockerfile, producing the correct single-backslash continuation.

Verified with hex dump from container logs:
- Before: line ended with 5c5c (two backslashes)
- After: line ends with 5c (one backslash)
This commit is contained in:
Alex Blank
2026-05-28 22:35:47 +02:00
parent 84f30b07c4
commit 9800e37cd6
+6 -6
View File
@@ -117,10 +117,10 @@ def compile_dockerfile(manifest: dict) -> str:
# System packages (apt)
apt_packages = manifest.get("packages", {}).get("apt", [])
if apt_packages:
lines.append("RUN apt-get update && apt-get install -y \\\\")
lines.append("RUN apt-get update && apt-get install -y \\")
for pkg in apt_packages[:-1]:
lines.append(f" {pkg} \\\\")
lines.append(f" {apt_packages[-1]} \\\\")
lines.append(f" {pkg} \\")
lines.append(f" {apt_packages[-1]} \\")
lines.append(" && rm -rf /var/lib/apt/lists/*")
lines.append("")
@@ -129,9 +129,9 @@ def compile_dockerfile(manifest: dict) -> str:
if node:
version = node.get("version", "20")
lines.append(
f"RUN curl -fsSL https://deb.nodesource.com/setup_{version}.x | bash - && \\\\"
f"RUN curl -fsSL https://deb.nodesource.com/setup_{version}.x | bash - && \\"
)
lines.append(" apt-get install -y nodejs && \\\\")
lines.append(" apt-get install -y nodejs && \\")
lines.append(" rm -rf /var/lib/apt/lists/*")
lines.append("")
@@ -157,7 +157,7 @@ def compile_dockerfile(manifest: dict) -> str:
gid = user["gid"]
create_home = "-m " if user.get("create_home", True) else ""
shell = user.get("shell", "/bin/bash")
lines.append(f"RUN groupadd -g {gid} {name} && \\\\")
lines.append(f"RUN groupadd -g {gid} {name} && \\")
lines.append(f" useradd -u {uid} -g {gid} {create_home}-s {shell} {name}")
lines.append("")