I'm running a Rails backend with Angular front end inside of a Docker image. The host machine is running OSX.
The services come up fine when I run docker-compose up --build
but any changes to the front end files take nearly an hour to trigger a hot reload.
If I run the build process manually in a bash session for the ng container,
(ng build --aot
), it takes about 2 minutes. Not optimal, but better than an hour. That same build process takes way longer when it's part of a hot reload. I'm not sure why.
I tried the solution mentioned here, about opening up the port for webpack hot reloads and adding the port number inside docker-compose.yml
but I saw no difference in behavior.
The Rails part of this works fine. Changing a file is almost immediately noticed in the container.
But things aren't as snappy for the ng container. The node_modules directory is excluded from my Docker image, so when Docker builds, it populates its own node_modules directory inside the image. That should mean that there are no issues syncing node modules on the host machine with what's in the image.
I've done some research and it looks like there's an option to run ng eject
, which would enable me to customize the webpack config. There are a few suggestions about modifying the config to speed things up, e.g. this one. However, given that the eject option isn't supported in ng 6, I'd prefer not to go down this road.
Any ideas on how I can speed up the compilation time for this ng app?