testcontainers 7.22.1-beta.0 → 7.23.2
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/README.md +10 -0
- package/dist/docker/functions/image/build-image.js +1 -1
- package/dist/docker-compose/default-docker-compose-options.js +1 -0
- package/dist/docker-compose/docker-compose-options.d.ts +1 -0
- package/dist/docker-compose-environment/docker-compose-environment.d.ts +2 -0
- package/dist/docker-compose-environment/docker-compose-environment.js +12 -2
- package/dist/docker-ignore.d.ts +1 -1
- package/dist/docker-ignore.js +2 -1
- package/dist/registry-auth-locator/credential-provider.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -523,6 +523,16 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
|
|
|
523
523
|
.up();
|
|
524
524
|
```
|
|
525
525
|
|
|
526
|
+
Specify [profiles](https://docs.docker.com/compose/profiles/):
|
|
527
|
+
|
|
528
|
+
```javascript
|
|
529
|
+
const { DockerComposeEnvironment } = require("testcontainers");
|
|
530
|
+
|
|
531
|
+
const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
|
|
532
|
+
.withProfiles("profile1", "profile2")
|
|
533
|
+
.up();
|
|
534
|
+
```
|
|
535
|
+
|
|
526
536
|
Specify not to re-create containers that are already running:
|
|
527
537
|
|
|
528
538
|
```javascript
|
|
@@ -23,7 +23,7 @@ const create_labels_1 = require("../create-labels");
|
|
|
23
23
|
const buildImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
25
25
|
logger_1.log.info(`Building image '${options.imageName.toString()}' with context '${options.context}'`);
|
|
26
|
-
const dockerIgnoreFiles = yield docker_ignore_1.findDockerIgnoreFiles(options.context);
|
|
26
|
+
const dockerIgnoreFiles = yield docker_ignore_1.findDockerIgnoreFiles(options.context, options.dockerfileName);
|
|
27
27
|
const tarStream = tar_fs_1.default.pack(options.context, { ignore: (name) => dockerIgnoreFiles.has(slash_1.default(name)) });
|
|
28
28
|
return new Promise((resolve) => dockerode_1.dockerode
|
|
29
29
|
.buildImage(tarStream, {
|
|
@@ -18,6 +18,7 @@ const defaultDockerComposeOptions = (_a) => {
|
|
|
18
18
|
log: false,
|
|
19
19
|
cwd: options.filePath,
|
|
20
20
|
config: options.files,
|
|
21
|
+
composeOptions: options.composeOptions,
|
|
21
22
|
commandOptions: options.commandOptions,
|
|
22
23
|
env: Object.assign(Object.assign(Object.assign({}, process.env), { COMPOSE_PROJECT_NAME: options.projectName }), env),
|
|
23
24
|
};
|
|
@@ -8,12 +8,14 @@ export declare class DockerComposeEnvironment {
|
|
|
8
8
|
private projectName;
|
|
9
9
|
private build;
|
|
10
10
|
private recreate;
|
|
11
|
+
private profiles;
|
|
11
12
|
private env;
|
|
12
13
|
private waitStrategy;
|
|
13
14
|
private startupTimeout;
|
|
14
15
|
constructor(composeFilePath: string, composeFiles: string | string[], uuid?: Uuid);
|
|
15
16
|
withBuild(): this;
|
|
16
17
|
withEnv(key: EnvKey, value: EnvValue): this;
|
|
18
|
+
withProfiles(...profiles: string[]): this;
|
|
17
19
|
withNoRecreate(): this;
|
|
18
20
|
withWaitStrategy(containerName: string, waitStrategy: WaitStrategy): this;
|
|
19
21
|
withStartupTimeout(startupTimeout: number): this;
|
|
@@ -30,6 +30,7 @@ class DockerComposeEnvironment {
|
|
|
30
30
|
constructor(composeFilePath, composeFiles, uuid = new uuid_1.RandomUuid()) {
|
|
31
31
|
this.build = false;
|
|
32
32
|
this.recreate = true;
|
|
33
|
+
this.profiles = [];
|
|
33
34
|
this.env = {};
|
|
34
35
|
this.waitStrategy = {};
|
|
35
36
|
this.startupTimeout = 60000;
|
|
@@ -45,6 +46,10 @@ class DockerComposeEnvironment {
|
|
|
45
46
|
this.env[key] = value;
|
|
46
47
|
return this;
|
|
47
48
|
}
|
|
49
|
+
withProfiles(...profiles) {
|
|
50
|
+
this.profiles = profiles;
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
48
53
|
withNoRecreate() {
|
|
49
54
|
this.recreate = false;
|
|
50
55
|
this.projectName = "testcontainers-node";
|
|
@@ -74,7 +79,12 @@ class DockerComposeEnvironment {
|
|
|
74
79
|
if (!this.recreate) {
|
|
75
80
|
commandOptions.push("--no-recreate");
|
|
76
81
|
}
|
|
77
|
-
|
|
82
|
+
const composeOptions = [];
|
|
83
|
+
this.profiles.forEach((profile) => {
|
|
84
|
+
composeOptions.push("--profile");
|
|
85
|
+
composeOptions.push(profile);
|
|
86
|
+
});
|
|
87
|
+
yield docker_compose_up_1.dockerComposeUp(Object.assign(Object.assign({}, options), { commandOptions, composeOptions, env: this.env }), services);
|
|
78
88
|
const startedContainers = (yield list_containers_1.listContainers()).filter((container) => container.Labels["com.docker.compose.project"] === this.projectName);
|
|
79
89
|
const startedContainerNames = startedContainers.reduce((containerNames, startedContainer) => [
|
|
80
90
|
...containerNames,
|
|
@@ -110,7 +120,7 @@ class DockerComposeEnvironment {
|
|
|
110
120
|
return Object.assign(Object.assign({}, map), { [containerName]: startedGenericContainer });
|
|
111
121
|
}, {});
|
|
112
122
|
logger_1.log.info(`DockerCompose environment started: ${Object.keys(startedGenericContainers).join(", ")}`);
|
|
113
|
-
return new started_docker_compose_environment_1.StartedDockerComposeEnvironment(startedGenericContainers, options);
|
|
123
|
+
return new started_docker_compose_environment_1.StartedDockerComposeEnvironment(startedGenericContainers, Object.assign(Object.assign({}, options), { composeOptions, env: this.env }));
|
|
114
124
|
});
|
|
115
125
|
}
|
|
116
126
|
getBoundPorts(containerInfo) {
|
package/dist/docker-ignore.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const findDockerIgnoreFiles: (context: string) => Promise<Set<string>>;
|
|
1
|
+
export declare const findDockerIgnoreFiles: (context: string, dockerfileName: string) => Promise<Set<string>>;
|
package/dist/docker-ignore.js
CHANGED
|
@@ -17,7 +17,7 @@ const fs_1 = require("fs");
|
|
|
17
17
|
const os_1 = __importDefault(require("os"));
|
|
18
18
|
const glob_1 = __importDefault(require("glob"));
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const findDockerIgnoreFiles = (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const findDockerIgnoreFiles = (context, dockerfileName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
const dockerIgnoreFilePath = path_1.default.join(context, ".dockerignore");
|
|
22
22
|
if (!fs_1.existsSync(dockerIgnoreFilePath)) {
|
|
23
23
|
return new Set();
|
|
@@ -25,6 +25,7 @@ const findDockerIgnoreFiles = (context) => __awaiter(void 0, void 0, void 0, fun
|
|
|
25
25
|
const dockerIgnorePatterns = (yield fs_1.promises.readFile(dockerIgnoreFilePath, { encoding: "utf-8" }))
|
|
26
26
|
.toString()
|
|
27
27
|
.split(os_1.default.EOL)
|
|
28
|
+
.filter((dockerIgnorePattern) => dockerIgnorePattern !== dockerfileName)
|
|
28
29
|
.map((dockerIgnorePattern) => path_1.default.resolve(context, dockerIgnorePattern));
|
|
29
30
|
const dockerIgnoreMatches = (yield Promise.all(dockerIgnorePatterns.map(findIgnoredFilesForPattern))).reduce((prev, next) => [...prev, ...next]);
|
|
30
31
|
return new Set(dockerIgnoreMatches);
|
|
@@ -55,7 +55,7 @@ class CredentialProvider {
|
|
|
55
55
|
}
|
|
56
56
|
runCredentialProvider(registry, providerName) {
|
|
57
57
|
return new Promise((resolve) => {
|
|
58
|
-
const sink = child_process_1.spawn(providerName, ["get"]
|
|
58
|
+
const sink = child_process_1.spawn(providerName, ["get"]);
|
|
59
59
|
const chunks = [];
|
|
60
60
|
sink.stdout.on("data", (chunk) => chunks.push(chunk));
|
|
61
61
|
sink.on("close", (code) => {
|