'Docker not detect changes with ReactJS
I am running Docker on Windows 11. I have four services:
- NestJS (Backend)
- ReactJS (Frontend)
- Postgres (DB)
- PGAdmin (DB Manager)
My backend detect changes correctly, but my frontend not detect changes.
docker-compose.yml
version: "3.8"
services:
nginx:
container_name: fortunesp_nginx
image: nginx:latest
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
command: /bin/sh -c "nginx -g 'daemon off;'"
networks:
- shared-network
app-prod:
container_name: fortunesp_frontend
image: fortunesp_frontend:1.0.0
build:
context: client
dockerfile: Dockerfile
depends_on:
- api-prod
environment:
CHOKIDAR_USEPOLLING: "true"
ports:
- "3000:3000"
networks:
- shared-network
volumes:
- /usr/src/app/node_modules
- ./client:/usr/src/app
api-prod:
container_name: fortunesp_backend
image: fortunesp_backend:1.0.0
build:
context: server
dockerfile: Dockerfile
command: bash -c 'while !</dev/tcp/postgres/5432; do sleep 1; done; npm run start:dev'
depends_on:
- postgres
environment:
CHOKIDAR_USEPOLLING: "true"
ports:
- "9000:9000"
networks:
- shared-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "http://api-prod:9000"]
interval: 5s
timeout: 15s
retries: 6
volumes:
- ./server:/usr/src/api
- /usr/src/api/node_modules/bcrypt/
pgadmin:
container_name: fortunesp_pgadmin
image: dpage/pgadmin4
environment:
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=123456
ports:
- "5050:80"
networks:
- shared-network
postgres:
container_name: fortunesp_postgres
image: postgres:13
environment:
- POSTGRES_DB=fortunesp
- POSTGRES_USER=root
- POSTGRES_PASSWORD=123456
ports:
- '5432:5432'
volumes:
- ./postgres:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER $$POSTGRES_DB" ]
interval: 5s
timeout: 5s
retries: 5
networks:
- shared-network
networks:
shared-network:
volumes:
postgres: {}
Dockerfile (client)
FROM node:14
WORKDIR /usr/src/app
COPY package.json .
COPY package-lock.json .
ENV NODE_PATH=/node_modules
ENV PATH=$PATH:/node_modules/.bin
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
I can't find the problem. Another thing I tried was to verify that in docker my file is being modified, and its correct, my file is modified successfully. The problem is that my console does not compile again when I modify my files.
I am using react app create. Docker Desktop 4.6.0. Windows 11 Pro.
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
