From a336dbc5171d5c0caee1225f3fd5da72cb3b3154 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 3 Jul 2024 11:13:10 +0000 Subject: [PATCH] Fix demo development inside a dev container --- .devcontainer/devcontainer.json | 1 + build-scripts/env.cjs | 3 +++ build-scripts/gulp/webpack.js | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) 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,