testcontainers 7.22.1 → 7.23.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/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
@@ -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
  };
@@ -4,5 +4,6 @@ export declare type DockerComposeOptions = {
4
4
  files: string | string[];
5
5
  projectName: string;
6
6
  commandOptions?: string[];
7
+ composeOptions?: string[];
7
8
  env?: Env;
8
9
  };
@@ -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
- yield docker_compose_up_1.dockerComposeUp(Object.assign(Object.assign({}, options), { commandOptions, env: this.env }), services);
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,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testcontainers",
3
3
  "author": "Cristian Greco",
4
- "version": "7.22.1",
4
+ "version": "7.23.0",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "keywords": [