0

docker-compose build --no-cache fails with this error:

 ---> Running in f62172d2e9f9
Removing intermediate container f62172d2e9f9
 ---> db5896c4aac5
Step 10/16 : COPY ./rclone/install.sh /data/rclone/
 ---> e659d60665cf
Step 11/16 : COPY ./rclone.conf /root/.config/rclone/rclone.conf
 ---> 61e3b9107870
Step 12/16 : RUN chmod +x ./rclone/install.sh
 ---> Running in 9c5eead9141b
Removing intermediate container 9c5eead9141b
 ---> 42fefac58542
Step 13/16 : RUN ./rclone/install.sh
 ---> Running in fbadefae8a57
': No such file or directory
ERROR: Service 'api' failed to build : The command '/bin/sh -c ./rclone/install.sh' returned a non-zero code: 127

Here's the Dockerfile:

FROM node:10.22-alpine3.11

RUN apk update
RUN apk add --no-cache curl
RUN apk add --no-cache bash
RUN apk add --update python make g++\
   && rm -rf /var/cache/apk/*


RUN npm install pm2 -g
RUN apk add --update python make g++\
   && rm -rf /var/cache/apk/*
RUN apk add nginx


WORKDIR /data

COPY ./rclone/install.sh /data/rclone/

COPY ./rclone.conf /root/.config/rclone/rclone.conf

RUN chmod +x ./rclone/install.sh
RUN ./rclone/install.sh

COPY . /data/project/NodeApp

RUN chmod +x /data/project/NodeApp/scripts/.supervisor.sh

CMD /data/project/NodeApp/scripts/.supervisor.sh

Any ideas as to what's causing this and how to fix it? rclone is in the root folder. I've reviewed previously answered questions about docker-compose not working, and otherwise researched this issue and haven't found much on it.

Any advice would be great! Thanks in advance.

  • According to your Dockerfile ```/data``` is the root dir – Margach Chris Jan 28 '21 at 21:59
  • @MargachChris, right, but is it not getting copied into `/data`? I'm only recently getting into bash commands. – Enrique Hilst Jan 28 '21 at 22:10
  • That odd-looking error message often suggests a file has gotten copied in with DOS line endings. Can you check that the file has Unix line endings? – David Maze Jan 28 '21 at 23:47
  • The `chmod +x ./rclone/install.sh` command succeeds, so this suggests to me that `./rclone/install.sh` is a valid path. The `No such file or directory` error might be coming from something the `install.sh` script is running. Try adding `set -x` to the start of the `install.sh` to confirm if the script is actually run, and where the script might be failing. You can also confirm the script is present by running `ls -l ./rclone/install.sh` just after your `chmod` command. – Shane Bishop Jan 29 '21 at 00:35
  • @DavidMaze The line endings are `\n` and `\r\n` – Enrique Hilst Feb 01 '21 at 20:27
  • @ShaneBishop I tried both `set -x` and `set -vx` and it returns: `./rclone/install.sh: set: line 1: illegal option -` – Enrique Hilst Feb 01 '21 at 20:38
  • If it's a Linux container, there shouldn't be any `\r` in the file at all. – David Maze Feb 01 '21 at 20:55
  • @DavidMaze it is a Linux container! Thank you for this info. How do I go about removing them? – Enrique Hilst Feb 01 '21 at 21:00
  • [Are shell scripts sensitive to encoding and line endings?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) has all kinds of suggestions. – David Maze Feb 01 '21 at 21:40

1 Answers1

0

@DavidMaze helped me figure this out. It was erroring on \r line endings because the files were converted to DOS when downloaded from GitHub. Running dos2unix fixed the problem, and we added a .gitattributes so that the line endings are no longer converted. See Are shell scripts sensitive to encoding and line endings? for more solutions.

Shane Bishop
  • 3,905
  • 4
  • 17
  • 47