[英]React App doesn't refresh on changes using Docker-Compose
考虑 Docker 组成
version: '3'
services:
frontend:
build:
context: ./frontend
container_name: frontend
command: npm start
stdin_open: true
tty: true
volumes:
- ./frontend:/usr/app
ports:
- "3000:3000"
backend:
build:
context: ./backend
container_name: backend
command: npm start
environment:
- PORT=3001
- MONGO_URL=mongodb://api_mongo:27017
volumes:
- ./backend/src:/usr/app/src
ports:
- "3001:3001"
api_mongo:
image: mongo:latest
container_name: api_mongo
volumes:
- mongodb_api:/data/db
ports:
- "27017:27017"
volumes:
mongodb_api:
还有反应 Dockerfile:
FROM node:14.10.1-alpine3.12
WORKDIR /usr/app
COPY package.json .
RUN npm i
COPY . .
文件夹结构:-frontend -backend -docker-compose.yml
在前端内部:
在 src 里面:
当我在src
中更改文件时,它不会反映在 Docker 端。
我们如何解决这个问题?
这是答案:
If you are running on Windows, please read this: Create-React-App has some issues detecting when files get changed on Windows based machines. To fix this, please do the following:
1)In the root project directory, create a file called .env
2)Add the following text to the file and save it: CHOKIDAR_USEPOLLING=true
3)That's all!
取自这里: https://github.com/StephenGrider/docker-react/issues/3#issuecomment-508946730
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.