Docker + Webpack (Dev Server) + Yarnpkg incomplete builds
It could be possible that your locally installed packages differ from the packages in the docker container.
To be sure that you have the same packages installed, you should include yarn.lock
and package.lock
files. If you only use yarn yarn.lock
should suffice. Even if this does not solve your specific problem, it can prevent others, because now you have a deterministic build.
Long shot here, but I was trying to run a grails-vue app in docker containers and had issues with the port mappings of webpack-dev-server not being exposed properly.
I found this issue on github https://github.com/webpack/webpack-dev-server/issues/547 which led to me adding --host 0.0.0.0 to my dev task in package.json like so:
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --host 0.0.0.0"
This solved my problem, maybe this will help you find your answer.
It's been a while, but coming back to this problem, I found the actual answer.
The webpack-dev-server
uses two ports. Thus, in exposing only the one port (3000) I was not getting the built files, which are served in client.js
on localhost:3001
. The clue was right there the whole time in the JS console: a connection refused error on GET localhost:3001/client.js
.
The solution is to expose both ports on the container, i.e.
docker run -it -p 3000:3000 -p 3001:3001 --rm --entrypoint "npm run env:dev -- webpack-dev-server" ${CONTAINER_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}