testcontainers 8.1.2 → 8.2.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
@@ -18,14 +18,14 @@ npm i -D testcontainers
18
18
 
19
19
  The following environment variables are supported:
20
20
 
21
- - `DEBUG=testcontainers` See testcontainers logs
22
- - `DEBUG=testcontainers:containers` See container logs
23
- - `DEBUG=testcontainers*` See all logs
21
+ - `DEBUG=testcontainers` Enable testcontainers logs
22
+ - `DEBUG=testcontainers:containers` Enable container logs
23
+ - `DEBUG=testcontainers*` Enable all logs
24
24
  - `DOCKER_HOST=tcp://docker:2375` Sets the URL of the docker daemon
25
- - `DOCKER_TLS_VERIFY=1` When set to anything other than an empty string, enables TLS communication with the docker
25
+ - `DOCKER_TLS_VERIFY=1` When set to `1`, enables TLS communication with the docker
26
26
  daemon
27
- - `DOCKER_CERT_PATH=/some/path` Configures the path to the ca.pem, cert.pem, and key.pem files used for TLS
28
- verification. Defaults to ~/.docker
27
+ - `DOCKER_CERT_PATH=/some/path` Configures the path to the `ca.pem`, `cert.pem`, and `key.pem` files used for TLS
28
+ verification. Defaults to `~/.docker`
29
29
  - `TESTCONTAINERS_HOST_OVERRIDE=docker.svc.local` Docker's host on which ports are exposed
30
30
  - `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock` Path to Docker's socket. Used by [ryuk](#ryuk) and
31
31
  other [auxiliary containers](#auxiliary-containers) that need to perform Docker actions
@@ -547,6 +547,16 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF
547
547
  .up();
548
548
  ```
549
549
 
550
+ Specify the [environment file](https://docs.docker.com/compose/environment-variables/#using-the---env-file--option):
551
+
552
+ ```javascript
553
+ const { DockerComposeEnvironment } = require("testcontainers");
554
+
555
+ const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
556
+ .withEnvFile(".env.custom")
557
+ .up();
558
+ ```
559
+
550
560
  Specify [profiles](https://docs.docker.com/compose/profiles/):
551
561
 
552
562
  ```javascript
@@ -8,6 +8,7 @@ export declare class DockerComposeEnvironment {
8
8
  private projectName;
9
9
  private build;
10
10
  private recreate;
11
+ private envFile;
11
12
  private profiles;
12
13
  private env;
13
14
  private waitStrategy;
@@ -15,6 +16,7 @@ export declare class DockerComposeEnvironment {
15
16
  constructor(composeFilePath: string, composeFiles: string | string[], uuid?: Uuid);
16
17
  withBuild(): this;
17
18
  withEnv(key: EnvKey, value: EnvValue): this;
19
+ withEnvFile(envFile: string): this;
18
20
  withProfiles(...profiles: string[]): this;
19
21
  withNoRecreate(): this;
20
22
  withWaitStrategy(containerName: string, waitStrategy: WaitStrategy): 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.envFile = "";
33
34
  this.profiles = [];
34
35
  this.env = {};
35
36
  this.waitStrategy = {};
@@ -46,6 +47,10 @@ class DockerComposeEnvironment {
46
47
  this.env[key] = value;
47
48
  return this;
48
49
  }
50
+ withEnvFile(envFile) {
51
+ this.envFile = envFile;
52
+ return this;
53
+ }
49
54
  withProfiles(...profiles) {
50
55
  this.profiles = profiles;
51
56
  return this;
@@ -80,6 +85,9 @@ class DockerComposeEnvironment {
80
85
  commandOptions.push("--no-recreate");
81
86
  }
82
87
  const composeOptions = [];
88
+ if (this.envFile) {
89
+ composeOptions.push("--env-file", this.envFile);
90
+ }
83
91
  this.profiles.forEach((profile) => composeOptions.push("--profile", profile));
84
92
  yield docker_compose_up_1.dockerComposeUp(Object.assign(Object.assign({}, options), { commandOptions, composeOptions, env: this.env }), services);
85
93
  const startedContainers = (yield list_containers_1.listContainers()).filter((container) => container.Labels["com.docker.compose.project"] === this.projectName);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testcontainers",
3
3
  "author": "Cristian Greco",
4
- "version": "8.1.2",
4
+ "version": "8.2.0",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "keywords": [