testcontainers 8.4.0 → 8.6.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 +24 -1
- package/dist/docker/functions/container/create-container.d.ts +3 -0
- package/dist/docker/functions/container/create-container.js +1 -1
- package/dist/docker/functions/container/get-container.d.ts +1 -0
- package/dist/docker/functions/container/get-container.js +34 -3
- package/dist/docker/functions/create-labels.d.ts +3 -2
- package/dist/docker/functions/create-labels.js +8 -3
- package/dist/docker/functions/image/build-image.js +27 -5
- package/dist/docker/functions/network/create-network.js +1 -1
- package/dist/generic-container/generic-container.d.ts +4 -0
- package/dist/generic-container/generic-container.js +41 -2
- package/dist/hash.d.ts +1 -0
- package/dist/hash.js +11 -0
- package/dist/labels.d.ts +2 -0
- package/dist/labels.js +5 -0
- package/dist/reaper.js +2 -1
- package/dist/test-container.d.ts +1 -0
- package/package.json +4 -6
- package/dist/docker-ignore.d.ts +0 -1
- package/dist/docker-ignore.js +0 -41
package/README.md
CHANGED
|
@@ -77,7 +77,12 @@ describe("GenericContainer", () => {
|
|
|
77
77
|
Using TypeScript:
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
|
-
import {
|
|
80
|
+
import {
|
|
81
|
+
TestContainer,
|
|
82
|
+
StartedTestContainer,
|
|
83
|
+
StoppedTestContainer,
|
|
84
|
+
GenericContainer
|
|
85
|
+
} from "testcontainers";
|
|
81
86
|
|
|
82
87
|
const container: TestContainer = new GenericContainer("alpine");
|
|
83
88
|
const startedContainer: StartedTestContainer = await container.start();
|
|
@@ -129,6 +134,24 @@ const container = await new GenericContainer("alpine")
|
|
|
129
134
|
.start();
|
|
130
135
|
```
|
|
131
136
|
|
|
137
|
+
Enabling container reuse, note that two containers are considered equal if their options (exposed ports, commands, mounts, etc) match. This also works across multiple processes:
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
const { GenericContainer } = require("testcontainers");
|
|
141
|
+
|
|
142
|
+
const container1 = await new GenericContainer("alpine")
|
|
143
|
+
.withCmd(["sleep", "infinity"])
|
|
144
|
+
.withReuse()
|
|
145
|
+
.start();
|
|
146
|
+
|
|
147
|
+
const container2 = await new GenericContainer("alpine")
|
|
148
|
+
.withCmd(["sleep", "infinity"])
|
|
149
|
+
.withReuse()
|
|
150
|
+
.start();
|
|
151
|
+
|
|
152
|
+
assert(container1.getId() === container2.getId());
|
|
153
|
+
```
|
|
154
|
+
|
|
132
155
|
Creating a container with a specified name:
|
|
133
156
|
|
|
134
157
|
```javascript
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DockerImageName } from "../../../docker-image-name";
|
|
2
2
|
import Dockerode from "dockerode";
|
|
3
3
|
import { PortWithOptionalBinding } from "../../../port";
|
|
4
|
+
import { Labels } from "../create-labels";
|
|
4
5
|
import { BindMount, Command, ContainerName, Env, ExtraHost, HealthCheck, NetworkMode, TmpFs } from "../../types";
|
|
5
6
|
export declare type CreateContainerOptions = {
|
|
6
7
|
imageName: DockerImageName;
|
|
@@ -10,6 +11,8 @@ export declare type CreateContainerOptions = {
|
|
|
10
11
|
tmpFs: TmpFs;
|
|
11
12
|
exposedPorts: PortWithOptionalBinding[];
|
|
12
13
|
name?: ContainerName;
|
|
14
|
+
reusable: boolean;
|
|
15
|
+
labels?: Labels;
|
|
13
16
|
networkMode?: NetworkMode;
|
|
14
17
|
healthCheck?: HealthCheck;
|
|
15
18
|
useDefaultLogDriver: boolean;
|
|
@@ -25,7 +25,7 @@ const createContainer = (options) => __awaiter(void 0, void 0, void 0, function*
|
|
|
25
25
|
Env: getEnv(options.env),
|
|
26
26
|
ExposedPorts: getExposedPorts(options.exposedPorts),
|
|
27
27
|
Cmd: options.cmd,
|
|
28
|
-
Labels: create_labels_1.createLabels(options.imageName),
|
|
28
|
+
Labels: create_labels_1.createLabels(options.reusable, options.imageName, options.labels),
|
|
29
29
|
// @ts-ignore
|
|
30
30
|
Healthcheck: getHealthCheck(options.healthCheck),
|
|
31
31
|
HostConfig: {
|
|
@@ -9,10 +9,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getContainerById = void 0;
|
|
12
|
+
exports.getContainerByHash = exports.getContainerById = void 0;
|
|
13
13
|
const docker_client_1 = require("../../docker-client");
|
|
14
|
+
const logger_1 = require("../../../logger");
|
|
15
|
+
const labels_1 = require("../../../labels");
|
|
14
16
|
const getContainerById = (id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
try {
|
|
18
|
+
const { dockerode } = yield docker_client_1.dockerClient;
|
|
19
|
+
return dockerode.getContainer(id);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
logger_1.log.error(`Failed to get container by ID: ${err}`);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
17
25
|
});
|
|
18
26
|
exports.getContainerById = getContainerById;
|
|
27
|
+
const getContainerByHash = (hash) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
try {
|
|
29
|
+
const { dockerode } = yield docker_client_1.dockerClient;
|
|
30
|
+
const containers = yield dockerode.listContainers({
|
|
31
|
+
limit: 1,
|
|
32
|
+
filters: {
|
|
33
|
+
status: ["running"],
|
|
34
|
+
label: [`${labels_1.LABEL_CONTAINER_HASH}=${hash}`],
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
if (containers.length === 0) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return yield exports.getContainerById(containers[0].Id);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
logger_1.log.error(`Failed to get container by hash (${hash}): ${err}`);
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
exports.getContainerByHash = getContainerByHash;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DockerImageName } from "../../docker-image-name";
|
|
2
|
-
export declare
|
|
3
|
-
[
|
|
2
|
+
export declare type Labels = {
|
|
3
|
+
[key: string]: string;
|
|
4
4
|
};
|
|
5
|
+
export declare const createLabels: (reusable: boolean, dockerImageName?: DockerImageName | undefined, extraLabels?: Labels) => Labels;
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLabels = void 0;
|
|
4
4
|
const session_id_1 = require("../session-id");
|
|
5
|
-
const
|
|
5
|
+
const labels_1 = require("../../labels");
|
|
6
|
+
const createLabels = (reusable, dockerImageName, extraLabels = {}) => {
|
|
7
|
+
const labels = Object.assign({}, extraLabels);
|
|
6
8
|
if (dockerImageName && dockerImageName.isReaper()) {
|
|
7
|
-
return
|
|
9
|
+
return labels;
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
if (!reusable) {
|
|
12
|
+
labels[labels_1.LABEL_SESSION_ID] = session_id_1.sessionId;
|
|
13
|
+
}
|
|
14
|
+
return labels;
|
|
10
15
|
};
|
|
11
16
|
exports.createLabels = createLabels;
|
|
@@ -14,24 +14,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.buildImage = void 0;
|
|
16
16
|
const logger_1 = require("../../../logger");
|
|
17
|
-
const docker_ignore_1 = require("../../../docker-ignore");
|
|
18
17
|
const tar_fs_1 = __importDefault(require("tar-fs"));
|
|
19
|
-
const slash_1 = __importDefault(require("slash"));
|
|
20
18
|
const byline_1 = __importDefault(require("byline"));
|
|
21
19
|
const docker_client_1 = require("../../docker-client");
|
|
22
20
|
const create_labels_1 = require("../create-labels");
|
|
21
|
+
const path_1 = __importDefault(require("path"));
|
|
22
|
+
const fs_1 = require("fs");
|
|
23
|
+
const dockerignore_1 = __importDefault(require("@balena/dockerignore"));
|
|
23
24
|
const buildImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
25
|
try {
|
|
25
26
|
logger_1.log.info(`Building image '${options.imageName.toString()}' with context '${options.context}'`);
|
|
26
|
-
const
|
|
27
|
-
const tarStream = tar_fs_1.default.pack(options.context, {
|
|
27
|
+
const isDockerIgnored = yield createIsDockerIgnoredFunction(options.context);
|
|
28
|
+
const tarStream = tar_fs_1.default.pack(options.context, {
|
|
29
|
+
ignore: (aPath) => {
|
|
30
|
+
const relativePath = path_1.default.relative(options.context, aPath);
|
|
31
|
+
if (relativePath === options.dockerfileName) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return isDockerIgnored(relativePath);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
});
|
|
28
39
|
const { dockerode } = yield docker_client_1.dockerClient;
|
|
29
40
|
return new Promise((resolve) => dockerode
|
|
30
41
|
.buildImage(tarStream, {
|
|
31
42
|
dockerfile: options.dockerfileName,
|
|
32
43
|
buildargs: options.buildArgs,
|
|
33
44
|
t: options.imageName.toString(),
|
|
34
|
-
labels: create_labels_1.createLabels(options.imageName),
|
|
45
|
+
labels: create_labels_1.createLabels(false, options.imageName),
|
|
35
46
|
registryconfig: options.registryConfig,
|
|
36
47
|
pull: options.pullPolicy.shouldPull() ? "any" : undefined,
|
|
37
48
|
})
|
|
@@ -48,3 +59,14 @@ const buildImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
48
59
|
}
|
|
49
60
|
});
|
|
50
61
|
exports.buildImage = buildImage;
|
|
62
|
+
const createIsDockerIgnoredFunction = (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
const dockerIgnoreFilePath = path_1.default.join(context, ".dockerignore");
|
|
64
|
+
if (!fs_1.existsSync(dockerIgnoreFilePath)) {
|
|
65
|
+
return () => false;
|
|
66
|
+
}
|
|
67
|
+
const instance = dockerignore_1.default({ ignorecase: false });
|
|
68
|
+
const dockerIgnorePatterns = yield fs_1.promises.readFile(dockerIgnoreFilePath, { encoding: "utf-8" });
|
|
69
|
+
instance.add(dockerIgnorePatterns);
|
|
70
|
+
const filter = instance.createFilter();
|
|
71
|
+
return (aPath) => !filter(aPath);
|
|
72
|
+
});
|
|
@@ -26,7 +26,7 @@ const createNetwork = (options) => __awaiter(void 0, void 0, void 0, function* (
|
|
|
26
26
|
Ingress: options.ingress,
|
|
27
27
|
EnableIPv6: options.enableIPv6,
|
|
28
28
|
Options: options.options,
|
|
29
|
-
Labels: Object.assign(Object.assign({}, options.labels), create_labels_1.createLabels()),
|
|
29
|
+
Labels: Object.assign(Object.assign({}, options.labels), create_labels_1.createLabels(false)),
|
|
30
30
|
});
|
|
31
31
|
return network.id;
|
|
32
32
|
}
|
|
@@ -29,11 +29,14 @@ export declare class GenericContainer implements TestContainer {
|
|
|
29
29
|
protected ipcMode?: string;
|
|
30
30
|
protected user?: string;
|
|
31
31
|
protected pullPolicy: PullPolicy;
|
|
32
|
+
protected reuse: boolean;
|
|
32
33
|
protected tarToCopy?: archiver.Archiver;
|
|
33
34
|
private extraHosts;
|
|
34
35
|
constructor(image: string);
|
|
35
36
|
protected preStart?(): Promise<void>;
|
|
36
37
|
start(): Promise<StartedTestContainer>;
|
|
38
|
+
private reuseContainer;
|
|
39
|
+
private startContainer;
|
|
37
40
|
protected postStart?(container: StartedTestContainer, inspectResult: InspectResult, boundPorts: BoundPorts): Promise<void>;
|
|
38
41
|
withCmd(cmd: Command[]): this;
|
|
39
42
|
withName(name: ContainerName): this;
|
|
@@ -51,6 +54,7 @@ export declare class GenericContainer implements TestContainer {
|
|
|
51
54
|
withDefaultLogDriver(): this;
|
|
52
55
|
withPrivilegedMode(): this;
|
|
53
56
|
withUser(user: string): this;
|
|
57
|
+
withReuse(): this;
|
|
54
58
|
withPullPolicy(pullPolicy: PullPolicy): this;
|
|
55
59
|
withIpcMode(ipcMode: string): this;
|
|
56
60
|
withCopyFileToContainer(sourcePath: string, containerPath: string): this;
|
|
@@ -35,6 +35,9 @@ const remove_container_1 = require("../docker/functions/container/remove-contain
|
|
|
35
35
|
const put_container_archive_1 = require("../docker/functions/container/put-container-archive");
|
|
36
36
|
const generic_container_builder_1 = require("./generic-container-builder");
|
|
37
37
|
const started_generic_container_1 = require("./started-generic-container");
|
|
38
|
+
const hash_1 = require("../hash");
|
|
39
|
+
const get_container_1 = require("../docker/functions/container/get-container");
|
|
40
|
+
const labels_1 = require("../labels");
|
|
38
41
|
class GenericContainer {
|
|
39
42
|
constructor(image) {
|
|
40
43
|
this.image = image;
|
|
@@ -48,6 +51,7 @@ class GenericContainer {
|
|
|
48
51
|
this.useDefaultLogDriver = false;
|
|
49
52
|
this.privilegedMode = false;
|
|
50
53
|
this.pullPolicy = new pull_policy_1.DefaultPullPolicy();
|
|
54
|
+
this.reuse = false;
|
|
51
55
|
this.extraHosts = [];
|
|
52
56
|
this.imageName = docker_image_name_1.DockerImageName.fromString(image);
|
|
53
57
|
}
|
|
@@ -71,7 +75,7 @@ class GenericContainer {
|
|
|
71
75
|
const portForwarder = yield port_forwarder_1.PortForwarderInstance.getInstance();
|
|
72
76
|
this.extraHosts.push({ host: "host.testcontainers.internal", ipAddress: portForwarder.getIpAddress() });
|
|
73
77
|
}
|
|
74
|
-
const
|
|
78
|
+
const createContainerOptions = {
|
|
75
79
|
imageName: this.imageName,
|
|
76
80
|
env: this.env,
|
|
77
81
|
cmd: this.cmd,
|
|
@@ -79,6 +83,7 @@ class GenericContainer {
|
|
|
79
83
|
tmpFs: this.tmpFs,
|
|
80
84
|
exposedPorts: this.ports,
|
|
81
85
|
name: this.name,
|
|
86
|
+
reusable: this.reuse,
|
|
82
87
|
networkMode: this.networkAliases.length > 0 ? undefined : this.networkMode,
|
|
83
88
|
healthCheck: this.healthCheck,
|
|
84
89
|
useDefaultLogDriver: this.useDefaultLogDriver,
|
|
@@ -87,7 +92,37 @@ class GenericContainer {
|
|
|
87
92
|
extraHosts: this.extraHosts,
|
|
88
93
|
ipcMode: this.ipcMode,
|
|
89
94
|
user: this.user,
|
|
90
|
-
}
|
|
95
|
+
};
|
|
96
|
+
if (this.reuse) {
|
|
97
|
+
const containerHash = hash_1.hash(JSON.stringify(createContainerOptions));
|
|
98
|
+
createContainerOptions.labels = { [labels_1.LABEL_CONTAINER_HASH]: containerHash };
|
|
99
|
+
logger_1.log.debug(`Container reuse has been enabled, hash: ${containerHash}`);
|
|
100
|
+
const container = yield get_container_1.getContainerByHash(containerHash);
|
|
101
|
+
if (container !== undefined) {
|
|
102
|
+
logger_1.log.debug(`Found container to reuse with hash: ${containerHash}`);
|
|
103
|
+
return this.reuseContainer(container);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
logger_1.log.debug("No container found to reuse");
|
|
107
|
+
return this.startContainer(createContainerOptions);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return this.startContainer(createContainerOptions);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
reuseContainer(startedContainer) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const inspectResult = yield inspect_container_1.inspectContainer(startedContainer);
|
|
118
|
+
const boundPorts = bound_ports_1.BoundPorts.fromInspectResult(inspectResult).filter(this.ports);
|
|
119
|
+
yield this.waitForContainer(startedContainer, boundPorts);
|
|
120
|
+
return new started_generic_container_1.StartedGenericContainer(startedContainer, (yield docker_client_1.dockerClient).host, inspectResult, boundPorts, inspectResult.name);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
startContainer(createContainerOptions) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const container = yield create_container_1.createContainer(createContainerOptions);
|
|
91
126
|
if (!this.imageName.isHelperContainer() && port_forwarder_1.PortForwarderInstance.isRunning()) {
|
|
92
127
|
const portForwarder = yield port_forwarder_1.PortForwarderInstance.getInstance();
|
|
93
128
|
const portForwarderNetworkId = portForwarder.getNetworkId();
|
|
@@ -190,6 +225,10 @@ class GenericContainer {
|
|
|
190
225
|
this.user = user;
|
|
191
226
|
return this;
|
|
192
227
|
}
|
|
228
|
+
withReuse() {
|
|
229
|
+
this.reuse = true;
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
193
232
|
withPullPolicy(pullPolicy) {
|
|
194
233
|
this.pullPolicy = pullPolicy;
|
|
195
234
|
return this;
|
package/dist/hash.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hash: (str: string) => string;
|
package/dist/hash.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.hash = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const hash = (str) => {
|
|
9
|
+
return crypto_1.default.createHash("md5").update(str).digest("hex");
|
|
10
|
+
};
|
|
11
|
+
exports.hash = hash;
|
package/dist/labels.d.ts
ADDED
package/dist/labels.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LABEL_CONTAINER_HASH = exports.LABEL_SESSION_ID = void 0;
|
|
4
|
+
exports.LABEL_SESSION_ID = "org.testcontainers.session-id";
|
|
5
|
+
exports.LABEL_CONTAINER_HASH = "org.testcontainers.container-hash";
|
package/dist/reaper.js
CHANGED
|
@@ -17,6 +17,7 @@ const session_id_1 = require("./docker/session-id");
|
|
|
17
17
|
const docker_client_1 = require("./docker/docker-client");
|
|
18
18
|
const images_1 = require("./images");
|
|
19
19
|
const port_1 = require("./port");
|
|
20
|
+
const labels_1 = require("./labels");
|
|
20
21
|
class RealReaper {
|
|
21
22
|
constructor(container, socket) {
|
|
22
23
|
this.container = container;
|
|
@@ -109,7 +110,7 @@ class ReaperInstance {
|
|
|
109
110
|
return new Promise((resolve) => {
|
|
110
111
|
socket.connect(port_1.getContainerPort(port), host, () => {
|
|
111
112
|
logger_1.log.debug(`Connected to Reaper ${containerId}`);
|
|
112
|
-
socket.write(`label
|
|
113
|
+
socket.write(`label=${labels_1.LABEL_SESSION_ID}=${session_id_1.sessionId}\r\n`);
|
|
113
114
|
const reaper = new RealReaper(startedContainer, socket);
|
|
114
115
|
resolve(reaper);
|
|
115
116
|
});
|
package/dist/test-container.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface TestContainer {
|
|
|
19
19
|
withPrivilegedMode(): this;
|
|
20
20
|
withUser(user: string): this;
|
|
21
21
|
withPullPolicy(pullPolicy: PullPolicy): this;
|
|
22
|
+
withReuse(): this;
|
|
22
23
|
withCopyFileToContainer(sourcePath: string, containerPath: string): this;
|
|
23
24
|
withCopyContentToContainer(content: string | Buffer | Readable, containerPath: string): this;
|
|
24
25
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testcontainers",
|
|
3
3
|
"author": "Cristian Greco",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.6.0",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"keywords": [
|
|
@@ -32,17 +32,16 @@
|
|
|
32
32
|
"updateDeps": "npx npm-check-updates -u"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@balena/dockerignore": "^1.0.2",
|
|
35
36
|
"@types/archiver": "^5.1.1",
|
|
36
37
|
"@types/dockerode": "^3.2.7",
|
|
37
38
|
"archiver": "^5.3.0",
|
|
38
39
|
"byline": "^5.0.0",
|
|
39
|
-
"debug": "^4.3.
|
|
40
|
+
"debug": "^4.3.4",
|
|
40
41
|
"docker-compose": "^0.23.17",
|
|
41
42
|
"dockerode": "^3.3.1",
|
|
42
43
|
"get-port": "^5.1.1",
|
|
43
|
-
"glob": "^7.2.0",
|
|
44
44
|
"properties-reader": "^2.2.0",
|
|
45
|
-
"slash": "^3.0.0",
|
|
46
45
|
"ssh-remote-port-forward": "^1.0.4",
|
|
47
46
|
"tar-fs": "^2.1.1"
|
|
48
47
|
},
|
|
@@ -50,11 +49,10 @@
|
|
|
50
49
|
"@elastic/elasticsearch": "^7.14.1",
|
|
51
50
|
"@types/byline": "^4.2.33",
|
|
52
51
|
"@types/debug": "4.1.7",
|
|
53
|
-
"@types/glob": "^7.1.4",
|
|
54
52
|
"@types/jest": "^27.0.3",
|
|
55
53
|
"@types/node": "^16.9.6",
|
|
56
54
|
"@types/node-fetch": "^2.5.12",
|
|
57
|
-
"@types/pg": "^8.6.
|
|
55
|
+
"@types/pg": "^8.6.5",
|
|
58
56
|
"@types/properties-reader": "^2.1.1",
|
|
59
57
|
"@types/tar-fs": "^2.0.1",
|
|
60
58
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
package/dist/docker-ignore.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const findDockerIgnoreFiles: (context: string, dockerfileName: string) => Promise<Set<string>>;
|
package/dist/docker-ignore.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.findDockerIgnoreFiles = void 0;
|
|
16
|
-
const fs_1 = require("fs");
|
|
17
|
-
const os_1 = __importDefault(require("os"));
|
|
18
|
-
const glob_1 = __importDefault(require("glob"));
|
|
19
|
-
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const findDockerIgnoreFiles = (context, dockerfileName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
const dockerIgnoreFilePath = path_1.default.join(context, ".dockerignore");
|
|
22
|
-
if (!fs_1.existsSync(dockerIgnoreFilePath)) {
|
|
23
|
-
return new Set();
|
|
24
|
-
}
|
|
25
|
-
const dockerIgnorePatterns = (yield fs_1.promises.readFile(dockerIgnoreFilePath, { encoding: "utf-8" }))
|
|
26
|
-
.toString()
|
|
27
|
-
.split(os_1.default.EOL)
|
|
28
|
-
.filter((dockerIgnorePattern) => dockerIgnorePattern !== dockerfileName)
|
|
29
|
-
.map((dockerIgnorePattern) => path_1.default.resolve(context, dockerIgnorePattern));
|
|
30
|
-
const dockerIgnoreMatches = (yield Promise.all(dockerIgnorePatterns.map(findIgnoredFilesForPattern))).reduce((prev, next) => [...prev, ...next]);
|
|
31
|
-
return new Set(dockerIgnoreMatches);
|
|
32
|
-
});
|
|
33
|
-
exports.findDockerIgnoreFiles = findDockerIgnoreFiles;
|
|
34
|
-
const findIgnoredFilesForPattern = (dockerIgnorePattern) => new Promise((resolve, reject) => glob_1.default(dockerIgnorePattern, (err, matches) => {
|
|
35
|
-
if (err) {
|
|
36
|
-
return reject(err);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
resolve(matches);
|
|
40
|
-
}
|
|
41
|
-
}));
|