testcontainers 9.4.0 → 9.5.0
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/dist/package.json +1 -1
- package/dist/src/docker/rootless-unix-socket-strategy.d.ts +2 -1
- package/dist/src/docker/rootless-unix-socket-strategy.js +10 -2
- package/dist/src/docker-compose/functions/docker-compose-pull.d.ts +2 -0
- package/dist/src/docker-compose/functions/docker-compose-pull.js +35 -0
- package/dist/src/docker-compose-environment/docker-compose-environment.d.ts +3 -0
- package/dist/src/docker-compose-environment/docker-compose-environment.js +10 -0
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -8,7 +8,8 @@ export declare class RootlessUnixSocketStrategy implements DockerClientStrategy
|
|
|
8
8
|
constructor(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv);
|
|
9
9
|
init(): Promise<void>;
|
|
10
10
|
private getSocketPathFromEnv;
|
|
11
|
-
private
|
|
11
|
+
private getSocketPathFromHomeRunDir;
|
|
12
|
+
private getSocketPathFromHomeDesktopDir;
|
|
12
13
|
private getSocketPathFromRunDir;
|
|
13
14
|
getDockerClient(): Promise<DockerClientInit>;
|
|
14
15
|
isApplicable(): boolean;
|
|
@@ -29,7 +29,12 @@ class RootlessUnixSocketStrategy {
|
|
|
29
29
|
this.applicable = false;
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
this.socketPath = [
|
|
32
|
+
this.socketPath = [
|
|
33
|
+
this.getSocketPathFromEnv(),
|
|
34
|
+
this.getSocketPathFromHomeRunDir(),
|
|
35
|
+
this.getSocketPathFromHomeDesktopDir(),
|
|
36
|
+
this.getSocketPathFromRunDir(),
|
|
37
|
+
]
|
|
33
38
|
.filter(type_guards_1.isDefined)
|
|
34
39
|
.find((candidateSocketPath) => (0, fs_1.existsSync)(candidateSocketPath));
|
|
35
40
|
this.applicable = this.socketPath !== undefined;
|
|
@@ -44,9 +49,12 @@ class RootlessUnixSocketStrategy {
|
|
|
44
49
|
return undefined;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
|
-
|
|
52
|
+
getSocketPathFromHomeRunDir() {
|
|
48
53
|
return path_1.default.join(os_1.default.homedir(), ".docker", "run", "docker.sock");
|
|
49
54
|
}
|
|
55
|
+
getSocketPathFromHomeDesktopDir() {
|
|
56
|
+
return path_1.default.join(os_1.default.homedir(), ".docker", "desktop", "docker.sock");
|
|
57
|
+
}
|
|
50
58
|
getSocketPathFromRunDir() {
|
|
51
59
|
return path_1.default.join("/run", "user", `${os_1.default.userInfo().uid}`, "docker.sock");
|
|
52
60
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.dockerComposePull = void 0;
|
|
13
|
+
const logger_1 = require("../../logger");
|
|
14
|
+
const docker_compose_1 = require("docker-compose");
|
|
15
|
+
const default_docker_compose_options_1 = require("../default-docker-compose-options");
|
|
16
|
+
const dockerComposePull = (options, services) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
try {
|
|
18
|
+
if (services) {
|
|
19
|
+
logger_1.log.info(`Pulling DockerCompose environment images for ${services.join(", ")}`);
|
|
20
|
+
yield (0, docker_compose_1.pullMany)(services, yield (0, default_docker_compose_options_1.defaultDockerComposeOptions)(options));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
logger_1.log.info(`Pulling DockerCompose environment images`);
|
|
24
|
+
yield (0, docker_compose_1.pullAll)(yield (0, default_docker_compose_options_1.defaultDockerComposeOptions)(options));
|
|
25
|
+
}
|
|
26
|
+
logger_1.log.info(`Pulled DockerCompose environment`);
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
const errorMessage = err.err || err.message || err || "";
|
|
31
|
+
logger_1.log.error(`Failed to pull DockerCompose environment images: ${errorMessage.trim()}`);
|
|
32
|
+
throw new Error(errorMessage);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
exports.dockerComposePull = dockerComposePull;
|
|
@@ -2,6 +2,7 @@ import { WaitStrategy } from "../wait-strategy/wait-strategy";
|
|
|
2
2
|
import { Uuid } from "../uuid";
|
|
3
3
|
import { Environment } from "../docker/types";
|
|
4
4
|
import { StartedDockerComposeEnvironment } from "./started-docker-compose-environment";
|
|
5
|
+
import { PullPolicy } from "../pull-policy";
|
|
5
6
|
export declare class DockerComposeEnvironment {
|
|
6
7
|
private readonly composeFilePath;
|
|
7
8
|
private readonly composeFiles;
|
|
@@ -11,6 +12,7 @@ export declare class DockerComposeEnvironment {
|
|
|
11
12
|
private environmentFile;
|
|
12
13
|
private profiles;
|
|
13
14
|
private environment;
|
|
15
|
+
private pullPolicy;
|
|
14
16
|
private waitStrategy;
|
|
15
17
|
private startupTimeout;
|
|
16
18
|
constructor(composeFilePath: string, composeFiles: string | string[], uuid?: Uuid);
|
|
@@ -19,6 +21,7 @@ export declare class DockerComposeEnvironment {
|
|
|
19
21
|
withEnvironmentFile(environmentFile: string): this;
|
|
20
22
|
withProfiles(...profiles: string[]): this;
|
|
21
23
|
withNoRecreate(): this;
|
|
24
|
+
withPullPolicy(pullPolicy: PullPolicy): this;
|
|
22
25
|
withWaitStrategy(containerName: string, waitStrategy: WaitStrategy): this;
|
|
23
26
|
withStartupTimeout(startupTimeout: number): this;
|
|
24
27
|
up(services?: Array<string>): Promise<StartedDockerComposeEnvironment>;
|
|
@@ -26,6 +26,8 @@ const docker_compose_down_1 = require("../docker-compose/functions/docker-compos
|
|
|
26
26
|
const docker_compose_up_1 = require("../docker-compose/functions/docker-compose-up");
|
|
27
27
|
const wait_for_container_1 = require("../wait-for-container");
|
|
28
28
|
const default_wait_strategy_1 = require("../wait-strategy/default-wait-strategy");
|
|
29
|
+
const pull_policy_1 = require("../pull-policy");
|
|
30
|
+
const docker_compose_pull_1 = require("../docker-compose/functions/docker-compose-pull");
|
|
29
31
|
class DockerComposeEnvironment {
|
|
30
32
|
constructor(composeFilePath, composeFiles, uuid = new uuid_1.RandomUuid()) {
|
|
31
33
|
this.build = false;
|
|
@@ -33,6 +35,7 @@ class DockerComposeEnvironment {
|
|
|
33
35
|
this.environmentFile = "";
|
|
34
36
|
this.profiles = [];
|
|
35
37
|
this.environment = {};
|
|
38
|
+
this.pullPolicy = new pull_policy_1.DefaultPullPolicy();
|
|
36
39
|
this.waitStrategy = {};
|
|
37
40
|
this.startupTimeout = 60000;
|
|
38
41
|
this.composeFilePath = composeFilePath;
|
|
@@ -60,6 +63,10 @@ class DockerComposeEnvironment {
|
|
|
60
63
|
this.projectName = "testcontainers-node";
|
|
61
64
|
return this;
|
|
62
65
|
}
|
|
66
|
+
withPullPolicy(pullPolicy) {
|
|
67
|
+
this.pullPolicy = pullPolicy;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
63
70
|
withWaitStrategy(containerName, waitStrategy) {
|
|
64
71
|
this.waitStrategy[containerName] = waitStrategy;
|
|
65
72
|
return this;
|
|
@@ -89,6 +96,9 @@ class DockerComposeEnvironment {
|
|
|
89
96
|
composeOptions.push("--env-file", this.environmentFile);
|
|
90
97
|
}
|
|
91
98
|
this.profiles.forEach((profile) => composeOptions.push("--profile", profile));
|
|
99
|
+
if (this.pullPolicy.shouldPull()) {
|
|
100
|
+
yield (0, docker_compose_pull_1.dockerComposePull)(options, services);
|
|
101
|
+
}
|
|
92
102
|
yield (0, docker_compose_up_1.dockerComposeUp)(Object.assign(Object.assign({}, options), { commandOptions, composeOptions, environment: this.environment }), services);
|
|
93
103
|
const startedContainers = (yield (0, list_containers_1.listContainers)()).filter((container) => container.Labels["com.docker.compose.project"] === this.projectName);
|
|
94
104
|
const startedContainerNames = startedContainers.reduce((containerNames, startedContainer) => [
|