diff --git a/automation/run-e2e/lib/ci.mjs b/automation/run-e2e/lib/ci.mjs index a3161b6532..7c8c97e03b 100644 --- a/automation/run-e2e/lib/ci.mjs +++ b/automation/run-e2e/lib/ci.mjs @@ -1,8 +1,8 @@ import c from "ansi-colors"; import findFreePort from "find-free-port"; -import nodeIp from "ip"; import { execSync } from "node:child_process"; import { createServer } from "node:net"; +import { networkInterfaces } from "node:os"; import { fileURLToPath } from "node:url"; import p from "node:path"; import sh from "shelljs"; @@ -34,6 +34,13 @@ const HOST_NETWORK = ["1", "true"].includes(String(process.env.E2E_HOST_NETWORK) const HOST_NETWORK_RUNTIME_PORT = 8080; const HOST_NETWORK_ADMIN_PORT = 8090; +// First external IPv4 address of this machine, so containers can reach the host. +function getHostIpAddress() { + return Object.values(networkInterfaces()) + .flat() + .find(iface => iface?.family === "IPv4" && !iface.internal)?.address; +} + export async function ci() { console.log(c.cyan("Run e2e tests in CI environment")); @@ -64,7 +71,7 @@ export async function ci() { ip = "127.0.0.1"; } else { freePort = await findFreePort(3000); - ip = nodeIp.address(); + ip = getHostIpAddress(); } if (!ip) { diff --git a/automation/run-e2e/package.json b/automation/run-e2e/package.json index 1a329df1f9..cca12887a6 100644 --- a/automation/run-e2e/package.json +++ b/automation/run-e2e/package.json @@ -27,7 +27,6 @@ "cross-zip": "^4.0.1", "enquirer": "^2.4.1", "find-free-port": "^2.0.0", - "ip": "^2.0.1", "node-fetch": "^3.3.2", "shelljs": "^0.10.0", "yargs-parser": "^22.0.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5bab1b34c..419e59d02e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -113,9 +113,6 @@ importers: find-free-port: specifier: ^2.0.0 version: 2.0.0 - ip: - specifier: ^2.0.1 - version: 2.0.1 node-fetch: specifier: ^3.3.2 version: 3.3.2 @@ -8293,9 +8290,6 @@ packages: resolution: {integrity: sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==} engines: {node: '>= 12'} - ip@2.0.1: - resolution: {integrity: sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==} - ipaddr.js@1.9.1: resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} engines: {node: '>= 0.10'} @@ -17254,8 +17248,6 @@ snapshots: ip-address@10.7.6: {} - ip@2.0.1: {} - ipaddr.js@1.9.1: {} is-arguments@1.2.0: