Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker/entrypoint.sh line endings can be implicitly converted to CRLF by Git, breaking execution in Alpine. #1171

Closed
1 task done
alilleybrinker opened this issue Jan 11, 2024 · 2 comments

Comments

@alilleybrinker
Copy link

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Checked the FAQs on the message board for common solutions: (TBD)
    • Checked that your issue isn't already filed.

Description

The docker/entrypoint.sh script gets run in an Alpine Linux container, where it is expected to have Linux line endings (just a line-feed). It will produce an error about incorrect syntax when /bin/sh tries to run it if the line endings are Windows line-endings.

Unfortunately, Git can be (and commonly is) configured to "correct" line endings in checked out files to those used by the local system (in my case, Windows). When I checked out this repo, the entrypoint.sh script had its line endings changed to Windows' CRLF (carriage-return and line-feed), giving me syntax errors when Alpine tries to run the script (which gets copied into the container as defined by the dev Dockerfile).

Steps to Reproduce

The quickest response will be spurred by providing a Postman json file with the exact request or progression of requests that cause the issue.

If a Postman file cannot be provided:

  1. Be on Windows
  2. Have a Git install configured to change line endings to CRLF
  3. Clone the `cve-services` repository
  4. Follow the docker/README.md instructions for instantiating a local dev instance of cve-services
  5. Observe a /bin/sh syntax error (my apologies, I didn't capture the exact error message before fixing it myself locally).

Expected behavior:

Be able to run entrypoint.sh in Alpine without syntax errors.

Actual behavior:

/bin/sh in Alpine reports syntax errors for entrypoint.sh, causing container startup to fail.

Reproduces how often:

100% of the time on Windows when the repository was checked out with a Git config that replaces line endings with Windows line endings.

Versions

I've only tried to current instance of the repo.

Additional Information

You can use Git attributes to fix this, by specifying with them that the entrypoint.sh file should never have its line endings changed during Git checkout. See the Git docs for more info: https://git-scm.com/docs/gitattributes#_eol

@david-rocca
Copy link
Collaborator

Hey @alilleybrinker, Did you see this on the test branch?

We have a pr merged (that has not made it into prod yet) that fixes this from a few months ago: #1090

@alilleybrinker
Copy link
Author

Strange, I saw this on the dev branch. Now I'm wondering if something else changed my line endings (VS Code maybe?). At any rate, I think this can be closed!

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

No branches or pull requests

2 participants