I created a Reactjs application with Docker setup. I am using Windows 10. After building, the container just keeps restarting producing errors on logs:
yarn run v1.22.5
error Command "install\r" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
: not foundotup.sh: line 3:
/var/www/bootup.sh: line 11: syntax error: unexpected end of file (expecting "then")
Dockerfile
# pull official base image
FROM node:12.20.0-alpine3.10
WORKDIR /var/www
COPY package.json /var/www/
RUN yarn install
COPY . /var/www/
# Install create-react-app package
RUN yarn global add react-scripts
EXPOSE 3000
ADD ./bootup.sh /var/www
RUN cd /var/www
RUN chmod +x /var/www/bootup.sh
docker-compose.yml
version: '3.7'
services:
frontend:
build: .
restart: unless-stopped
tty: true
working_dir: /var/www/
ports:
- '3002:3000'
volumes:
- '.:/var/www'
- /var/www/node_modules
environment:
- CHOKIDAR_USEPOLLING=true yarn start
command: /var/www/bootup.sh ${SSL_ON}
bootup.sh
# Install Dependencies
yarn install
# Start the react app
if [ "$1" == "true" ]
then
yarn start-https
else
yarn start
fi
I tried restarting it, killing the container, cloned the repository again, but the issue is still occurring.
I cloned the repo in Ubuntu using another laptop, none of these errors occur, only on windows. If anyone has any idea what this means, it would be a great help.
I resolved this issue based on @HansKilian comment about line-endings. I followed this link on how to convert bootup.sh
file with the proper UNIX-style line endings: https://support.nesi.org.nz/hc/en-gb/articles/218032857-Converting-from-Windows-style-to-UNIX-style-line-endings