Skip to content

Instantly share code, notes, and snippets.

@josefsabl
Last active March 17, 2022 13:05
Show Gist options
  • Save josefsabl/da4f953033c321a2ec0523ae31329d4a to your computer and use it in GitHub Desktop.
Save josefsabl/da4f953033c321a2ec0523ae31329d4a to your computer and use it in GitHub Desktop.
Webpack Watch using Docker Node image cannot be stopped (or crashes in Alpine flavored image)

SOLVED:

Run using this format:

docker run --rm -u 1000:1000 -v "${PWD}":/usr/src/app -w /usr/src/app node:17 npm run watch

To reproduce the problem:

docker run --rm -u 1000:1000 -v "${PWD}":/usr/src/app -w /usr/src/app node:17 /bin/sh -c "npm install"
docker run --rm -u 1000:1000 -v "${PWD}":/usr/src/app -w /usr/src/app node:17 /bin/sh -c "npm run watch"

Webpack starts up, watcher is working, pressing ctrl+C does not quit the watcher.

docker run --rm -u 1000:1000 -v "${PWD}":/usr/src/app -w /usr/src/app node:17 /bin/sh -c "npm install"
docker run --rm -u 1000:1000 -v "${PWD}":/usr/src/app -w /usr/src/app node:17-alpine /bin/sh -c "npm run watch"

Webpack starts up, watcher is working, pressing ctrl+C terminates the watcher with such error:

npm ERR! path /usr/src/app
npm ERR! command failed
npm ERR! signal SIGINT
npm ERR! command sh -c webpack --config webpack-config.js --watch

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/node/.npm/_logs/2022-03-17T12_29_57_811Z-debug-0.log
console.log('FooBar')
{
"name": "webpack-poc",
"description": "webpack-poc",
"author": "",
"scripts": {
"watch": "webpack --config webpack-config.js --watch"
},
"main": "index.js",
"devDependencies": {
"webpack-cli": "4.9.2",
"webpack": "5.70.0"
},
"license": "proprietary"
}
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, "entry.js"),
output: {
path: path.resolve(__dirname, 'build'),
},
watchOptions: {
},
mode: "production",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment