testcontainers 11.13.0 → 11.14.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.
@@ -9,6 +9,7 @@ export declare class DockerComposeEnvironment {
9
9
  private readonly composeFiles;
10
10
  private projectName;
11
11
  private build;
12
+ private autoCleanup;
12
13
  private recreate;
13
14
  private environmentFile;
14
15
  private profiles;
@@ -20,6 +21,7 @@ export declare class DockerComposeEnvironment {
20
21
  private clientOptions;
21
22
  constructor(composeFilePath: string, composeFiles: string | string[], uuid?: Uuid);
22
23
  withBuild(): this;
24
+ withAutoCleanup(autoCleanup: boolean): this;
23
25
  withEnvironment(environment: Environment): this;
24
26
  withEnvironmentFile(environmentFile: string): this;
25
27
  withProfiles(...profiles: string[]): this;
@@ -16,6 +16,7 @@ class DockerComposeEnvironment {
16
16
  composeFiles;
17
17
  projectName;
18
18
  build = false;
19
+ autoCleanup = true;
19
20
  recreate = true;
20
21
  environmentFile = "";
21
22
  profiles = [];
@@ -34,6 +35,10 @@ class DockerComposeEnvironment {
34
35
  this.build = true;
35
36
  return this;
36
37
  }
38
+ withAutoCleanup(autoCleanup) {
39
+ this.autoCleanup = autoCleanup;
40
+ return this;
41
+ }
37
42
  withEnvironment(environment) {
38
43
  this.environment = { ...this.environment, ...environment };
39
44
  return this;
@@ -78,8 +83,10 @@ class DockerComposeEnvironment {
78
83
  async up(services) {
79
84
  common_1.log.info(`Starting DockerCompose environment "${this.projectName}"...`);
80
85
  const client = await (0, container_runtime_1.getContainerRuntimeClient)();
81
- const reaper = await (0, reaper_1.getReaper)(client);
82
- reaper.addComposeProject(this.projectName);
86
+ if (this.autoCleanup) {
87
+ const reaper = await (0, reaper_1.getReaper)(client);
88
+ reaper.addComposeProject(this.projectName);
89
+ }
83
90
  const { composeOptions: clientComposeOptions = [], commandOptions: clientCommandOptions = [], ...remainingClientOptions } = this.clientOptions;
84
91
  const options = {
85
92
  ...remainingClientOptions,
@@ -18,6 +18,7 @@ export declare class GenericContainer implements TestContainer {
18
18
  protected environment: Record<string, string>;
19
19
  protected exposedPorts: PortWithOptionalBinding[];
20
20
  protected reuse: boolean;
21
+ protected autoCleanup: boolean;
21
22
  protected autoRemove: boolean;
22
23
  protected networkMode?: string;
23
24
  protected networkAliases: string[];
@@ -66,6 +67,7 @@ export declare class GenericContainer implements TestContainer {
66
67
  withPrivilegedMode(): this;
67
68
  withUser(user: string): this;
68
69
  withReuse(): this;
70
+ withAutoCleanup(autoCleanup: boolean): this;
69
71
  withAutoRemove(autoRemove: boolean): this;
70
72
  withPullPolicy(pullPolicy: ImagePullPolicy): this;
71
73
  withIpcMode(ipcMode: string): this;
@@ -35,6 +35,7 @@ class GenericContainer {
35
35
  environment = {};
36
36
  exposedPorts = [];
37
37
  reuse = false;
38
+ autoCleanup = true;
38
39
  autoRemove = true;
39
40
  networkMode;
40
41
  networkAliases = [];
@@ -78,7 +79,7 @@ class GenericContainer {
78
79
  if (process.env.TESTCONTAINERS_REUSE_ENABLE !== "false" && this.reuse) {
79
80
  return this.reuseOrStartContainer(client);
80
81
  }
81
- if (!this.isReaper()) {
82
+ if (!this.isReaper() && this.autoCleanup) {
82
83
  const reaper = await (0, reaper_1.getReaper)(client);
83
84
  this.createOpts.Labels = { ...this.createOpts.Labels, [labels_1.LABEL_TESTCONTAINERS_SESSION_ID]: reaper.sessionId };
84
85
  }
@@ -337,6 +338,10 @@ class GenericContainer {
337
338
  this.reuse = true;
338
339
  return this;
339
340
  }
341
+ withAutoCleanup(autoCleanup) {
342
+ this.autoCleanup = autoCleanup;
343
+ return this;
344
+ }
340
345
  withAutoRemove(autoRemove) {
341
346
  this.autoRemove = autoRemove;
342
347
  return this;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.REAPER_IMAGE = void 0;
4
4
  exports.getReaper = getReaper;
5
5
  const net_1 = require("net");
6
+ const os_1 = require("os");
6
7
  const common_1 = require("../common");
7
8
  const container_runtime_1 = require("../container-runtime");
8
9
  const generic_container_1 = require("../generic-container/generic-container");
@@ -17,7 +18,8 @@ async function getReaper(client) {
17
18
  if (reaper) {
18
19
  return reaper;
19
20
  }
20
- reaper = await (0, common_1.withFileLock)("testcontainers-node.lock", async () => {
21
+ const userId = (0, os_1.userInfo)().uid;
22
+ reaper = await (0, common_1.withFileLock)(`testcontainers-node-${userId}.lock`, async () => {
21
23
  const reaperContainers = await findReaperContainers(client);
22
24
  if (process.env.TESTCONTAINERS_RYUK_DISABLED === "true") {
23
25
  sessionId = new common_1.RandomUuid().nextUuid();
@@ -27,6 +27,7 @@ export interface TestContainer {
27
27
  withUser(user: string): this;
28
28
  withPullPolicy(pullPolicy: ImagePullPolicy): this;
29
29
  withReuse(): this;
30
+ withAutoCleanup(autoCleanup: boolean): this;
30
31
  withAutoRemove(autoRemove: boolean): this;
31
32
  withCopyFilesToContainer(filesToCopy: FileToCopy[]): this;
32
33
  withCopyDirectoriesToContainer(directoriesToCopy: DirectoryToCopy[]): this;
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "11.13.0";
1
+ export declare const LIB_VERSION = "11.14.0";
package/build/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIB_VERSION = void 0;
4
- exports.LIB_VERSION = "11.13.0";
4
+ exports.LIB_VERSION = "11.14.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testcontainers",
3
- "version": "11.13.0",
3
+ "version": "11.14.0",
4
4
  "author": "Cristian Greco",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -36,21 +36,21 @@
36
36
  "async-lock": "^1.4.1",
37
37
  "byline": "^5.0.0",
38
38
  "debug": "^4.4.3",
39
- "docker-compose": "^1.3.2",
40
- "dockerode": "^4.0.9",
41
- "get-port": "^7.1.0",
39
+ "docker-compose": "^1.4.2",
40
+ "dockerode": "^4.0.10",
41
+ "get-port": "^7.2.0",
42
42
  "proper-lockfile": "^4.1.2",
43
43
  "properties-reader": "^3.0.1",
44
44
  "ssh-remote-port-forward": "^1.0.4",
45
45
  "tar-fs": "^3.1.2",
46
46
  "tmp": "^0.2.5",
47
- "undici": "^7.24.3"
47
+ "undici": "^7.24.5"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/archiver": "^7.0.0",
51
51
  "@types/async-lock": "^1.4.2",
52
52
  "@types/byline": "^4.2.36",
53
- "@types/debug": "^4.1.12",
53
+ "@types/debug": "^4.1.13",
54
54
  "@types/proper-lockfile": "^4.1.4",
55
55
  "@types/properties-reader": "^2.1.3",
56
56
  "@types/tar-fs": "^2.0.4",