diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d6033abcd080..7f8ab1df13e7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,6 +8,7 @@ "postCreateCommand": "sudo apt update && sudo apt upgrade -y && sudo apt install -y libpcap-dev", "postStartCommand": "script/bootstrap", "containerEnv": { + "DEV_CONTAINER": "1", "WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}" }, "customizations": { diff --git a/build-scripts/env.cjs b/build-scripts/env.cjs index bb0d6b3d0028..6f208b779b33 100644 --- a/build-scripts/env.cjs +++ b/build-scripts/env.cjs @@ -32,4 +32,7 @@ module.exports = { } return version[1]; }, + isDevContainer() { + return process.env.DEV_CONTAINER === "1"; + }, }; diff --git a/build-scripts/gulp/webpack.js b/build-scripts/gulp/webpack.js index 51f062f316e1..a7eb3be20d8e 100644 --- a/build-scripts/gulp/webpack.js +++ b/build-scripts/gulp/webpack.js @@ -40,8 +40,12 @@ const runDevServer = async ({ compiler, contentBase, port, - listenHost = "localhost", + listenHost = undefined, }) => { + if (listenHost === undefined) { + // For dev container, we need to listen on all hosts + listenHost = env.isDevContainer() ? "0.0.0.0" : "localhost"; + } const server = new WebpackDevServer( { hot: false,