testcontainers 8.10.1 → 8.10.2-beta.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/docker/docker-client.d.ts +1 -1
- package/dist/docker/docker-client.js +8 -1
- package/dist/docker/functions/container/create-container.js +1 -1
- package/dist/docker/functions/container/get-container.js +2 -2
- package/dist/docker/functions/container/list-containers.js +1 -1
- package/dist/docker/functions/demux-stream.js +1 -1
- package/dist/docker/functions/get-info.js +1 -1
- package/dist/docker/functions/image/build-image.js +1 -1
- package/dist/docker/functions/image/list-images.js +1 -1
- package/dist/docker/functions/image/pull-image.js +1 -1
- package/dist/docker/functions/network/connect-network.js +1 -1
- package/dist/docker/functions/network/create-network.js +1 -1
- package/dist/docker/functions/network/remove-network.js +1 -1
- package/dist/docker-compose-environment/docker-compose-environment.js +2 -2
- package/dist/generic-container/generic-container.js +3 -3
- package/dist/port-forwarder.js +1 -1
- package/package.json +1 -1
|
@@ -153,4 +153,11 @@ const findGateway = (dockerode) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
153
153
|
});
|
|
154
154
|
const findDefaultGateway = (dockerode) => __awaiter(void 0, void 0, void 0, function* () { return (0, run_in_container_1.runInContainer)(dockerode, "alpine:3.14", ["sh", "-c", "ip route|awk '/default/ { print $3 }'"]); });
|
|
155
155
|
const isInContainer = () => (0, fs_1.existsSync)("/.dockerenv");
|
|
156
|
-
|
|
156
|
+
let _dockerClient;
|
|
157
|
+
const dockerClient = () => {
|
|
158
|
+
if (!_dockerClient) {
|
|
159
|
+
_dockerClient = getDockerClient();
|
|
160
|
+
}
|
|
161
|
+
return _dockerClient;
|
|
162
|
+
};
|
|
163
|
+
exports.dockerClient = dockerClient;
|
|
@@ -17,7 +17,7 @@ const create_labels_1 = require("../create-labels");
|
|
|
17
17
|
const createContainer = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
try {
|
|
19
19
|
logger_1.log.info(`Creating container for image: ${options.imageName}`);
|
|
20
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
20
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
21
21
|
return yield dockerode.createContainer({
|
|
22
22
|
name: options.name,
|
|
23
23
|
User: options.user,
|
|
@@ -15,7 +15,7 @@ const logger_1 = require("../../../logger");
|
|
|
15
15
|
const labels_1 = require("../../../labels");
|
|
16
16
|
const getContainerById = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
return dockerode.getContainer(id);
|
|
20
20
|
}
|
|
21
21
|
catch (err) {
|
|
@@ -26,7 +26,7 @@ const getContainerById = (id) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
26
26
|
exports.getContainerById = getContainerById;
|
|
27
27
|
const getContainerByHash = (hash) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
try {
|
|
29
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
29
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
30
30
|
const containers = yield dockerode.listContainers({
|
|
31
31
|
limit: 1,
|
|
32
32
|
filters: {
|
|
@@ -14,7 +14,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
14
14
|
const logger_1 = require("../../../logger");
|
|
15
15
|
const listContainers = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
17
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
18
18
|
return yield dockerode.listContainers();
|
|
19
19
|
}
|
|
20
20
|
catch (err) {
|
|
@@ -16,7 +16,7 @@ const docker_client_1 = require("../docker-client");
|
|
|
16
16
|
const demuxStream = (stream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
18
|
const demuxedStream = new stream_1.PassThrough({ autoDestroy: true, encoding: "utf-8" });
|
|
19
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
19
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
20
20
|
dockerode.modem.demuxStream(stream, demuxedStream, demuxedStream);
|
|
21
21
|
stream.on("end", () => demuxedStream.end());
|
|
22
22
|
demuxedStream.on("close", () => {
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getDockerInfo = void 0;
|
|
13
13
|
const docker_client_1 = require("../docker-client");
|
|
14
14
|
const getDockerInfo = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
15
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
16
16
|
const info = yield dockerode.info();
|
|
17
17
|
return {
|
|
18
18
|
serverVersion: info.ServerVersion,
|
|
@@ -36,7 +36,7 @@ const buildImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
39
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
40
40
|
return new Promise((resolve) => dockerode
|
|
41
41
|
.buildImage(tarStream, {
|
|
42
42
|
dockerfile: options.dockerfileName,
|
|
@@ -15,7 +15,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
15
15
|
const logger_1 = require("../../../logger");
|
|
16
16
|
const listImages = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
const images = yield dockerode.listImages();
|
|
20
20
|
return images.reduce((dockerImageNames, image) => {
|
|
21
21
|
var _a;
|
|
@@ -21,7 +21,7 @@ const pullImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
logger_1.log.info(`Pulling image: ${options.imageName}`);
|
|
24
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
24
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
25
25
|
const stream = yield dockerode.pull(options.imageName.toString(), { authconfig: options.authConfig });
|
|
26
26
|
yield new pull_stream_parser_1.PullStreamParser(options.imageName, logger_1.log).consume(stream);
|
|
27
27
|
}
|
|
@@ -15,7 +15,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
15
15
|
const connectNetwork = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
17
|
logger_1.log.info(`Connecting container ${options.containerId} to network ${options.networkId}`);
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
const network = dockerode.getNetwork(options.networkId);
|
|
20
20
|
yield network.connect({ Container: options.containerId, EndpointConfig: { Aliases: options.networkAliases } });
|
|
21
21
|
}
|
|
@@ -16,7 +16,7 @@ const create_labels_1 = require("../create-labels");
|
|
|
16
16
|
const createNetwork = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
try {
|
|
18
18
|
logger_1.log.info(`Creating network ${options.name}`);
|
|
19
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
19
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
20
20
|
const network = yield dockerode.createNetwork({
|
|
21
21
|
Name: options.name,
|
|
22
22
|
CheckDuplicate: options.checkDuplicate,
|
|
@@ -15,7 +15,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
15
15
|
const removeNetwork = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
try {
|
|
17
17
|
logger_1.log.info(`Removing network ${id}`);
|
|
18
|
-
const { dockerode } = yield docker_client_1.dockerClient;
|
|
18
|
+
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
19
19
|
const network = dockerode.getNetwork(id);
|
|
20
20
|
const { message } = yield network.remove();
|
|
21
21
|
if (message) {
|
|
@@ -119,7 +119,7 @@ class DockerComposeEnvironment {
|
|
|
119
119
|
}
|
|
120
120
|
throw err;
|
|
121
121
|
}
|
|
122
|
-
return new started_generic_container_1.StartedGenericContainer(container, (yield docker_client_1.dockerClient).host, inspectResult, boundPorts, containerName);
|
|
122
|
+
return new started_generic_container_1.StartedGenericContainer(container, (yield (0, docker_client_1.dockerClient)()).host, inspectResult, boundPorts, containerName);
|
|
123
123
|
})))).reduce((map, startedGenericContainer) => {
|
|
124
124
|
const containerName = startedGenericContainer.getName();
|
|
125
125
|
return Object.assign(Object.assign({}, map), { [containerName]: startedGenericContainer });
|
|
@@ -130,7 +130,7 @@ class DockerComposeEnvironment {
|
|
|
130
130
|
}
|
|
131
131
|
waitForContainer(container, containerName, boundPorts) {
|
|
132
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
const waitStrategy = this.getWaitStrategy((yield docker_client_1.dockerClient).host, container, containerName);
|
|
133
|
+
const waitStrategy = this.getWaitStrategy((yield (0, docker_client_1.dockerClient)()).host, container, containerName);
|
|
134
134
|
yield waitStrategy.withStartupTimeout(this.startupTimeout).waitUntilReady(container, boundPorts);
|
|
135
135
|
});
|
|
136
136
|
}
|
|
@@ -119,7 +119,7 @@ class GenericContainer {
|
|
|
119
119
|
const inspectResult = yield (0, inspect_container_1.inspectContainer)(startedContainer);
|
|
120
120
|
const boundPorts = bound_ports_1.BoundPorts.fromInspectResult(inspectResult).filter(this.ports);
|
|
121
121
|
yield this.waitForContainer(startedContainer, boundPorts);
|
|
122
|
-
return new started_generic_container_1.StartedGenericContainer(startedContainer, (yield docker_client_1.dockerClient).host, inspectResult, boundPorts, inspectResult.name);
|
|
122
|
+
return new started_generic_container_1.StartedGenericContainer(startedContainer, (yield (0, docker_client_1.dockerClient)()).host, inspectResult, boundPorts, inspectResult.name);
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
startContainer(createContainerOptions) {
|
|
@@ -156,7 +156,7 @@ class GenericContainer {
|
|
|
156
156
|
const inspectResult = yield (0, inspect_container_1.inspectContainer)(container);
|
|
157
157
|
const boundPorts = bound_ports_1.BoundPorts.fromInspectResult(inspectResult).filter(this.ports);
|
|
158
158
|
yield this.waitForContainer(container, boundPorts);
|
|
159
|
-
const startedContainer = new started_generic_container_1.StartedGenericContainer(container, (yield docker_client_1.dockerClient).host, inspectResult, boundPorts, inspectResult.name);
|
|
159
|
+
const startedContainer = new started_generic_container_1.StartedGenericContainer(container, (yield (0, docker_client_1.dockerClient)()).host, inspectResult, boundPorts, inspectResult.name);
|
|
160
160
|
if (this.postStart) {
|
|
161
161
|
yield this.postStart(startedContainer, inspectResult, boundPorts);
|
|
162
162
|
}
|
|
@@ -263,7 +263,7 @@ class GenericContainer {
|
|
|
263
263
|
waitForContainer(container, boundPorts) {
|
|
264
264
|
return __awaiter(this, void 0, void 0, function* () {
|
|
265
265
|
logger_1.log.debug(`Waiting for container to be ready: ${container.id}`);
|
|
266
|
-
const waitStrategy = this.getWaitStrategy((yield docker_client_1.dockerClient).host, container);
|
|
266
|
+
const waitStrategy = this.getWaitStrategy((yield (0, docker_client_1.dockerClient)()).host, container);
|
|
267
267
|
try {
|
|
268
268
|
yield waitStrategy.withStartupTimeout(this.startupTimeout).waitUntilReady(container, boundPorts);
|
|
269
269
|
logger_1.log.info("Container is ready");
|
package/dist/port-forwarder.js
CHANGED
|
@@ -69,7 +69,7 @@ class PortForwarderInstance {
|
|
|
69
69
|
`echo "${username}:$PASSWORD" | chpasswd && /usr/sbin/sshd -D -o PermitRootLogin=yes -o AddressFamily=inet -o GatewayPorts=yes`,
|
|
70
70
|
])
|
|
71
71
|
.start();
|
|
72
|
-
const host = (yield docker_client_1.dockerClient).host;
|
|
72
|
+
const host = (yield (0, docker_client_1.dockerClient)()).host;
|
|
73
73
|
const port = container.getMappedPort(22);
|
|
74
74
|
logger_1.log.debug(`Connecting to Port Forwarder on ${host}:${port}`);
|
|
75
75
|
const connection = yield (0, ssh_remote_port_forward_1.createSshConnection)({ host, port, username, password });
|