fix: convert entrypoint.sh line endings at Docker build time#9
fix: convert entrypoint.sh line endings at Docker build time#9curlysasha merged 1 commit intomasterfrom
Conversation
- Add sed command in Dockerfile to strip CRLF line endings from entrypoint.sh - Add .gitattributes to enforce LF line endings for shell scripts - Fixes issue #7 where Docker container fails to start on Windows 11 This fix works immediately without requiring users to re-clone the repository. The sed command ensures correct line endings inside the container regardless of how the file was checked out on the host system. Co-authored-by: curlysasha <curlysasha@users.noreply.github.com>
Code Review - PR #9SummaryThis PR addresses a critical cross-platform compatibility issue where Docker containers fail to start on Windows due to CRLF line ending conflicts. The solution is well-targeted and effective. ✅ Strengths
🔍 Code Quality AssessmentDockerfile changes (Dockerfile:48-49): # Convert line endings to LF (fixes Windows CRLF issues) and make executable
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
.gitattributes (.gitattributes:1-5): # Ensure shell scripts always use LF line endings on all platforms
*.sh text eol=lf
# Ensure other text files maintain consistent line endings
* text=auto
🐛 Potential IssuesNone identified - the implementation is solid for this specific fix. ⚡ Performance Considerations
🔒 Security ConcernsNone - This change:
🧪 Test CoverageObservations:
Recommendation:
💡 Suggestions (Optional Enhancements)1. Extend .gitattributes coverageConsider adding other text file types that might be affected: *.sh text eol=lf
*.py text eol=lf
*.json text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.conf text eol=lf
* text=auto2. Add build validationAs mentioned above, consider adding a validation step: # Convert line endings to LF (fixes Windows CRLF issues) and make executable
RUN sed -i 's/\r$//' /entrypoint.sh && \
chmod +x /entrypoint.sh && \
head -1 /entrypoint.sh | grep -q '^#!/bin/sh$'3. Consider applying fix to all shell scriptsIf there are other shell scripts in the future: RUN find / -name "*.sh" -type f -exec sed -i 's/\r$//' {} \; 2>/dev/null || trueHowever, the current targeted approach is cleaner for now. 📋 VerdictAPPROVED ✅ This is a well-crafted fix that:
The PR is ready to merge. The optional suggestions above are enhancements, not blockers. 📚 Related Best PracticesFor future reference, this fix follows Docker best practices: Great work on this fix! 🎉 |
Summary
This PR fixes issue #7 where the Docker container fails to start on Windows 11 with the error "exec /entrypoint.sh: no such file or directory".
Changes
Dockerfile: Addedsedcommand to strip CRLF line endings fromentrypoint.shduring build.gitattributesfile to enforce LF line endings for all shell scriptsRoot Cause
When Git on Windows checks out files, it converts LF to CRLF. When Docker copies
entrypoint.shinto the Linux container, the shebang becomes#!/bin/sh\rwhich the kernel can't interpret.Solution
The
sedcommand strips any CRLF endings during the Docker build process, ensuring correct LF endings inside the container regardless of how the file was checked out.Testing
Windows users should:
docker-compose build --no-cachedocker-compose up -dCloses #7
Generated with Claude Code