pgadmin4 icon indicating copy to clipboard operation
pgadmin4 copied to clipboard

Force LF line endings on text files

Open Guiorgy opened this issue 2 months ago • 2 comments

Depending on how git is configured on Windows, git may attempt to normalize text file line endings to CRLF (\r\n), which results in broken Docker containers being built, as, for example, the entry point shell script fails to execute.

This PR adds the .gitattributes file instructing git to force LF (\n) line endings on text files.

Demonstration of the entrypoint.sh script having Windows CRLF line endings:

image

Demonstration of the entrypoint.sh script having Unix LF line endings after applying this PR (and resetting files):

image

Demonstration of the Docker build and run on a Windows machine:

> ver

Microsoft Windows [Version 10.0.19045.6575]

> docker version
Client:
 Version:           28.4.0
 API version:       1.51
 Go version:        go1.24.7
 Git commit:        d8eb465
 Built:             Wed Sep  3 20:59:40 2025
 OS/Arch:           windows/amd64
 Context:           desktop-linux

Server: Docker Desktop 4.47.0 (206054)
 Engine:
  Version:          28.4.0
  API version:      1.51 (minimum version 1.24)
  Go version:       go1.24.7
  Git commit:       249d679
  Built:            Wed Sep  3 20:57:37 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.27
  GitCommit:        05044ec0a9a75232cad458027ca83437aae3f4da
 runc:
  Version:          1.2.5
  GitCommit:        v1.2.5-0-g59923ef
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

> docker build --tag "pgadmin4:latest" .
...
=> exporting to image                                                                           9.1s
 => => exporting layers                                                                          9.0s
 => => writing image sha256:d0795b07892ecd1d58d3707da73094dbd8b0bb57c3ede384866d22e1bbd64da8     0.0s
 => => naming to docker.io/library/pgadmin4:latest                                               0.0s

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/uwm2g1ptmf8azdewr07zqy91b

> docker run --rm -p 8080:80 -e [email protected] -e PGADMIN_DEFAULT_PASSWORD=admin pgadmin4:latest
email config is {'CHECK_EMAIL_DELIVERABILITY': False, 'ALLOW_SPECIAL_EMAIL_DOMAINS': [], 'GLOBALLY_DELIVERABLE': True}
/venv/lib/python3.12/site-packages/passlib/pwd.py:16: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
NOTE: Configuring authentication for SERVER mode.

pgAdmin 4 - Application Initialisation
======================================

postfix/postlog: starting the Postfix mail system
/venv/lib/python3.12/site-packages/passlib/pwd.py:16: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
/venv/lib/python3.12/site-packages/passlib/pwd.py:16: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
[2025-11-14 12:31:57 +0000] [1] [INFO] Starting gunicorn 23.0.0
[2025-11-14 12:31:57 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
[2025-11-14 12:31:57 +0000] [1] [INFO] Using worker: gthread
[2025-11-14 12:31:57 +0000] [123] [INFO] Booting worker with pid: 123
::ffff:172.17.0.1 - - [14/Nov/2025:12:32:20 +0000] "GET / HTTP/1.1" 302 213 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:144.0) Gecko/20100101 Firefox/144.0"
...

The page localhost:8080 responded:

image

So the image builds and runs successfully on Windows.

Summary by CodeRabbit

  • Chores
    • Added repository configuration for consistent line ending handling across development environments.

Guiorgy avatar Nov 14 '25 12:11 Guiorgy

Walkthrough

A .gitattributes file is added to configure Git for automatic text file detection and line ending normalization. The file specifies that all files should be treated as text with LF line endings (\n) to ensure consistent behavior across different operating systems.

Changes

Cohort / File(s) Change Summary
Git Configuration
\.gitattributes
Added configuration to enable automatic text file detection and normalize all line endings to LF

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

This is a straightforward configuration file addition with no logic or code changes required.

Poem

🐰 A gitattributes file hops into place, With LF endings across the codebase, No more carriage returns to confound, All systems now on common ground, Consistency found, the end of the race! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately describes the main change: adding a .gitattributes file to enforce LF line endings on text files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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

coderabbitai[bot] avatar Nov 14 '25 12:11 coderabbitai[bot]

Sorry for the doubling of PRs, completely screwed up the commit history on the last one (#9349) 😅

Guiorgy avatar Nov 14 '25 12:11 Guiorgy

Hi @Guiorgy, which ticket is associated with this PR?

khushboovashi avatar Nov 18 '25 11:11 khushboovashi

Hi @Guiorgy, which ticket is associated with this PR?

There isn't a dedicated GitHub issue, as far as I am aware. A comment under an unrelated issue mentioned them being unable to build a working image under Windows, which I have run into multiple times in other projects, hence this PR.

Guiorgy avatar Nov 18 '25 12:11 Guiorgy

@khushboovashi BTW, this is unrelated, just an FYI, in commit 57f88cf you added apt update to the build.sh script, yet on the same day in commit c03b550 it was removed by someone else. The later commit message/description had nothing explaining the removal, so maybe it wasn't intentional?

I was about to revert that patch as our build machines were failing due to that change.

Guiorgy avatar Nov 19 '25 09:11 Guiorgy

Technically, if the whole team is using Linux, Unix. OSX, or Windows with differently configured git, this isn't an issue to you all, but this would help those that want to contribute, especially on the Docker side, that are using Windows with git configured to "fix" line endings.

Building an image without this patch on my Windows machine:

> git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

> docker build --tag "pgadmin4:crlf" .
...
=> exporting to image                                                                            10.0s
 => => exporting layers                                                                           10.0s
 => => writing image sha256:5ba4ccc73836adf9922d29d9d2a73e2d21eaa451c57dc5478697e3c311e0e6f4       0.0s
 => => naming to docker.io/library/pgadmin4:crlf                                                    0.0s
 
> docker run --rm -p 8080:80 -e [email protected] -e PGADMIN_DEFAULT_PASSWORD=admin pgadmin4:crlf
': No such file or directory

The image fails to run, and with a very non-descriptive error at that.

Guiorgy avatar Nov 20 '25 15:11 Guiorgy