In a docker-compose I have two services that share the same mapped volume from the host. The mapped volume is the application source files located in the host. When the source files are changed in the host, HMR is not triggered, including a manual refresh does not show the latest changes. Although, if editing the file directly in the container, the HMR reloads and displays the changes. Finally, the changes are visible from the host - meaning that the mapped volume is correct and pointing to the correct place. The question is why isn't the webpack-dev-server watcher picking up the changes? How to debut this? What solutions are there?
The docker-compose services in question:
node_dev_worker:
build:
context: .
dockerfile: ./.docker/dockerFiles/node.yml
image: foobar/node_dev:latest
container_name: node_dev_worker
working_dir: /home/node/app
environment:
- NODE_ENV=development
volumes:
- ./foobar-blog-ui/:/home/node/app
networks:
- foobar-wordpress-network
node_dev:
image: foobar/node_dev:latest
container_name: node_dev
working_dir: /home/node/app
ports:
- 8000:8000
- 9000:9000
environment:
- NODE_ENV=development
volumes:
- ./foobar-blog-ui/:/home/node/app
- ./.docker/scripts/wait-for-it.sh:/home/node/wait-for-it.sh
command: /bin/bash -c '/home/node/wait-for-it.sh wordpress-reverse-proxy:80 -t 10 -- npm run start'
depends_on:
- node_dev_worker
- mysql
- wordpress
networks:
- foobar-wordpress-network
The node.yml:
FROM node:8.16.0-slim
WORKDIR /home/node/app
RUN apt-get update
RUN apt-get install -y rsync vim git libpng-dev libjpeg-dev libxi6 build-essential libgl1-mesa-glx
CMD npm install
The Webpack dev server configuration follows some recommendations found online, for container issues, such as the one I'm presenting. The webpack configuration is placed in a middleware provided by Gatsbyjs called gatsby-node.js, as follow:
devServer: {
port: 8000,
disableHostCheck: true,
watchOptions: {
poll: true,
aggregateTimeout: 500
}
}
The Linux distro is (Docker image called node:8.16.0-slim
):
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
Also, the browser does show that [HMR] is connected and listening. As follows:
[HMR] connected
[HMR] bundle rebuilt in 32899ms
The host in question is Macos 10.14.6 Mojave. Running Docker 2.1.0.2
Any hints on how to debug this issue?