I am working on setting up a React project in docker. The project runs fully well in my local environment, but when I try build it using Docker, I run into some build issue
Step 7/7 : RUN npm run build
---> Running in 31be0cd260c7
> educollect@0.1.0 build /app
> react-scripts build
Creating an optimized production build...
Failed to compile.
./src/Pages/Steps.js
Cannot find file '../Components/Steppers' in './src/Pages'.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! educollect@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
Here are my files:
Dockerfile
FROM node:alpine
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json /app/package.json
RUN npm install
COPY . /app
RUN npm run build
Package.json
{
"name": "myproject",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.9.5",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.45",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.1",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"node-sass": "^4.13.1",
"prop-types": "^15.7.2",
"query-string": "^6.11.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
When I try to build it using this command:
docker build -t myproject:latest .
I run into the build. Any form of help will be highly appreciated.