Skip to content

Conversation

@Guiorgy
Copy link
Contributor

@Guiorgy Guiorgy commented Nov 14, 2025

Depending on how git is configured on Windows (for example mine), 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 if it has CRLF line endings.

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 by executing git rm --cached -r . && git reset --hard HEAD to force git to apply the rules, since they are applied lazily when a file is modified):

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.

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
@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.gitattributes (1)

2-2: Consider adding explicit binary file markers for extra safety.

While text=auto should adequately identify binary files, you might consider adding explicit patterns (e.g., *.png binary, *.exe binary, *.jpg binary) for certain high-risk binary formats. This is a common best practice to prevent accidental normalization of non-text files.

For example:

# Auto detect text files and normalize end of lines to LF (\n)
* text=auto eol=lf

# Explicitly mark common binary files
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.exe binary

That said, many projects successfully use * text=auto eol=lf without explicit markers, so this is optional.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39c2f39 and 0d14c2c.

📒 Files selected for processing (1)
  • .gitattributes (1 hunks)
🔇 Additional comments (1)
.gitattributes (1)

1-2: Correct approach to enforce LF line endings across platforms.

The .gitattributes rule correctly leverages Git's auto-detection and line-ending normalization to ensure text files consistently use LF, which solves the stated problem of Docker containers failing on Windows due to CRLF line endings.

@Guiorgy
Copy link
Contributor Author

Guiorgy commented Nov 14, 2025

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

@khushboovashi
Copy link
Contributor

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

@Guiorgy
Copy link
Contributor Author

Guiorgy commented Nov 18, 2025

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
Copy link
Contributor Author

Guiorgy commented Nov 19, 2025

@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
Copy link
Contributor Author

Guiorgy commented Nov 20, 2025

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.

@khushboovashi khushboovashi merged commit 6d01a24 into pgadmin-org:master Nov 21, 2025
37 checks passed
@Guiorgy Guiorgy deleted the line-ending branch November 21, 2025 06:57
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.

2 participants