testcontainers 12.1.0 → 12.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/build/common/file-lock.js +3 -3
  2. package/build/common/hash.js +2 -2
  3. package/build/common/index.d.ts +2 -3
  4. package/build/common/index.js +2 -4
  5. package/build/common/retry.d.ts +1 -1
  6. package/build/common/uuid.js +2 -2
  7. package/build/container-runtime/auth/auths.d.ts +2 -2
  8. package/build/container-runtime/auth/cred-helpers.d.ts +1 -1
  9. package/build/container-runtime/auth/credential-provider.d.ts +2 -2
  10. package/build/container-runtime/auth/credential-provider.js +3 -3
  11. package/build/container-runtime/auth/creds-store.d.ts +2 -2
  12. package/build/container-runtime/auth/creds-store.js +1 -1
  13. package/build/container-runtime/auth/get-auth-config.d.ts +1 -1
  14. package/build/container-runtime/auth/get-auth-config.js +7 -7
  15. package/build/container-runtime/auth/registry-auth-locator.d.ts +1 -1
  16. package/build/container-runtime/auth/registry-matches.js +1 -1
  17. package/build/container-runtime/clients/client.d.ts +5 -5
  18. package/build/container-runtime/clients/compose/compose-client.d.ts +1 -1
  19. package/build/container-runtime/clients/compose/compose-client.js +1 -3
  20. package/build/container-runtime/clients/compose/default-compose-options.d.ts +2 -2
  21. package/build/container-runtime/clients/compose/default-compose-options.js +5 -3
  22. package/build/container-runtime/clients/compose/types.d.ts +3 -2
  23. package/build/container-runtime/clients/container/container-client.d.ts +5 -4
  24. package/build/container-runtime/clients/container/docker-container-client.d.ts +6 -5
  25. package/build/container-runtime/clients/container/docker-container-client.js +13 -9
  26. package/build/container-runtime/clients/container/types.d.ts +1 -3
  27. package/build/container-runtime/clients/image/docker-image-client.d.ts +4 -3
  28. package/build/container-runtime/clients/image/docker-image-client.js +11 -10
  29. package/build/container-runtime/clients/image/image-client.d.ts +2 -2
  30. package/build/container-runtime/clients/network/docker-network-client.d.ts +3 -2
  31. package/build/container-runtime/clients/network/network-client.d.ts +1 -1
  32. package/build/container-runtime/image-name.d.ts +2 -1
  33. package/build/container-runtime/image-name.js +23 -13
  34. package/build/container-runtime/index.d.ts +1 -1
  35. package/build/container-runtime/strategies/configuration-strategy.d.ts +2 -2
  36. package/build/container-runtime/strategies/configuration-strategy.js +7 -7
  37. package/build/container-runtime/strategies/npipe-socket-strategy.d.ts +2 -2
  38. package/build/container-runtime/strategies/rootless-unix-socket-strategy.d.ts +2 -2
  39. package/build/container-runtime/strategies/rootless-unix-socket-strategy.js +9 -9
  40. package/build/container-runtime/strategies/strategy.d.ts +1 -1
  41. package/build/container-runtime/strategies/testcontainers-host-strategy.d.ts +2 -2
  42. package/build/container-runtime/strategies/testcontainers-host-strategy.js +2 -2
  43. package/build/container-runtime/strategies/types.d.ts +1 -1
  44. package/build/container-runtime/strategies/unix-socket-strategy.d.ts +2 -2
  45. package/build/container-runtime/strategies/unix-socket-strategy.js +2 -2
  46. package/build/container-runtime/strategies/utils/config.js +12 -12
  47. package/build/container-runtime/utils/attach-container.d.ts +2 -2
  48. package/build/container-runtime/utils/demux-stream.d.ts +2 -2
  49. package/build/container-runtime/utils/demux-stream.js +2 -2
  50. package/build/container-runtime/utils/image-exists.d.ts +2 -2
  51. package/build/container-runtime/utils/lookup-host-ips.d.ts +1 -1
  52. package/build/container-runtime/utils/lookup-host-ips.js +4 -4
  53. package/build/container-runtime/utils/pull-image.d.ts +2 -2
  54. package/build/container-runtime/utils/remote-container-runtime-socket-path.d.ts +1 -1
  55. package/build/container-runtime/utils/remote-container-runtime-socket-path.js +2 -2
  56. package/build/container-runtime/utils/resolve-host.d.ts +2 -2
  57. package/build/container-runtime/utils/resolve-host.js +4 -4
  58. package/build/container-runtime/utils/run-in-container.d.ts +1 -1
  59. package/build/container-runtime/utils/run-in-container.js +2 -1
  60. package/build/container-runtime/utils/start-container.d.ts +1 -1
  61. package/build/docker-compose-environment/docker-compose-environment.d.ts +5 -5
  62. package/build/docker-compose-environment/docker-compose-environment.js +18 -8
  63. package/build/docker-compose-environment/started-docker-compose-environment.d.ts +2 -2
  64. package/build/docker-compose-environment/stopped-docker-compose-environment.d.ts +1 -1
  65. package/build/generic-container/abstract-started-container.d.ts +3 -3
  66. package/build/generic-container/abstract-stopped-container.d.ts +1 -1
  67. package/build/generic-container/generic-container-builder.d.ts +3 -3
  68. package/build/generic-container/generic-container-builder.js +11 -6
  69. package/build/generic-container/generic-container.d.ts +9 -9
  70. package/build/generic-container/generic-container.js +22 -8
  71. package/build/generic-container/inspect-container-util-ports-exposed.d.ts +1 -1
  72. package/build/generic-container/inspect-container-util-ports-exposed.js +1 -1
  73. package/build/generic-container/started-generic-container.d.ts +6 -5
  74. package/build/generic-container/started-generic-container.js +19 -16
  75. package/build/generic-container/stopped-generic-container.d.ts +2 -2
  76. package/build/index.d.ts +4 -4
  77. package/build/index.js +3 -3
  78. package/build/network/network.d.ts +3 -3
  79. package/build/port-forwarder/port-forwarder.d.ts +2 -3
  80. package/build/port-forwarder/port-forwarder.js +25 -19
  81. package/build/reaper/reaper.d.ts +1 -1
  82. package/build/reaper/reaper.js +21 -19
  83. package/build/socat/socat-container.d.ts +0 -2
  84. package/build/socat/socat-container.js +0 -3
  85. package/build/test-container.d.ts +6 -6
  86. package/build/test-containers.js +2 -1
  87. package/build/types.d.ts +3 -4
  88. package/build/utils/bound-ports.d.ts +3 -3
  89. package/build/utils/bound-ports.js +2 -2
  90. package/build/utils/dockerfile-parser.d.ts +1 -1
  91. package/build/utils/dockerfile-parser.js +2 -2
  92. package/build/utils/labels.d.ts +0 -2
  93. package/build/utils/labels.js +5 -5
  94. package/build/utils/map-inspect-result.d.ts +2 -2
  95. package/build/utils/map-inspect-result.js +12 -13
  96. package/build/utils/pull-policy.d.ts +2 -1
  97. package/build/utils/pull-policy.js +9 -0
  98. package/build/version.d.ts +1 -1
  99. package/build/version.js +1 -1
  100. package/build/wait-strategies/composite-wait-strategy.d.ts +3 -3
  101. package/build/wait-strategies/composite-wait-strategy.js +3 -1
  102. package/build/wait-strategies/health-check-wait-strategy.d.ts +1 -1
  103. package/build/wait-strategies/host-port-wait-strategy.d.ts +2 -2
  104. package/build/wait-strategies/http-wait-strategy.d.ts +2 -2
  105. package/build/wait-strategies/http-wait-strategy.js +4 -7
  106. package/build/wait-strategies/log-wait-strategy.d.ts +3 -3
  107. package/build/wait-strategies/log-wait-strategy.js +1 -1
  108. package/build/wait-strategies/one-shot-startup-startegy.d.ts +2 -2
  109. package/build/wait-strategies/shell-wait-strategy.d.ts +1 -1
  110. package/build/wait-strategies/startup-check-strategy.d.ts +1 -2
  111. package/build/wait-strategies/startup-check-strategy.js +0 -3
  112. package/build/wait-strategies/utils/health-check.d.ts +2 -4
  113. package/build/wait-strategies/utils/health-check.js +4 -6
  114. package/build/wait-strategies/utils/port-check.d.ts +2 -2
  115. package/build/wait-strategies/utils/port-check.js +2 -2
  116. package/build/wait-strategies/utils/undici-response-parser.d.ts +1 -1
  117. package/build/wait-strategies/utils/undici-response-parser.js +2 -2
  118. package/build/wait-strategies/utils/wait-strategy-selector.d.ts +4 -4
  119. package/build/wait-strategies/wait-for-container.d.ts +4 -4
  120. package/build/wait-strategies/wait-strategy.d.ts +2 -2
  121. package/build/wait-strategies/wait.d.ts +3 -3
  122. package/build/wait-strategies/wait.js +1 -0
  123. package/package.json +3 -4
  124. package/build/common/streams.d.ts +0 -6
  125. package/build/common/streams.js +0 -12
@@ -1,6 +1,6 @@
1
1
  export { getAuthConfig } from "./auth/get-auth-config";
2
2
  export { ContainerRuntimeClient, getContainerRuntimeClient } from "./clients/client";
3
3
  export { parseComposeContainerName } from "./clients/compose/parse-compose-container-name";
4
- export { ComposeDownOptions, ComposeExecutableOptions, ComposeOptions } from "./clients/compose/types";
4
+ export { ComposeDownOptions, ComposeOptions } from "./clients/compose/types";
5
5
  export { HostIp } from "./clients/types";
6
6
  export { ImageName } from "./image-name";
@@ -1,5 +1,5 @@
1
- import { ContainerRuntimeClientStrategy } from "./strategy";
2
- import { ContainerRuntimeClientStrategyResult } from "./types";
1
+ import type { ContainerRuntimeClientStrategy } from "./strategy";
2
+ import type { ContainerRuntimeClientStrategyResult } from "./types";
3
3
  export declare class ConfigurationStrategy implements ContainerRuntimeClientStrategy {
4
4
  getName(): string;
5
5
  getResult(): Promise<ContainerRuntimeClientStrategyResult | undefined>;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConfigurationStrategy = void 0;
7
- const promises_1 = __importDefault(require("fs/promises"));
8
- const path_1 = __importDefault(require("path"));
9
- const url_1 = require("url");
7
+ const promises_1 = __importDefault(require("node:fs/promises"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_url_1 = require("node:url");
10
10
  const config_1 = require("./utils/config");
11
11
  class ConfigurationStrategy {
12
12
  getName() {
@@ -18,7 +18,7 @@ class ConfigurationStrategy {
18
18
  return undefined;
19
19
  }
20
20
  const dockerOptions = {};
21
- const { pathname, hostname, port } = new url_1.URL(dockerHost);
21
+ const { pathname, hostname, port } = new node_url_1.URL(dockerHost);
22
22
  if (hostname !== "") {
23
23
  dockerOptions.host = hostname;
24
24
  dockerOptions.port = port;
@@ -27,9 +27,9 @@ class ConfigurationStrategy {
27
27
  dockerOptions.socketPath = pathname;
28
28
  }
29
29
  if (dockerTlsVerify === "1" && dockerCertPath !== undefined) {
30
- dockerOptions.ca = await promises_1.default.readFile(path_1.default.resolve(dockerCertPath, "ca.pem"));
31
- dockerOptions.cert = await promises_1.default.readFile(path_1.default.resolve(dockerCertPath, "cert.pem"));
32
- dockerOptions.key = await promises_1.default.readFile(path_1.default.resolve(dockerCertPath, "key.pem"));
30
+ dockerOptions.ca = await promises_1.default.readFile(node_path_1.default.resolve(dockerCertPath, "ca.pem"));
31
+ dockerOptions.cert = await promises_1.default.readFile(node_path_1.default.resolve(dockerCertPath, "cert.pem"));
32
+ dockerOptions.key = await promises_1.default.readFile(node_path_1.default.resolve(dockerCertPath, "key.pem"));
33
33
  }
34
34
  return {
35
35
  uri: dockerHost,
@@ -1,5 +1,5 @@
1
- import { ContainerRuntimeClientStrategy } from "./strategy";
2
- import { ContainerRuntimeClientStrategyResult } from "./types";
1
+ import type { ContainerRuntimeClientStrategy } from "./strategy";
2
+ import type { ContainerRuntimeClientStrategyResult } from "./types";
3
3
  export declare class NpipeSocketStrategy implements ContainerRuntimeClientStrategy {
4
4
  private readonly platform;
5
5
  constructor(platform?: NodeJS.Platform);
@@ -1,5 +1,5 @@
1
- import { ContainerRuntimeClientStrategy } from "./strategy";
2
- import { ContainerRuntimeClientStrategyResult } from "./types";
1
+ import type { ContainerRuntimeClientStrategy } from "./strategy";
2
+ import type { ContainerRuntimeClientStrategyResult } from "./types";
3
3
  export declare class RootlessUnixSocketStrategy implements ContainerRuntimeClientStrategy {
4
4
  private readonly platform;
5
5
  private readonly env;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RootlessUnixSocketStrategy = void 0;
7
- const fs_1 = require("fs");
8
- const os_1 = __importDefault(require("os"));
9
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = require("node:fs");
8
+ const node_os_1 = __importDefault(require("node:os"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
10
  const common_1 = require("../../common");
11
11
  class RootlessUnixSocketStrategy {
12
12
  platform;
@@ -29,7 +29,7 @@ class RootlessUnixSocketStrategy {
29
29
  this.getSocketPathFromRunDir(),
30
30
  ]
31
31
  .filter(common_1.isDefined)
32
- .find((candidateSocketPath) => (0, fs_1.existsSync)(candidateSocketPath));
32
+ .find((candidateSocketPath) => (0, node_fs_1.existsSync)(candidateSocketPath));
33
33
  if (!socketPath) {
34
34
  return;
35
35
  }
@@ -41,22 +41,22 @@ class RootlessUnixSocketStrategy {
41
41
  };
42
42
  }
43
43
  getSocketPathFromEnv() {
44
- const xdgRuntimeDir = this.env["XDG_RUNTIME_DIR"];
44
+ const xdgRuntimeDir = this.env.XDG_RUNTIME_DIR;
45
45
  if (xdgRuntimeDir !== undefined) {
46
- return path_1.default.join(xdgRuntimeDir, "docker.sock");
46
+ return node_path_1.default.join(xdgRuntimeDir, "docker.sock");
47
47
  }
48
48
  else {
49
49
  return undefined;
50
50
  }
51
51
  }
52
52
  getSocketPathFromHomeRunDir() {
53
- return path_1.default.join(os_1.default.homedir(), ".docker", "run", "docker.sock");
53
+ return node_path_1.default.join(node_os_1.default.homedir(), ".docker", "run", "docker.sock");
54
54
  }
55
55
  getSocketPathFromHomeDesktopDir() {
56
- return path_1.default.join(os_1.default.homedir(), ".docker", "desktop", "docker.sock");
56
+ return node_path_1.default.join(node_os_1.default.homedir(), ".docker", "desktop", "docker.sock");
57
57
  }
58
58
  getSocketPathFromRunDir() {
59
- return path_1.default.join("/run", "user", `${os_1.default.userInfo().uid}`, "docker.sock");
59
+ return node_path_1.default.join("/run", "user", `${node_os_1.default.userInfo().uid}`, "docker.sock");
60
60
  }
61
61
  }
62
62
  exports.RootlessUnixSocketStrategy = RootlessUnixSocketStrategy;
@@ -1,4 +1,4 @@
1
- import { ContainerRuntimeClientStrategyResult } from "./types";
1
+ import type { ContainerRuntimeClientStrategyResult } from "./types";
2
2
  export interface ContainerRuntimeClientStrategy {
3
3
  getName(): string;
4
4
  getResult(): Promise<ContainerRuntimeClientStrategyResult | undefined>;
@@ -1,5 +1,5 @@
1
- import { ContainerRuntimeClientStrategy } from "./strategy";
2
- import { ContainerRuntimeClientStrategyResult } from "./types";
1
+ import type { ContainerRuntimeClientStrategy } from "./strategy";
2
+ import type { ContainerRuntimeClientStrategyResult } from "./types";
3
3
  export declare class TestcontainersHostStrategy implements ContainerRuntimeClientStrategy {
4
4
  getName(): string;
5
5
  getResult(): Promise<ContainerRuntimeClientStrategyResult | undefined>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TestcontainersHostStrategy = void 0;
4
- const url_1 = require("url");
4
+ const node_url_1 = require("node:url");
5
5
  const config_1 = require("./utils/config");
6
6
  class TestcontainersHostStrategy {
7
7
  getName() {
@@ -13,7 +13,7 @@ class TestcontainersHostStrategy {
13
13
  return;
14
14
  }
15
15
  const dockerOptions = {};
16
- const { hostname, port } = new url_1.URL(tcHost);
16
+ const { hostname, port } = new node_url_1.URL(tcHost);
17
17
  dockerOptions.host = hostname;
18
18
  dockerOptions.port = port;
19
19
  return {
@@ -1,4 +1,4 @@
1
- import { DockerOptions } from "dockerode";
1
+ import type { DockerOptions } from "dockerode";
2
2
  export type ContainerRuntimeClientStrategyResult = {
3
3
  uri: string;
4
4
  dockerOptions: DockerOptions;
@@ -1,5 +1,5 @@
1
- import { ContainerRuntimeClientStrategy } from "./strategy";
2
- import { ContainerRuntimeClientStrategyResult } from "./types";
1
+ import type { ContainerRuntimeClientStrategy } from "./strategy";
2
+ import type { ContainerRuntimeClientStrategyResult } from "./types";
3
3
  export declare class UnixSocketStrategy implements ContainerRuntimeClientStrategy {
4
4
  private readonly platform;
5
5
  constructor(platform?: NodeJS.Platform);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnixSocketStrategy = void 0;
4
- const fs_1 = require("fs");
4
+ const node_fs_1 = require("node:fs");
5
5
  class UnixSocketStrategy {
6
6
  platform;
7
7
  constructor(platform = process.platform) {
@@ -11,7 +11,7 @@ class UnixSocketStrategy {
11
11
  return "UnixSocketStrategy";
12
12
  }
13
13
  async getResult() {
14
- if ((this.platform !== "linux" && this.platform !== "darwin") || !(0, fs_1.existsSync)("/var/run/docker.sock")) {
14
+ if ((this.platform !== "linux" && this.platform !== "darwin") || !(0, node_fs_1.existsSync)("/var/run/docker.sock")) {
15
15
  return;
16
16
  }
17
17
  return {
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getContainerRuntimeConfig = void 0;
7
- const fs_1 = require("fs");
8
- const promises_1 = require("fs/promises");
9
- const os_1 = require("os");
10
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = require("node:fs");
8
+ const promises_1 = require("node:fs/promises");
9
+ const node_os_1 = require("node:os");
10
+ const node_path_1 = __importDefault(require("node:path"));
11
11
  const properties_reader_1 = __importDefault(require("properties-reader"));
12
12
  const common_1 = require("../../../common");
13
13
  let containerRuntimeConfig;
@@ -23,9 +23,9 @@ const getContainerRuntimeConfig = async (env = process.env) => {
23
23
  };
24
24
  exports.getContainerRuntimeConfig = getContainerRuntimeConfig;
25
25
  async function loadFromFile() {
26
- const file = path_1.default.resolve((0, os_1.homedir)(), ".testcontainers.properties");
26
+ const file = node_path_1.default.resolve((0, node_os_1.homedir)(), ".testcontainers.properties");
27
27
  const dockerClientConfig = {};
28
- if ((0, fs_1.existsSync)(file)) {
28
+ if ((0, node_fs_1.existsSync)(file)) {
29
29
  common_1.log.debug(`Loading ".testcontainers.properties" file...`);
30
30
  const string = await (0, promises_1.readFile)(file, { encoding: "utf-8" });
31
31
  const properties = (0, properties_reader_1.default)({ sourceFile: "" }).read(string);
@@ -51,14 +51,14 @@ async function loadFromFile() {
51
51
  }
52
52
  function loadFromEnv(env) {
53
53
  const dockerClientConfig = {};
54
- if (env["DOCKER_HOST"] !== undefined) {
55
- dockerClientConfig.dockerHost = env["DOCKER_HOST"];
54
+ if (env.DOCKER_HOST !== undefined) {
55
+ dockerClientConfig.dockerHost = env.DOCKER_HOST;
56
56
  }
57
- if (env["DOCKER_TLS_VERIFY"] !== undefined) {
58
- dockerClientConfig.dockerTlsVerify = env["DOCKER_TLS_VERIFY"];
57
+ if (env.DOCKER_TLS_VERIFY !== undefined) {
58
+ dockerClientConfig.dockerTlsVerify = env.DOCKER_TLS_VERIFY;
59
59
  }
60
- if (env["DOCKER_CERT_PATH"] !== undefined) {
61
- dockerClientConfig.dockerCertPath = env["DOCKER_CERT_PATH"];
60
+ if (env.DOCKER_CERT_PATH !== undefined) {
61
+ dockerClientConfig.dockerCertPath = env.DOCKER_CERT_PATH;
62
62
  }
63
63
  return dockerClientConfig;
64
64
  }
@@ -1,3 +1,3 @@
1
- import Dockerode from "dockerode";
2
- import { Readable } from "stream";
1
+ import type { Readable } from "node:stream";
2
+ import type Dockerode from "dockerode";
3
3
  export declare const attachContainer: (dockerode: Dockerode, container: Dockerode.Container) => Promise<Readable>;
@@ -1,3 +1,3 @@
1
- import Dockerode from "dockerode";
2
- import { Readable } from "stream";
1
+ import { type Readable } from "node:stream";
2
+ import type Dockerode from "dockerode";
3
3
  export declare function demuxStream(dockerode: Dockerode, stream: Readable): Promise<Readable>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.demuxStream = demuxStream;
4
- const stream_1 = require("stream");
4
+ const node_stream_1 = require("node:stream");
5
5
  const common_1 = require("../../common");
6
6
  async function demuxStream(dockerode, stream) {
7
7
  try {
8
- const demuxedStream = new stream_1.PassThrough({ autoDestroy: true, encoding: "utf-8" });
8
+ const demuxedStream = new node_stream_1.PassThrough({ autoDestroy: true, encoding: "utf-8" });
9
9
  dockerode.modem.demuxStream(stream, demuxedStream, demuxedStream);
10
10
  stream.on("end", () => demuxedStream.end());
11
11
  demuxedStream.on("close", () => {
@@ -1,3 +1,3 @@
1
- import Dockerode from "dockerode";
2
- import { ImageName } from "../image-name";
1
+ import type Dockerode from "dockerode";
2
+ import type { ImageName } from "../image-name";
3
3
  export declare function imageExists(dockerode: Dockerode, imageName: ImageName): Promise<boolean>;
@@ -1,2 +1,2 @@
1
- import { HostIp } from "../clients/types";
1
+ import type { HostIp } from "../clients/types";
2
2
  export declare const lookupHostIps: (host: string) => Promise<HostIp[]>;
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.lookupHostIps = void 0;
7
- const promises_1 = require("dns/promises");
8
- const net_1 = __importDefault(require("net"));
7
+ const promises_1 = require("node:dns/promises");
8
+ const node_net_1 = __importDefault(require("node:net"));
9
9
  const lookupHostIps = async (host) => {
10
- if (net_1.default.isIP(host) === 0) {
10
+ if (node_net_1.default.isIP(host) === 0) {
11
11
  return await (0, promises_1.lookup)(host, { all: true });
12
12
  }
13
13
  else {
14
- return [{ address: host, family: net_1.default.isIP(host) }];
14
+ return [{ address: host, family: node_net_1.default.isIP(host) }];
15
15
  }
16
16
  };
17
17
  exports.lookupHostIps = lookupHostIps;
@@ -1,5 +1,5 @@
1
- import Dockerode from "dockerode";
2
- import { ImageName } from "../image-name";
1
+ import type Dockerode from "dockerode";
2
+ import type { ImageName } from "../image-name";
3
3
  export type PullImageOptions = {
4
4
  imageName: ImageName;
5
5
  force: boolean;
@@ -1,2 +1,2 @@
1
- import { ContainerRuntimeClientStrategyResult } from "../strategies/types";
1
+ import type { ContainerRuntimeClientStrategyResult } from "../strategies/types";
2
2
  export declare const getRemoteContainerRuntimeSocketPath: (containerRuntimeStrategyResult: ContainerRuntimeClientStrategyResult, containerRuntimeOs: string, platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv) => string;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRemoteContainerRuntimeSocketPath = void 0;
4
4
  const getRemoteContainerRuntimeSocketPath = (containerRuntimeStrategyResult, containerRuntimeOs, platform = process.platform, env = process.env) => {
5
5
  if (containerRuntimeStrategyResult.allowUserOverrides) {
6
- if (env["TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE"] !== undefined) {
7
- return env["TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE"];
6
+ if (env.TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE !== undefined) {
7
+ return env.TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE;
8
8
  }
9
9
  }
10
10
  let socketPath;
@@ -1,3 +1,3 @@
1
- import Dockerode from "dockerode";
2
- import { ContainerRuntimeClientStrategyResult } from "../strategies/types";
1
+ import type Dockerode from "dockerode";
2
+ import type { ContainerRuntimeClientStrategyResult } from "../strategies/types";
3
3
  export declare const resolveHost: (dockerode: Dockerode, strategyResult: ContainerRuntimeClientStrategyResult, indexServerAddress: string, env?: NodeJS.ProcessEnv) => Promise<string>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveHost = void 0;
4
- const fs_1 = require("fs");
5
- const url_1 = require("url");
4
+ const node_fs_1 = require("node:fs");
5
+ const node_url_1 = require("node:url");
6
6
  const common_1 = require("../../common");
7
7
  const run_in_container_1 = require("./run-in-container");
8
8
  const resolveHost = async (dockerode, strategyResult, indexServerAddress, env = process.env) => {
@@ -11,7 +11,7 @@ const resolveHost = async (dockerode, strategyResult, indexServerAddress, env =
11
11
  return env.TESTCONTAINERS_HOST_OVERRIDE;
12
12
  }
13
13
  }
14
- const { protocol, hostname } = new url_1.URL(strategyResult.uri);
14
+ const { protocol, hostname } = new node_url_1.URL(strategyResult.uri);
15
15
  switch (protocol) {
16
16
  case "http:":
17
17
  case "https:":
@@ -50,4 +50,4 @@ const findDefaultGateway = async (dockerode, indexServerAddress) => {
50
50
  "ip route|awk '/default/ { print $3 }'",
51
51
  ]);
52
52
  };
53
- const isInContainer = () => (0, fs_1.existsSync)("/.dockerenv");
53
+ const isInContainer = () => (0, node_fs_1.existsSync)("/.dockerenv");
@@ -1,2 +1,2 @@
1
- import Dockerode from "dockerode";
1
+ import type Dockerode from "dockerode";
2
2
  export declare const runInContainer: (dockerode: Dockerode, indexServerAddress: string, image: string, command: string[]) => Promise<string | undefined>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runInContainer = void 0;
4
+ const consumers_1 = require("node:stream/consumers");
4
5
  const common_1 = require("../../common");
5
6
  const image_name_1 = require("../image-name");
6
7
  const attach_container_1 = require("./attach-container");
@@ -16,7 +17,7 @@ const runInContainer = async (dockerode, indexServerAddress, image, command) =>
16
17
  common_1.log.debug(`Starting container...`, { containerId: container.id });
17
18
  await (0, start_container_1.startContainer)(container);
18
19
  common_1.log.debug(`Waiting for container output...`, { containerId: container.id });
19
- const output = await (0, common_1.streamToString)(stream, { trim: true });
20
+ const output = (await (0, consumers_1.text)(stream)).trim();
20
21
  common_1.log.debug(`Removing container...`, { containerId: container.id });
21
22
  await container.remove({ force: true, v: true });
22
23
  return output.length === 0 ? undefined : output;
@@ -1,2 +1,2 @@
1
- import Dockerode from "dockerode";
1
+ import type Dockerode from "dockerode";
2
2
  export declare const startContainer: (container: Dockerode.Container) => Promise<void>;
@@ -1,8 +1,8 @@
1
- import { Uuid } from "../common";
2
- import { ComposeOptions } from "../container-runtime";
3
- import { Environment } from "../types";
4
- import { ImagePullPolicy } from "../utils/pull-policy";
5
- import { WaitStrategy } from "../wait-strategies/wait-strategy";
1
+ import { type Uuid } from "../common";
2
+ import { type ComposeOptions } from "../container-runtime";
3
+ import type { Environment } from "../types";
4
+ import { type ImagePullPolicy } from "../utils/pull-policy";
5
+ import type { WaitStrategy } from "../wait-strategies/wait-strategy";
6
6
  import { StartedDockerComposeEnvironment } from "./started-docker-compose-environment";
7
7
  export declare class DockerComposeEnvironment {
8
8
  private readonly composeFilePath;
@@ -98,6 +98,10 @@ class DockerComposeEnvironment {
98
98
  if (this.build) {
99
99
  commandOptions.push("--build");
100
100
  }
101
+ const shouldPull = this.pullPolicy.shouldPull();
102
+ if (shouldPull === "never") {
103
+ commandOptions.push("--pull", "never");
104
+ }
101
105
  if (!this.recreate) {
102
106
  commandOptions.push("--no-recreate");
103
107
  }
@@ -105,8 +109,10 @@ class DockerComposeEnvironment {
105
109
  if (this.environmentFile) {
106
110
  composeOptions.push("--env-file", this.environmentFile);
107
111
  }
108
- this.profiles.forEach((profile) => composeOptions.push("--profile", profile));
109
- if (this.pullPolicy.shouldPull()) {
112
+ this.profiles.forEach((profile) => {
113
+ composeOptions.push("--profile", profile);
114
+ });
115
+ if (shouldPull === true) {
110
116
  await client.compose.pull(options, services);
111
117
  }
112
118
  await client.compose.up({
@@ -116,10 +122,7 @@ class DockerComposeEnvironment {
116
122
  environment: { ...this.environment },
117
123
  }, services);
118
124
  const startedContainers = (await client.container.list()).filter((container) => container.Labels["com.docker.compose.project"] === this.projectName);
119
- const startedContainerNames = startedContainers.reduce((containerNames, startedContainer) => [
120
- ...containerNames,
121
- startedContainer.Names.join(", "),
122
- ], []);
125
+ const startedContainerNames = startedContainers.map((startedContainer) => startedContainer.Names.join(", "));
123
126
  common_1.log.info(`Started containers "${startedContainerNames.join('", "')}"`);
124
127
  const startedContainerNameSet = new Set(startedContainers.map((startedContainer) => (0, container_runtime_1.parseComposeContainerName)(this.projectName, startedContainer.Names[0])));
125
128
  this.warnForUnusedWaitStrategies(startedContainerNameSet);
@@ -156,8 +159,15 @@ class DockerComposeEnvironment {
156
159
  }
157
160
  return new started_generic_container_1.StartedGenericContainer(container, client.info.containerRuntime.host, inspectResult, boundPorts, containerName, waitStrategy, true);
158
161
  }))).reduce((map, startedGenericContainer) => {
159
- const containerName = startedGenericContainer.getName();
160
- return { ...map, [containerName]: startedGenericContainer };
162
+ // defineProperty rather than assignment: a container named "__proto__" would otherwise
163
+ // set the prototype instead of creating an own property.
164
+ Object.defineProperty(map, startedGenericContainer.getName(), {
165
+ value: startedGenericContainer,
166
+ writable: true,
167
+ enumerable: true,
168
+ configurable: true,
169
+ });
170
+ return map;
161
171
  }, {});
162
172
  common_1.log.info(`DockerCompose environment started`);
163
173
  return new started_docker_compose_environment_1.StartedDockerComposeEnvironment(startedGenericContainers, {
@@ -1,5 +1,5 @@
1
- import { ComposeDownOptions, ComposeOptions } from "../container-runtime";
2
- import { StartedGenericContainer } from "../generic-container/started-generic-container";
1
+ import { type ComposeDownOptions, type ComposeOptions } from "../container-runtime";
2
+ import type { StartedGenericContainer } from "../generic-container/started-generic-container";
3
3
  import { DownedDockerComposeEnvironment } from "./downed-docker-compose-environment";
4
4
  import { StoppedDockerComposeEnvironment } from "./stopped-docker-compose-environment";
5
5
  export declare class StartedDockerComposeEnvironment implements AsyncDisposable {
@@ -1,4 +1,4 @@
1
- import { ComposeDownOptions, ComposeOptions } from "../container-runtime";
1
+ import { type ComposeDownOptions, type ComposeOptions } from "../container-runtime";
2
2
  import { DownedDockerComposeEnvironment } from "./downed-docker-compose-environment";
3
3
  export declare class StoppedDockerComposeEnvironment {
4
4
  private readonly options;
@@ -1,6 +1,6 @@
1
- import { Readable } from "stream";
2
- import { RestartOptions, StartedTestContainer, StopOptions, StoppedTestContainer } from "../test-container";
3
- import { CommitOptions, ContentToCopy, CopyToContainerOptions, DirectoryToCopy, ExecOptions, ExecResult, FileToCopy, Labels } from "../types";
1
+ import type { Readable } from "node:stream";
2
+ import type { RestartOptions, StartedTestContainer, StopOptions, StoppedTestContainer } from "../test-container";
3
+ import type { CommitOptions, ContentToCopy, CopyToContainerOptions, DirectoryToCopy, ExecOptions, ExecResult, FileToCopy, Labels } from "../types";
4
4
  export declare class AbstractStartedContainer implements StartedTestContainer {
5
5
  protected readonly startedTestContainer: StartedTestContainer;
6
6
  constructor(startedTestContainer: StartedTestContainer);
@@ -1,4 +1,4 @@
1
- import { StoppedTestContainer } from "../test-container";
1
+ import type { StoppedTestContainer } from "../test-container";
2
2
  export declare class AbstractStoppedContainer implements StoppedTestContainer {
3
3
  protected readonly stoppedTestContainer: StoppedTestContainer;
4
4
  constructor(stoppedTestContainer: StoppedTestContainer);
@@ -1,6 +1,6 @@
1
- import { Uuid } from "../common";
2
- import { BuildArgs } from "../types";
3
- import { ImagePullPolicy } from "../utils/pull-policy";
1
+ import { type Uuid } from "../common";
2
+ import type { BuildArgs } from "../types";
3
+ import { type ImagePullPolicy } from "../utils/pull-policy";
4
4
  import { GenericContainer } from "./generic-container";
5
5
  export type BuildOptions = {
6
6
  deleteOnExit: boolean;
@@ -4,13 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GenericContainerBuilder = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const common_1 = require("../common");
9
9
  const container_runtime_1 = require("../container-runtime");
10
+ // biome-ignore lint/suspicious/noImportCycles: Ryuk and sshd run as GenericContainers; only dereferenced at runtime
10
11
  const reaper_1 = require("../reaper/reaper");
11
12
  const dockerfile_parser_1 = require("../utils/dockerfile-parser");
12
13
  const labels_1 = require("../utils/labels");
13
14
  const pull_policy_1 = require("../utils/pull-policy");
15
+ // biome-ignore lint/suspicious/noImportCycles: fromDockerfile() and build() construct each other; only dereferenced at runtime
14
16
  const generic_container_1 = require("./generic-container");
15
17
  class GenericContainerBuilder {
16
18
  context;
@@ -52,10 +54,15 @@ class GenericContainerBuilder {
52
54
  return this;
53
55
  }
54
56
  async build(image = `localhost/${this.uuid.nextUuid()}:${this.uuid.nextUuid()}`, options = { deleteOnExit: true }) {
57
+ const shouldPull = this.pullPolicy.shouldPull();
58
+ // https://github.com/docker/buildx/issues/1889
59
+ if (shouldPull === "never") {
60
+ throw new Error("Never-pull policies are not supported for Dockerfile builds: the Docker build API cannot forbid image pulls");
61
+ }
55
62
  const client = await (0, container_runtime_1.getContainerRuntimeClient)();
56
63
  const reaper = await (0, reaper_1.getReaper)(client);
57
64
  const imageName = container_runtime_1.ImageName.fromString(image);
58
- const dockerfile = path_1.default.resolve(this.context, this.dockerfileName);
65
+ const dockerfile = node_path_1.default.resolve(this.context, this.dockerfileName);
59
66
  const imageNames = await (0, dockerfile_parser_1.getDockerfileImages)(dockerfile, this.buildArgs);
60
67
  const registryConfig = await this.getRegistryConfig(client.info.containerRuntime.indexServerAddress, imageNames);
61
68
  const labels = (0, labels_1.createLabels)();
@@ -75,7 +82,7 @@ class GenericContainerBuilder {
75
82
  platform: this.platform,
76
83
  version: this.buildkit ? "2" : "1",
77
84
  };
78
- if (this.pullPolicy.shouldPull()) {
85
+ if (shouldPull === true) {
79
86
  buildOptions.pull = true;
80
87
  }
81
88
  await client.image.build(this.context, buildOptions);
@@ -93,9 +100,7 @@ class GenericContainerBuilder {
93
100
  authConfigs.push(authConfig);
94
101
  }
95
102
  }));
96
- return authConfigs
97
- .map((authConfig) => ({ [authConfig.registryAddress]: authConfig }))
98
- .reduce((prev, next) => ({ ...prev, ...next }), {});
103
+ return Object.fromEntries(authConfigs.map((authConfig) => [authConfig.registryAddress, authConfig]));
99
104
  }
100
105
  }
101
106
  exports.GenericContainerBuilder = GenericContainerBuilder;
@@ -1,12 +1,12 @@
1
- import { ContainerCreateOptions, ContainerInspectInfo, HostConfig } from "dockerode";
2
- import { Readable } from "stream";
3
- import { ContainerRuntimeClient, ImageName } from "../container-runtime";
4
- import { StartedNetwork } from "../network/network";
5
- import { StartedTestContainer, TestContainer } from "../test-container";
6
- import { ArchiveToCopy, BindMount, ContentToCopy, CopyToContainerOptions, DirectoryToCopy, Environment, ExtraHost, FileToCopy, HealthCheck, InspectResult, Labels, ResourcesQuota, TmpFs, Ulimits } from "../types";
7
- import { PortWithOptionalBinding } from "../utils/port";
8
- import { ImagePullPolicy } from "../utils/pull-policy";
9
- import { WaitStrategy } from "../wait-strategies/wait-strategy";
1
+ import type { Readable } from "node:stream";
2
+ import type { ContainerCreateOptions, ContainerInspectInfo, HostConfig } from "dockerode";
3
+ import { type ContainerRuntimeClient, ImageName } from "../container-runtime";
4
+ import type { StartedNetwork } from "../network/network";
5
+ import type { StartedTestContainer, TestContainer } from "../test-container";
6
+ import type { ArchiveToCopy, BindMount, ContentToCopy, CopyToContainerOptions, DirectoryToCopy, Environment, ExtraHost, FileToCopy, HealthCheck, InspectResult, Labels, ResourcesQuota, TmpFs, Ulimits } from "../types";
7
+ import { type PortWithOptionalBinding } from "../utils/port";
8
+ import { type ImagePullPolicy } from "../utils/pull-policy";
9
+ import type { WaitStrategy } from "../wait-strategies/wait-strategy";
10
10
  import { GenericContainerBuilder } from "./generic-container-builder";
11
11
  export declare class GenericContainer implements TestContainer {
12
12
  static fromDockerfile(context: string, dockerfileName?: string): GenericContainerBuilder;