I have a React.js application which I have a Dockerfile and both the app and the Dockerfile worked fine until today when I tried to build the docker file and I got the exception form the title.
This exception is triggered after the npm run build command in the Dockerfile. I tried the same command locally for my project and there was no problem. It happens only in the Dockerfile when I try to build it with docker build -t image .
Here is my Dockerfile:
FROM node:16.13.0 as build
RUN apt-get update -y && apt-get install mosquitto-clients -y
# Creates scripts to publish update messages and give system permission to read it
RUN echo "mosquitto_pub -t watchtower/update/dashboard -h mosquitto -p 1883 -m "{status: checking, service: Dashboard}"" > pre-check.sh && chmod +rx pre-check.sh
RUN echo "mosquitto_pub -t watchtower/update/dashboard -h mosquitto -p 1883 -m "{status: updating, service: Dashboard}"" > pre-update.sh && chmod +rx pre-update.sh
RUN echo "mosquitto_pub -t watchtower/update/dashboard -h mosquitto -p 1883 -m "{status: updated, service: Dashboard}"" > post-update.sh && chmod +rx post-update.sh
RUN echo "mosquitto_pub -t watchtower/update/dashboard -h mosquitto -p 1883 -m "{status: checked, service: Dashboard}"" > post-check.sh && chmod +rx post-check.sh
# Connect watchtower hook to the above created script
LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="/pre-check.sh"
LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="/pre-update.sh"
LABEL com.centurylinklabs.watchtower.lifecycle.post-update="/post-update.sh"
LABEL com.centurylinklabs.watchtower.lifecycle.post-check="/post-check.sh"
RUN mkdir /app
WORKDIR /app
COPY /front-end/package.json /app
RUN npm install
COPY ./front-end/ /app
RUN npm run build
# Install `serve` to run the application.
RUN npm install -g serve
# Set the command to start the node server.
CMD serve -s build
# Tell Docker about the port we'll run on.
EXPOSE 5000
Any idea how to resolve that issue? Thanks in advance.