testcontainers 8.8.0 → 8.8.1-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/README.md CHANGED
@@ -18,18 +18,26 @@ npm i -D testcontainers
18
18
 
19
19
  The following environment variables are supported:
20
20
 
21
+ ### Logs
22
+
21
23
  - `DEBUG=testcontainers` Enable testcontainers logs
22
24
  - `DEBUG=testcontainers:containers` Enable container logs
23
25
  - `DEBUG=testcontainers*` Enable all logs
26
+
27
+ ### Docker
28
+
24
29
  - `DOCKER_HOST=tcp://docker:2375` Sets the URL of the docker daemon
25
30
  - `DOCKER_TLS_VERIFY=1` When set to `1`, enables TLS communication with the docker
26
31
  daemon
27
32
  - `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
- - `DOCKER_CONFIG=/some/path` Configures the path to the `config.json`. Defaults to `~/.docker`
33
+ verification
34
+ - `DOCKER_CONFIG=/some/path` Configures the path to the `config.json`
30
35
  - `TESTCONTAINERS_HOST_OVERRIDE=docker.svc.local` Docker's host on which ports are exposed
31
36
  - `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock` Path to Docker's socket. Used by [ryuk](#ryuk) and
32
37
  other [auxiliary containers](#auxiliary-containers) that need to perform Docker actions
38
+
39
+ ### Testcontainers
40
+
33
41
  - `TESTCONTAINERS_RYUK_PRIVILEGED=true` Run [ryuk](#ryuk) as a privileged container
34
42
  - `TESTCONTAINERS_RYUK_DISABLED=true` Disable [ryuk](#ryuk)
35
43
  - `RYUK_CONTAINER_IMAGE=registry.mycompany.com/mirror/ryuk:0.3.0` Custom image for [ryuk](#ryuk)
@@ -60,18 +60,21 @@ class ConfigurationStrategy {
60
60
  return __awaiter(this, void 0, void 0, function* () {
61
61
  const { DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH } = process.env;
62
62
  const dockerOptions = {};
63
- const url = new url_1.URL(DOCKER_HOST);
64
- const dockerHost = url.host === "" ? `tcp://${DOCKER_HOST}` : DOCKER_HOST;
65
- const { hostname, port } = new url_1.URL(dockerHost);
66
- dockerOptions.host = hostname;
67
- dockerOptions.port = port;
63
+ const { hostname, port } = new url_1.URL(DOCKER_HOST);
64
+ if (hostname !== "") {
65
+ dockerOptions.host = hostname;
66
+ dockerOptions.port = port;
67
+ }
68
+ else {
69
+ dockerOptions.socketPath = DOCKER_HOST;
70
+ }
68
71
  if (DOCKER_TLS_VERIFY === "1" && DOCKER_CERT_PATH !== undefined) {
69
72
  dockerOptions.ca = yield fs_1.promises.readFile(path_1.default.resolve(DOCKER_CERT_PATH, "ca.pem"));
70
73
  dockerOptions.cert = yield fs_1.promises.readFile(path_1.default.resolve(DOCKER_CERT_PATH, "cert.pem"));
71
74
  dockerOptions.key = yield fs_1.promises.readFile(path_1.default.resolve(DOCKER_CERT_PATH, "key.pem"));
72
75
  }
73
76
  return {
74
- uri: dockerHost,
77
+ uri: DOCKER_HOST,
75
78
  dockerode: new dockerode_1.default(dockerOptions),
76
79
  };
77
80
  });
@@ -39,6 +39,7 @@ export declare class GenericContainer implements TestContainer {
39
39
  private reuseContainer;
40
40
  private startContainer;
41
41
  protected postStart?(container: StartedTestContainer, inspectResult: InspectResult, boundPorts: BoundPorts): Promise<void>;
42
+ protected get hasExposedPorts(): boolean;
42
43
  withCmd(cmd: Command[]): this;
43
44
  withName(name: ContainerName): this;
44
45
  withLabels(labels: Labels): this;
@@ -163,6 +163,9 @@ class GenericContainer {
163
163
  return startedContainer;
164
164
  });
165
165
  }
166
+ get hasExposedPorts() {
167
+ return this.ports.length !== 0;
168
+ }
166
169
  withCmd(cmd) {
167
170
  this.cmd = cmd;
168
171
  return this;
@@ -13,7 +13,7 @@ exports.StartedArangoContainer = exports.ArangoDBContainer = void 0;
13
13
  const __1 = require("../..");
14
14
  const uuid_1 = require("../../uuid");
15
15
  const abstract_started_container_1 = require("../abstract-started-container");
16
- const PORT = 8529;
16
+ const ARANGODB_PORT = 8529;
17
17
  const USERNAME = "root";
18
18
  class ArangoDBContainer extends __1.GenericContainer {
19
19
  constructor(image = "arangodb:3.7.13", password = new uuid_1.RandomUuid().nextUuid()) {
@@ -29,7 +29,7 @@ class ArangoDBContainer extends __1.GenericContainer {
29
29
  start: { get: () => super.start }
30
30
  });
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- this.withExposedPorts(PORT)
32
+ this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [ARANGODB_PORT]))
33
33
  .withWaitStrategy(__1.Wait.forLogMessage("Have fun!"))
34
34
  .withEnv("ARANGO_ROOT_PASSWORD", this.password)
35
35
  .withStartupTimeout(120000);
@@ -43,7 +43,7 @@ class StartedArangoContainer extends abstract_started_container_1.AbstractStarte
43
43
  super(startedTestContainer);
44
44
  this.password = password;
45
45
  this.host = this.startedTestContainer.getHost();
46
- this.port = this.startedTestContainer.getMappedPort(PORT);
46
+ this.port = this.startedTestContainer.getMappedPort(ARANGODB_PORT);
47
47
  }
48
48
  getTcpUrl() {
49
49
  return `tcp://${this.host}:${this.port}/`;
@@ -22,7 +22,7 @@ class ElasticsearchContainer extends __1.GenericContainer {
22
22
  start: { get: () => super.start }
23
23
  });
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
- this.withExposedPorts(ELASTIC_SEARCH_HTTP_PORT)
25
+ this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [ELASTIC_SEARCH_HTTP_PORT]))
26
26
  .withEnv("discovery.type", "single-node")
27
27
  .withStartupTimeout(120000);
28
28
  return new StartedElasticsearchContainer(yield _super.start.call(this));
@@ -13,6 +13,7 @@ exports.StartedMySqlContainer = exports.MySqlContainer = void 0;
13
13
  const generic_container_1 = require("../../generic-container/generic-container");
14
14
  const uuid_1 = require("../../uuid");
15
15
  const abstract_started_container_1 = require("../abstract-started-container");
16
+ const MYSQL_PORT = 3306;
16
17
  class MySqlContainer extends generic_container_1.GenericContainer {
17
18
  constructor(image = "mysql:8.0.26") {
18
19
  super(image);
@@ -42,7 +43,7 @@ class MySqlContainer extends generic_container_1.GenericContainer {
42
43
  start: { get: () => super.start }
43
44
  });
44
45
  return __awaiter(this, void 0, void 0, function* () {
45
- this.withExposedPorts(3306)
46
+ this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [MYSQL_PORT]))
46
47
  .withEnv("MYSQL_DATABASE", this.database)
47
48
  .withEnv("MYSQL_ROOT_PASSWORD", this.rootPassword)
48
49
  .withEnv("MYSQL_USER", this.username)
@@ -39,7 +39,7 @@ class Neo4jContainer extends __1.GenericContainer {
39
39
  start: { get: () => super.start }
40
40
  });
41
41
  return __awaiter(this, void 0, void 0, function* () {
42
- this.withExposedPorts(BOLT_PORT, HTTP_PORT)
42
+ this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [BOLT_PORT, HTTP_PORT]))
43
43
  .withWaitStrategy(__1.Wait.forLogMessage("Started."))
44
44
  .withEnv("NEO4J_AUTH", `${USERNAME}/${this.password}`)
45
45
  .withStartupTimeout(120000);
@@ -13,6 +13,7 @@ exports.StartedPostgreSqlContainer = exports.PostgreSqlContainer = void 0;
13
13
  const generic_container_1 = require("../../generic-container/generic-container");
14
14
  const uuid_1 = require("../../uuid");
15
15
  const abstract_started_container_1 = require("../abstract-started-container");
16
+ const POSTGRES_PORT = 5432;
16
17
  class PostgreSqlContainer extends generic_container_1.GenericContainer {
17
18
  constructor(image = "postgres:13.3-alpine") {
18
19
  super(image);
@@ -37,7 +38,7 @@ class PostgreSqlContainer extends generic_container_1.GenericContainer {
37
38
  start: { get: () => super.start }
38
39
  });
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
- this.withExposedPorts(5432)
41
+ this.withExposedPorts(...(this.hasExposedPorts ? this.ports : [POSTGRES_PORT]))
41
42
  .withEnv("POSTGRES_DB", this.database)
42
43
  .withEnv("POSTGRES_USER", this.username)
43
44
  .withEnv("POSTGRES_PASSWORD", this.password)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "testcontainers",
3
3
  "author": "Cristian Greco",
4
- "version": "8.8.0",
4
+ "version": "8.8.1-beta.0",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index",
7
7
  "keywords": [