Skip to content

fix(docker): normalize CRLF line endings on Windows checkouts#951

Open
sridhar-3009 wants to merge 1 commit into
jamiepine:mainfrom
sridhar-3009:fix/dockerfile-crlf-line-endings-915
Open

fix(docker): normalize CRLF line endings on Windows checkouts#951
sridhar-3009 wants to merge 1 commit into
jamiepine:mainfrom
sridhar-3009:fix/dockerfile-crlf-line-endings-915

Conversation

@sridhar-3009

@sridhar-3009 sridhar-3009 commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #915.

Problem

A Windows Git checkout with checkout-time CRLF conversion enabled produces CRLF working-tree copies of package.json and scripts/rocm-entrypoint.sh, breaking docker compose build/up two independent ways:

  1. Frontend build: the trailing-comma fixup sed -i -z 's/,\n ]/\n ]/' is LF-anchored and doesn't match ,\r\n ], so the "web", entry's trailing comma survives after "tauri"/"landing" are stripped, producing invalid JSON that fails the Vite build (JSON does not support trailing commas).
  2. Runtime entrypoint: the final stage copies scripts/rocm-entrypoint.sh straight from the build context. With a CRLF shebang, the effective interpreter path becomes /bin/sh\r, which Linux can't resolve — surfaced as the misleading exec /usr/local/bin/entrypoint.sh: no such file or directory even though the file is right there.

Fix

Two parts, both suggested in the issue:

  1. Added .gitattributes forcing LF for both files at checkout time going forward:
    package.json text eol=lf
    scripts/*.sh text eol=lf
  2. Added a sed -i 's/\r$//' normalization step in each Dockerfile stage (before the trailing-comma fixup, and right after copying the entrypoint script) for resilience with clones that predate the .gitattributes rule.

Testing

I don't have a Windows machine to reproduce the CRLF checkout directly, so I verified the regex behavior conceptually: sed's -z mode splits on NUL only, so \r before the matched \n is preserved as part of the "non-newline" content and defeats the pattern's ,\n anchor exactly as described. I didn't run the full docker compose build end-to-end. Happy to adjust if you can verify against a real CRLF checkout.

Summary by CodeRabbit

  • Bug Fixes
    • Improved cross-platform build reliability by normalizing line endings in package configuration and startup scripts.
    • Prevented issues caused by Windows-style CRLF files during container builds and GPU runtime startup.

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 jamiepine#915
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 150de376-f6b9-49bb-add1-95a16915994c

📥 Commits

Reviewing files that changed from the base of the PR and between 52f8d8d and 49b2328.

📒 Files selected for processing (2)
  • .gitattributes
  • Dockerfile

📝 Walkthrough

Walkthrough

The changes enforce LF endings for package.json and shell scripts, and normalize CRLF content during Docker builds for package.json and the GPU entrypoint.

Changes

Line-ending normalization

Layer / File(s) Summary
Normalize repository and image line endings
.gitattributes, Dockerfile
.gitattributes enforces LF endings for package.json and scripts/*.sh; Docker build steps strip CRLF characters from package.json and the installed GPU entrypoint script.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related issues

  • Issue 915: The changes implement CRLF normalization in .gitattributes and the Dockerfile for package.json and scripts/rocm-entrypoint.sh.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: normalizing CRLF line endings in Docker-related files on Windows checkouts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
Dockerfile

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker build and container startup fail on Windows checkouts due to CRLF line endings

1 participant