0

We have a Docker project that is shared by developers using Windows, Mac or Linux.

Unfortunately we can't control the way the project is cloned, so Windows developers might end up with bad line-endings when building the Docker image and the build could fail because of that.

To fix this issue, we added a line to our Dockerfile to replace all Windows line endings with Unix line endings before the build process is started:

ADD . /app
RUN find . -type f -exec sed -i 's/\x0d//g' {} \+

But the problem is, the build is now much slower, even on Linux and Mac boxes.

I would like to RUN this command only if the build is happening on a Windows machine. But is there a way for the Dockerfile to detect that?

Saintali
  • 4,482
  • 2
  • 29
  • 49

1 Answers1

0

Can you try to replace the the "ADD ..." line by something like this:

RUN git clone <your.repo.git> src
ADD src /app

I have not tested but the files will be created by the git of your Dockerfile base image, so everyone should have the same files.

Fiber Optic
  • 184
  • 5