I'm trying to dockerize a basic CRA template created through npx create-react-app project-name
, of which Dockerfile
would look like:
FROM node:latest
WORKDIR /usr/src/client
COPY ./ ./
RUN npm install
EXPOSE 3000
CMD ["npm", "start"]
I've built the image by running docker build -t containername .
and then run it with docker run -it -p 3000:3000 containername
Everything works fine, the container runs successfully and I can see the webpage running on the browser.
Problem here is webpack hot reloading not working, causing the app to not recompile upon changes.
Same question was posed already here and here but sadly with unsuccessful results. Problem seems to appear for Windows users, but in my case I'm on Mac.
I've tried already:
- Updating
npm start
script with CHOKIDAR_USEPOLLING=true react-scripts start
- Adding
EXPOSE 35729
as explained here
Any suggestion is highly appreciated, thank you in advance!
question from:
https://stackoverflow.com/questions/65848833/dockerized-react-app-not-recompiling-code 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…