Skip to content

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

@alilleybrinker

Description

@alilleybrinker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions