I'm trying to run my react application using the build folder via docker file.
Everything seems to run properly when tried without docker, but when i run using the docker file build folder gets created but serve -s build command is not working inside the docker image. Below is my dockerfile.
FROM node:carbon
# Create app directory
WORKDIR /usr/src/docker-react-sample
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
COPY package-lock.json ./
RUN npm install
#To bundle your app’s source code inside the Docker image, use the COPY instruction:
COPY . .
# Build for production.
RUN npm run build
# Install `serve` to run the application.
RUN npm install -g serve
# Uses port which is used by the actual application
EXPOSE 3000
# Run application
#CMD [ "npm", "start" ]
CMD serve -s build
Below is the error i get when i run it with docker
/usr/local/lib/node_modules/serve/node_modules/camelcase/index.js:3
const UPPERCASE = /[\p{Lu}]/u;
^
SyntaxError: Invalid regular expression: /[\p{Lu}]/: Invalid escape
at Object.<anonymous> (/usr/local/lib/node_modules/serve/node_modules/camelcase/index.js:3:19)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/serve/node_modules/boxen/index.js:6:19)
at Module._compile (module.js:653:30)
But instead of "serve -s build" if i use CMD [ "npm", "start" ] it work properly.
Any help provided would be helpful.