testcontainers 12.2.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.
- package/build/common/file-lock.js +3 -3
- package/build/common/hash.js +2 -2
- package/build/common/index.d.ts +2 -3
- package/build/common/index.js +2 -4
- package/build/common/retry.d.ts +1 -1
- package/build/common/uuid.js +2 -2
- package/build/container-runtime/auth/auths.d.ts +2 -2
- package/build/container-runtime/auth/cred-helpers.d.ts +1 -1
- package/build/container-runtime/auth/credential-provider.d.ts +2 -2
- package/build/container-runtime/auth/credential-provider.js +3 -3
- package/build/container-runtime/auth/creds-store.d.ts +2 -2
- package/build/container-runtime/auth/creds-store.js +1 -1
- package/build/container-runtime/auth/get-auth-config.d.ts +1 -1
- package/build/container-runtime/auth/get-auth-config.js +7 -7
- package/build/container-runtime/auth/registry-auth-locator.d.ts +1 -1
- package/build/container-runtime/auth/registry-matches.js +1 -1
- package/build/container-runtime/clients/client.d.ts +5 -5
- package/build/container-runtime/clients/compose/compose-client.d.ts +1 -1
- package/build/container-runtime/clients/compose/compose-client.js +1 -3
- package/build/container-runtime/clients/compose/default-compose-options.d.ts +2 -2
- package/build/container-runtime/clients/compose/default-compose-options.js +5 -3
- package/build/container-runtime/clients/compose/types.d.ts +3 -2
- package/build/container-runtime/clients/container/container-client.d.ts +5 -4
- package/build/container-runtime/clients/container/docker-container-client.d.ts +6 -5
- package/build/container-runtime/clients/container/docker-container-client.js +8 -9
- package/build/container-runtime/clients/container/types.d.ts +1 -3
- package/build/container-runtime/clients/image/docker-image-client.d.ts +4 -3
- package/build/container-runtime/clients/image/docker-image-client.js +11 -10
- package/build/container-runtime/clients/image/image-client.d.ts +2 -2
- package/build/container-runtime/clients/network/docker-network-client.d.ts +3 -2
- package/build/container-runtime/clients/network/network-client.d.ts +1 -1
- package/build/container-runtime/image-name.js +2 -2
- package/build/container-runtime/index.d.ts +1 -1
- package/build/container-runtime/strategies/configuration-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/configuration-strategy.js +7 -7
- package/build/container-runtime/strategies/npipe-socket-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/rootless-unix-socket-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/rootless-unix-socket-strategy.js +9 -9
- package/build/container-runtime/strategies/strategy.d.ts +1 -1
- package/build/container-runtime/strategies/testcontainers-host-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/testcontainers-host-strategy.js +2 -2
- package/build/container-runtime/strategies/types.d.ts +1 -1
- package/build/container-runtime/strategies/unix-socket-strategy.d.ts +2 -2
- package/build/container-runtime/strategies/unix-socket-strategy.js +2 -2
- package/build/container-runtime/strategies/utils/config.js +12 -12
- package/build/container-runtime/utils/attach-container.d.ts +2 -2
- package/build/container-runtime/utils/demux-stream.d.ts +2 -2
- package/build/container-runtime/utils/demux-stream.js +2 -2
- package/build/container-runtime/utils/image-exists.d.ts +2 -2
- package/build/container-runtime/utils/lookup-host-ips.d.ts +1 -1
- package/build/container-runtime/utils/lookup-host-ips.js +4 -4
- package/build/container-runtime/utils/pull-image.d.ts +2 -2
- package/build/container-runtime/utils/remote-container-runtime-socket-path.d.ts +1 -1
- package/build/container-runtime/utils/remote-container-runtime-socket-path.js +2 -2
- package/build/container-runtime/utils/resolve-host.d.ts +2 -2
- package/build/container-runtime/utils/resolve-host.js +4 -4
- package/build/container-runtime/utils/run-in-container.d.ts +1 -1
- package/build/container-runtime/utils/run-in-container.js +2 -1
- package/build/container-runtime/utils/start-container.d.ts +1 -1
- package/build/docker-compose-environment/docker-compose-environment.d.ts +5 -5
- package/build/docker-compose-environment/docker-compose-environment.js +13 -7
- package/build/docker-compose-environment/started-docker-compose-environment.d.ts +2 -2
- package/build/docker-compose-environment/stopped-docker-compose-environment.d.ts +1 -1
- package/build/generic-container/abstract-started-container.d.ts +3 -3
- package/build/generic-container/abstract-stopped-container.d.ts +1 -1
- package/build/generic-container/generic-container-builder.d.ts +3 -3
- package/build/generic-container/generic-container-builder.js +5 -5
- package/build/generic-container/generic-container.d.ts +9 -9
- package/build/generic-container/generic-container.js +10 -4
- package/build/generic-container/inspect-container-util-ports-exposed.d.ts +1 -1
- package/build/generic-container/inspect-container-util-ports-exposed.js +1 -1
- package/build/generic-container/started-generic-container.d.ts +6 -5
- package/build/generic-container/started-generic-container.js +19 -16
- package/build/generic-container/stopped-generic-container.d.ts +2 -2
- package/build/index.d.ts +4 -4
- package/build/index.js +3 -3
- package/build/network/network.d.ts +3 -3
- package/build/port-forwarder/port-forwarder.d.ts +2 -3
- package/build/port-forwarder/port-forwarder.js +25 -19
- package/build/reaper/reaper.d.ts +1 -1
- package/build/reaper/reaper.js +21 -19
- package/build/socat/socat-container.d.ts +0 -2
- package/build/socat/socat-container.js +0 -3
- package/build/test-container.d.ts +6 -6
- package/build/test-containers.js +2 -1
- package/build/types.d.ts +3 -4
- package/build/utils/bound-ports.d.ts +3 -3
- package/build/utils/bound-ports.js +2 -2
- package/build/utils/dockerfile-parser.d.ts +1 -1
- package/build/utils/dockerfile-parser.js +2 -2
- package/build/utils/labels.d.ts +0 -2
- package/build/utils/labels.js +5 -5
- package/build/utils/map-inspect-result.d.ts +2 -2
- package/build/utils/map-inspect-result.js +12 -13
- package/build/utils/pull-policy.js +1 -0
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/build/wait-strategies/composite-wait-strategy.d.ts +3 -3
- package/build/wait-strategies/composite-wait-strategy.js +3 -1
- package/build/wait-strategies/health-check-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/host-port-wait-strategy.d.ts +2 -2
- package/build/wait-strategies/http-wait-strategy.d.ts +2 -2
- package/build/wait-strategies/http-wait-strategy.js +4 -7
- package/build/wait-strategies/log-wait-strategy.d.ts +3 -3
- package/build/wait-strategies/log-wait-strategy.js +1 -1
- package/build/wait-strategies/one-shot-startup-startegy.d.ts +2 -2
- package/build/wait-strategies/shell-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/startup-check-strategy.d.ts +1 -2
- package/build/wait-strategies/startup-check-strategy.js +0 -3
- package/build/wait-strategies/utils/health-check.d.ts +2 -4
- package/build/wait-strategies/utils/health-check.js +4 -6
- package/build/wait-strategies/utils/port-check.d.ts +2 -2
- package/build/wait-strategies/utils/port-check.js +2 -2
- package/build/wait-strategies/utils/undici-response-parser.d.ts +1 -1
- package/build/wait-strategies/utils/undici-response-parser.js +2 -2
- package/build/wait-strategies/utils/wait-strategy-selector.d.ts +4 -4
- package/build/wait-strategies/wait-for-container.d.ts +4 -4
- package/build/wait-strategies/wait-strategy.d.ts +2 -2
- package/build/wait-strategies/wait.d.ts +3 -3
- package/build/wait-strategies/wait.js +1 -0
- package/package.json +2 -3
- package/build/common/streams.d.ts +0 -6
- package/build/common/streams.js +0 -12
|
@@ -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
|
|
8
|
-
const
|
|
9
|
-
const
|
|
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,
|
|
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
|
|
44
|
+
const xdgRuntimeDir = this.env.XDG_RUNTIME_DIR;
|
|
45
45
|
if (xdgRuntimeDir !== undefined) {
|
|
46
|
-
return
|
|
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
|
|
53
|
+
return node_path_1.default.join(node_os_1.default.homedir(), ".docker", "run", "docker.sock");
|
|
54
54
|
}
|
|
55
55
|
getSocketPathFromHomeDesktopDir() {
|
|
56
|
-
return
|
|
56
|
+
return node_path_1.default.join(node_os_1.default.homedir(), ".docker", "desktop", "docker.sock");
|
|
57
57
|
}
|
|
58
58
|
getSocketPathFromRunDir() {
|
|
59
|
-
return
|
|
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
|
|
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
|
|
16
|
+
const { hostname, port } = new node_url_1.URL(tcHost);
|
|
17
17
|
dockerOptions.host = hostname;
|
|
18
18
|
dockerOptions.port = port;
|
|
19
19
|
return {
|
|
@@ -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
|
|
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,
|
|
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
|
|
8
|
-
const promises_1 = require("fs/promises");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
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 =
|
|
26
|
+
const file = node_path_1.default.resolve((0, node_os_1.homedir)(), ".testcontainers.properties");
|
|
27
27
|
const dockerClientConfig = {};
|
|
28
|
-
if ((0,
|
|
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
|
|
55
|
-
dockerClientConfig.dockerHost = env
|
|
54
|
+
if (env.DOCKER_HOST !== undefined) {
|
|
55
|
+
dockerClientConfig.dockerHost = env.DOCKER_HOST;
|
|
56
56
|
}
|
|
57
|
-
if (env
|
|
58
|
-
dockerClientConfig.dockerTlsVerify = env
|
|
57
|
+
if (env.DOCKER_TLS_VERIFY !== undefined) {
|
|
58
|
+
dockerClientConfig.dockerTlsVerify = env.DOCKER_TLS_VERIFY;
|
|
59
59
|
}
|
|
60
|
-
if (env
|
|
61
|
-
dockerClientConfig.dockerCertPath = env
|
|
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
|
|
2
|
-
import
|
|
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
|
|
2
|
-
import
|
|
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
|
|
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
|
|
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
|
|
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 (
|
|
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:
|
|
14
|
+
return [{ address: host, family: node_net_1.default.isIP(host) }];
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
exports.lookupHostIps = lookupHostIps;
|
|
@@ -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
|
|
7
|
-
return env
|
|
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
|
|
5
|
-
const
|
|
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
|
|
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,
|
|
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,
|
|
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;
|
|
@@ -109,7 +109,9 @@ class DockerComposeEnvironment {
|
|
|
109
109
|
if (this.environmentFile) {
|
|
110
110
|
composeOptions.push("--env-file", this.environmentFile);
|
|
111
111
|
}
|
|
112
|
-
this.profiles.forEach((profile) =>
|
|
112
|
+
this.profiles.forEach((profile) => {
|
|
113
|
+
composeOptions.push("--profile", profile);
|
|
114
|
+
});
|
|
113
115
|
if (shouldPull === true) {
|
|
114
116
|
await client.compose.pull(options, services);
|
|
115
117
|
}
|
|
@@ -120,10 +122,7 @@ class DockerComposeEnvironment {
|
|
|
120
122
|
environment: { ...this.environment },
|
|
121
123
|
}, services);
|
|
122
124
|
const startedContainers = (await client.container.list()).filter((container) => container.Labels["com.docker.compose.project"] === this.projectName);
|
|
123
|
-
const startedContainerNames = startedContainers.
|
|
124
|
-
...containerNames,
|
|
125
|
-
startedContainer.Names.join(", "),
|
|
126
|
-
], []);
|
|
125
|
+
const startedContainerNames = startedContainers.map((startedContainer) => startedContainer.Names.join(", "));
|
|
127
126
|
common_1.log.info(`Started containers "${startedContainerNames.join('", "')}"`);
|
|
128
127
|
const startedContainerNameSet = new Set(startedContainers.map((startedContainer) => (0, container_runtime_1.parseComposeContainerName)(this.projectName, startedContainer.Names[0])));
|
|
129
128
|
this.warnForUnusedWaitStrategies(startedContainerNameSet);
|
|
@@ -160,8 +159,15 @@ class DockerComposeEnvironment {
|
|
|
160
159
|
}
|
|
161
160
|
return new started_generic_container_1.StartedGenericContainer(container, client.info.containerRuntime.host, inspectResult, boundPorts, containerName, waitStrategy, true);
|
|
162
161
|
}))).reduce((map, startedGenericContainer) => {
|
|
163
|
-
|
|
164
|
-
|
|
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;
|
|
165
171
|
}, {});
|
|
166
172
|
common_1.log.info(`DockerCompose environment started`);
|
|
167
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
|
|
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;
|
|
@@ -60,7 +62,7 @@ class GenericContainerBuilder {
|
|
|
60
62
|
const client = await (0, container_runtime_1.getContainerRuntimeClient)();
|
|
61
63
|
const reaper = await (0, reaper_1.getReaper)(client);
|
|
62
64
|
const imageName = container_runtime_1.ImageName.fromString(image);
|
|
63
|
-
const dockerfile =
|
|
65
|
+
const dockerfile = node_path_1.default.resolve(this.context, this.dockerfileName);
|
|
64
66
|
const imageNames = await (0, dockerfile_parser_1.getDockerfileImages)(dockerfile, this.buildArgs);
|
|
65
67
|
const registryConfig = await this.getRegistryConfig(client.info.containerRuntime.indexServerAddress, imageNames);
|
|
66
68
|
const labels = (0, labels_1.createLabels)();
|
|
@@ -98,9 +100,7 @@ class GenericContainerBuilder {
|
|
|
98
100
|
authConfigs.push(authConfig);
|
|
99
101
|
}
|
|
100
102
|
}));
|
|
101
|
-
return authConfigs
|
|
102
|
-
.map((authConfig) => ({ [authConfig.registryAddress]: authConfig }))
|
|
103
|
-
.reduce((prev, next) => ({ ...prev, ...next }), {});
|
|
103
|
+
return Object.fromEntries(authConfigs.map((authConfig) => [authConfig.registryAddress, authConfig]));
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
exports.GenericContainerBuilder = GenericContainerBuilder;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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;
|
|
@@ -4,13 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GenericContainer = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
7
8
|
const archiver_1 = __importDefault(require("archiver"));
|
|
8
9
|
const async_lock_1 = __importDefault(require("async-lock"));
|
|
9
|
-
const fs_1 = require("fs");
|
|
10
10
|
const common_1 = require("../common");
|
|
11
11
|
const container_runtime_1 = require("../container-runtime");
|
|
12
12
|
const types_1 = require("../container-runtime/clients/container/types");
|
|
13
|
+
// biome-ignore lint/suspicious/noImportCycles: Ryuk and sshd run as GenericContainers; only dereferenced at runtime
|
|
13
14
|
const port_forwarder_1 = require("../port-forwarder/port-forwarder");
|
|
15
|
+
// biome-ignore lint/suspicious/noImportCycles: Ryuk and sshd run as GenericContainers; only dereferenced at runtime
|
|
14
16
|
const reaper_1 = require("../reaper/reaper");
|
|
15
17
|
const bound_ports_1 = require("../utils/bound-ports");
|
|
16
18
|
const labels_1 = require("../utils/labels");
|
|
@@ -19,8 +21,10 @@ const port_1 = require("../utils/port");
|
|
|
19
21
|
const pull_policy_1 = require("../utils/pull-policy");
|
|
20
22
|
const wait_strategy_selector_1 = require("../wait-strategies/utils/wait-strategy-selector");
|
|
21
23
|
const wait_for_container_1 = require("../wait-strategies/wait-for-container");
|
|
24
|
+
// biome-ignore lint/suspicious/noImportCycles: fromDockerfile() and build() construct each other; only dereferenced at runtime
|
|
22
25
|
const generic_container_builder_1 = require("./generic-container-builder");
|
|
23
26
|
const inspect_container_util_ports_exposed_1 = require("./inspect-container-util-ports-exposed");
|
|
27
|
+
// biome-ignore lint/suspicious/noImportCycles: Ryuk and sshd run as GenericContainers; only dereferenced at runtime
|
|
24
28
|
const started_generic_container_1 = require("./started-generic-container");
|
|
25
29
|
const reusableContainerCreationLock = new async_lock_1.default();
|
|
26
30
|
class GenericContainer {
|
|
@@ -145,8 +149,10 @@ class GenericContainer {
|
|
|
145
149
|
}
|
|
146
150
|
if (this.filesToCopy.length > 0 || this.directoriesToCopy.length > 0 || this.contentsToCopy.length > 0) {
|
|
147
151
|
const archive = await this.createArchiveToCopyToContainer();
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
await Promise.all([
|
|
153
|
+
archive.finalize(),
|
|
154
|
+
client.container.putArchive(container, archive, "/", this.copyToContainerOptions),
|
|
155
|
+
]);
|
|
150
156
|
}
|
|
151
157
|
for (const archive of this.archivesToCopy) {
|
|
152
158
|
await client.container.putArchive(container, archive.tar, archive.target, this.copyToContainerOptions);
|
|
@@ -197,7 +203,7 @@ class GenericContainer {
|
|
|
197
203
|
const tar = (0, archiver_1.default)("tar");
|
|
198
204
|
const filesToCopyWithStats = await Promise.all(this.filesToCopy.map(async (fileToCopy) => ({
|
|
199
205
|
...fileToCopy,
|
|
200
|
-
stats: await
|
|
206
|
+
stats: await node_fs_1.promises.stat(fileToCopy.source),
|
|
201
207
|
})));
|
|
202
208
|
for (const { source, target, mode, stats } of filesToCopyWithStats) {
|
|
203
209
|
tar.file(source, { name: target, mode, stats });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ContainerInspectInfo } from "dockerode";
|
|
1
|
+
import type { ContainerInspectInfo } from "dockerode";
|
|
2
2
|
export declare function inspectContainerUntilPortsExposed(inspectFn: () => Promise<ContainerInspectInfo>, containerId: string, timeout?: number): Promise<ContainerInspectInfo>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.inspectContainerUntilPortsExposed = inspectContainerUntilPortsExposed;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
|
-
async function inspectContainerUntilPortsExposed(inspectFn, containerId, timeout =
|
|
5
|
+
async function inspectContainerUntilPortsExposed(inspectFn, containerId, timeout = 30_000) {
|
|
6
6
|
const result = await new common_1.IntervalRetry(250).retryUntil(() => inspectFn(), (inspectResult) => {
|
|
7
7
|
const portBindings = inspectResult?.HostConfig?.PortBindings;
|
|
8
8
|
if (!portBindings)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
import type Dockerode from "dockerode";
|
|
3
|
+
import type { ContainerInspectInfo } from "dockerode";
|
|
4
|
+
import type { RestartOptions, StartedTestContainer, StopOptions, StoppedTestContainer } from "../test-container";
|
|
5
|
+
import type { CommitOptions, ContentToCopy, CopyToContainerOptions, DirectoryToCopy, ExecOptions, ExecResult, FileToCopy, Labels } from "../types";
|
|
5
6
|
import { BoundPorts } from "../utils/bound-ports";
|
|
6
|
-
import { WaitStrategy } from "../wait-strategies/wait-strategy";
|
|
7
|
+
import type { WaitStrategy } from "../wait-strategies/wait-strategy";
|
|
7
8
|
export declare class StartedGenericContainer implements StartedTestContainer {
|
|
8
9
|
private readonly container;
|
|
9
10
|
private readonly host;
|