I have an Angular 5.2 application running in a Docker container, and for development purposes, I use the Angular CLI ng-serveto service an application that automatically reloads changes. My original work team serves;
ng serve --host 0.0.0.0 --port 80 --disable-host-check
This works great and I can access the hosted application from the host machine as expected.
To the above, thanks to various sources, I added a flag --poll 1000that tells the CLI to poll files for changes every 1000 ms, without which it never detects changes and, therefore, never recompiles or updates. My problem is that there is a delay of up to 15-20 seconds between the modified file and the change found in the docker container that initiates the rebuild. I confirmed that the file changes were transferred to the container, since I can save the catedited file in the container immediately and see the changes. I can change the polling timeout to 1 ms and this will reduce the delay to a few seconds, but this is obviously not perfect, and the delay is still significant.
Why does such a delay exist?
- OSX Version : 10.11.6
- Docker: 18.04.0-ce, build 3d479c0
- : 0.14.0, build 89b8332
- Docker Compose: 1.21.0
// docker-compose.yml
web-client:
build:
context: ../web-client/
dockerfile: ./docker/Dockerfile
ports:
- "80:80"
volumes:
- ../web-client/:/var/www/web-client
container_name: web-client
// Dockerfile
FROM node:9.11
COPY ./ /var/www/web-client
ENTRYPOINT ["/var/www/web-client/docker/entrypoint.sh"]
// entrypoint.sh
#!/usr/bin/env bash
cd /var/www/web-client
yarn run start
// package.json
"scripts": {
...
"start": "ng serve --host 0.0.0.0 --port 80 --poll 1 --disable-host-check",
...
}