From 2a001fd63f056ddf249584fa004eebf946234d69 Mon Sep 17 00:00:00 2001 From: Sai Sridhar Tarra <117087864+sridhar-3009@users.noreply.github.com> Date: Mon, 27 Jul 2026 12:01:33 +0530 Subject: [PATCH] fix(docker): normalize CRLF line endings on Windows checkouts (#951) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Windows Git checkout with checkout-time CRLF conversion enabled produces CRLF working-tree copies of package.json and scripts/rocm-entrypoint.sh, breaking the Docker build two ways: - The frontend stage's `sed -i -z 's/,\n ]/…/'` is LF-anchored, so it doesn't match against \r\n and leaves an invalid trailing comma in package.json, which then fails JSON parsing in the vite build. - The final stage copies rocm-entrypoint.sh straight from the build context; with a CRLF shebang the container reports the misleading "no such file or directory" for an entrypoint that plainly exists, because Linux can't resolve "/bin/sh\r" as an interpreter. Add .gitattributes forcing LF for both files at checkout time, plus a sed normalization step in each Dockerfile stage for resilience with clones that predate the .gitattributes rule. Fixes #915 --- .gitattributes | 2 ++ Dockerfile | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..f984d3b0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +package.json text eol=lf +scripts/*.sh text eol=lf diff --git a/Dockerfile b/Dockerfile index 2fe66e5a..e1340a2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,11 @@ COPY package.json bun.lock CHANGELOG.md ./ COPY app/ ./app/ COPY web/ ./web/ -# Strip workspaces not needed for web build, and fix trailing comma -RUN sed -i '/"tauri"/d; /"landing"/d' package.json && \ +# Normalize line endings first (a Windows CRLF checkout would otherwise +# defeat the `-z 's/,\n ]/…/'` match below, since it's LF-anchored), then +# strip workspaces not needed for web build, and fix trailing comma +RUN sed -i 's/\r$//' package.json && \ + sed -i '/"tauri"/d; /"landing"/d' package.json && \ sed -i -z 's/,\n ]/\n ]/' package.json RUN bun install --no-save # Build frontend (skip tsc — upstream has pre-existing type errors) @@ -100,7 +103,11 @@ EXPOSE 17493 HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=60s \ CMD curl -f http://localhost:17493/health || exit 1 -# Entrypoint joins GPU groups then drops to the voicebox user +# Entrypoint joins GPU groups then drops to the voicebox user. +# Normalize CRLF (a Windows checkout otherwise leaves the shebang as +# `#!/bin/sh\r`, which Linux can't resolve — reported as a misleading +# "no such file or directory" even though the file exists). COPY --chmod=755 scripts/rocm-entrypoint.sh /usr/local/bin/entrypoint.sh +RUN sed -i 's/\r$//' /usr/local/bin/entrypoint.sh ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "17493"]