Creé una aplicación Reactjs con la configuración de Docker. Estoy usando Windows 10. Después de compilar, el contenedor sigue reiniciando y produce errores en los registros:
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.shdocker-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 fiIntenté reiniciarlo, eliminé el contenedor, volví a clonar el repositorio, pero el problema sigue ocurriendo.
Cloné el repositorio en Ubuntu usando otra computadora portátil, ninguno de estos errores ocurre, solo en Windows. Si alguien tiene alguna idea de lo que esto significa, sería de gran ayuda.
Resolví este problema según el comentario de @HansKilian sobre los finales de línea. Seguí este enlace sobre cómo convertir el archivo bootup.sh con los finales de línea de estilo UNIX adecuados: https://support.nesi.org.nz/hc/en-gb/articles/218032857-Converting-from-Windows-style -a-finales-de-línea-estilo-UNIX