testcontainers 8.5.1 → 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.
|
@@ -14,17 +14,28 @@ 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, {
|
|
@@ -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
|
+
});
|
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,6 +32,7 @@
|
|
|
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",
|
|
@@ -40,9 +41,7 @@
|
|
|
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,7 +49,6 @@
|
|
|
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",
|
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
|
-
}));
|