I have two services: front (product-list) and backend (server-api).
I've created a docker-compose file and it works fine:
version: '3.1'
services:
server-api:
build: ./server-api
ports:
- "8080:8080"
product-list:
build: ./product-list
environment:
CHOKIDAR_USEPOLLING: "true"
ports:
- "3000:3000"
depends_on:
- server-api
But I have a problem: the app doesnt reload after a change.
I have read about this, and a lot of people says that CHOKIDAR_USEPOLLING: "true" should works.
It doesnt for me.
I would like to know if is a volume problem (I dont have very clear how they work right now or what volume should I create), or if maybe I should install something to watch the files.
This is the Dockerfile that I have in my frontend app:
FROM node:14-alpine AS development
ENV NODE_ENV development
WORKDIR /app
COPY package.json .
COPY package-lock.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
And right now I just use docker-compose up to launch the app.
I just need to know about what happend with my react app and why it doesnt reload, backend service (server-api) works fine and I dont need hot reload in that app.
Any help is thankful.
For the changes to get into container, you need to mount the project as volume. In the current configuration, changes to the project will fall into container only after rebuilding the image.
As example:
product-list:
build: ./product-list
environment:
CHOKIDAR_USEPOLLING: "true"
ports:
- "3000:3000"
depends_on:
- server-api
volumes:
- ".:/app"