testcontainers 7.20.0 → 7.20.4
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 -15
- package/dist/docker-compose/functions/docker-compose-down.js +3 -2
- package/dist/docker-compose/functions/docker-compose-stop.js +3 -2
- package/dist/docker-compose/functions/docker-compose-up.js +3 -2
- package/dist/docker-compose-environment/docker-compose-environment.js +1 -1
- package/dist/docker-image-name.js +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,15 +16,15 @@ npm i -D testcontainers
|
|
|
16
16
|
|
|
17
17
|
The following environment variables are supported:
|
|
18
18
|
|
|
19
|
-
- `DEBUG
|
|
20
|
-
- `DEBUG
|
|
21
|
-
- `DEBUG
|
|
22
|
-
- `DOCKER_HOST
|
|
23
|
-
- `TESTCONTAINERS_HOST_OVERRIDE
|
|
24
|
-
- `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
|
|
25
|
-
- `TESTCONTAINERS_RYUK_DISABLED
|
|
26
|
-
- `RYUK_CONTAINER_IMAGE
|
|
27
|
-
- `SSHD_CONTAINER_IMAGE
|
|
19
|
+
- `DEBUG=testcontainers` See output
|
|
20
|
+
- `DEBUG=testcontainers:containers` See container output
|
|
21
|
+
- `DEBUG=testcontainers*` See all output
|
|
22
|
+
- `DOCKER_HOST=tcp://docker:2375` Daemon socket to connect to
|
|
23
|
+
- `TESTCONTAINERS_HOST_OVERRIDE=docker.svc.local` Docker's host on which ports are exposed
|
|
24
|
+
- `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock` Path to Docker's socket. Used by [ryuk](#ryuk) and other [auxiliary containers](#auxiliary-containers) that need to perform Docker actions
|
|
25
|
+
- `TESTCONTAINERS_RYUK_DISABLED=true` Disable [ryuk](#ryuk)
|
|
26
|
+
- `RYUK_CONTAINER_IMAGE=registry.mycompany.com/mirror/ryuk:0.3.0` Custom image for [ryuk](#ryuk)
|
|
27
|
+
- `SSHD_CONTAINER_IMAGE=registry.mycompany.com/mirror/sshd:1.0.0` Custom image for [SSHd](#SSHd)
|
|
28
28
|
|
|
29
29
|
## Modules
|
|
30
30
|
|
|
@@ -68,12 +68,7 @@ describe("GenericContainer", () => {
|
|
|
68
68
|
Using TypeScript:
|
|
69
69
|
|
|
70
70
|
```typescript
|
|
71
|
-
import {
|
|
72
|
-
TestContainer,
|
|
73
|
-
StartedTestContainer,
|
|
74
|
-
StoppedTestContainer,
|
|
75
|
-
GenericContainer
|
|
76
|
-
} from "testcontainers";
|
|
71
|
+
import { TestContainer, StartedTestContainer, StoppedTestContainer, GenericContainer } from "testcontainers";
|
|
77
72
|
|
|
78
73
|
const container: TestContainer = new GenericContainer("alpine");
|
|
79
74
|
const startedContainer: StartedTestContainer = await container.start();
|
|
@@ -20,8 +20,9 @@ const dockerComposeDown = (options) => __awaiter(void 0, void 0, void 0, functio
|
|
|
20
20
|
logger_1.log.info(`Downed DockerCompose environment`);
|
|
21
21
|
}
|
|
22
22
|
catch (err) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const errorMessage = err.err || err.message || err;
|
|
24
|
+
logger_1.log.error(`Failed to down DockerCompose environment: ${errorMessage}`);
|
|
25
|
+
throw new Error(errorMessage);
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
exports.dockerComposeDown = dockerComposeDown;
|
|
@@ -20,8 +20,9 @@ const dockerComposeStop = (options) => __awaiter(void 0, void 0, void 0, functio
|
|
|
20
20
|
logger_1.log.info(`Stopped DockerCompose environment`);
|
|
21
21
|
}
|
|
22
22
|
catch (err) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const errorMessage = err.err || err.message || err;
|
|
24
|
+
logger_1.log.error(`Failed to stop DockerCompose environment: ${errorMessage}`);
|
|
25
|
+
throw new Error(errorMessage);
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
exports.dockerComposeStop = dockerComposeStop;
|
|
@@ -26,14 +26,15 @@ const dockerComposeUp = (options, services) => __awaiter(void 0, void 0, void 0,
|
|
|
26
26
|
logger_1.log.info(`Upped DockerCompose environment`);
|
|
27
27
|
}
|
|
28
28
|
catch (err) {
|
|
29
|
-
|
|
29
|
+
const errorMessage = err.err || err.message || err;
|
|
30
|
+
logger_1.log.error(`Failed to up DockerCompose environment: ${errorMessage}`);
|
|
30
31
|
try {
|
|
31
32
|
yield docker_compose_down_1.dockerComposeDown(options);
|
|
32
33
|
}
|
|
33
34
|
catch (_a) {
|
|
34
35
|
logger_1.log.warn(`Failed to down DockerCompose environment after failed up`);
|
|
35
36
|
}
|
|
36
|
-
throw new Error(
|
|
37
|
+
throw new Error(errorMessage);
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
exports.dockerComposeUp = dockerComposeUp;
|
|
@@ -100,7 +100,7 @@ class DockerComposeEnvironment {
|
|
|
100
100
|
}
|
|
101
101
|
getBoundPorts(containerInfo) {
|
|
102
102
|
const boundPorts = new bound_ports_1.BoundPorts();
|
|
103
|
-
containerInfo.Ports.forEach((port) => boundPorts.setBinding(port.PrivatePort, port.PublicPort));
|
|
103
|
+
containerInfo.Ports.filter((port) => port.PublicPort !== undefined).forEach((port) => boundPorts.setBinding(port.PrivatePort, port.PublicPort));
|
|
104
104
|
return boundPorts;
|
|
105
105
|
}
|
|
106
106
|
waitForContainer(container, containerName, boundPorts) {
|
|
@@ -8,7 +8,15 @@ class DockerImageName {
|
|
|
8
8
|
this.image = image;
|
|
9
9
|
this.tag = tag;
|
|
10
10
|
if (this.registry) {
|
|
11
|
-
|
|
11
|
+
if (this.tag.startsWith("sha256:")) {
|
|
12
|
+
this.string = `${this.registry}/${this.image}@${this.tag}`;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.string = `${this.registry}/${this.image}:${this.tag}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else if (this.tag.startsWith("sha256:")) {
|
|
19
|
+
this.string = `${this.image}@${this.tag}`;
|
|
12
20
|
}
|
|
13
21
|
else {
|
|
14
22
|
this.string = `${this.image}:${this.tag}`;
|