containerify 3.3.1 → 3.3.2
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/lib/appLayerCreator.js +19 -33
- package/lib/httpRequest.js +9 -4
- package/lib/registry.js +10 -5
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/lib/appLayerCreator.js
CHANGED
|
@@ -22,39 +22,25 @@ const utils_1 = require("./utils");
|
|
|
22
22
|
const version_1 = require("./version");
|
|
23
23
|
const depLayerPossibles = ["package.json", "package-lock.json", "node_modules"];
|
|
24
24
|
const ignore = [".git", ".gitignore", ".npmrc", ".DS_Store", "npm-debug.log", ".svn", ".hg", "CVS"];
|
|
25
|
-
function
|
|
25
|
+
function createOnWriteEntry(layerOwner) {
|
|
26
26
|
if (!layerOwner)
|
|
27
|
-
return
|
|
28
|
-
// We use
|
|
29
|
-
//
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
stat.birthtime = new Date(0);
|
|
45
|
-
stat.atimeMs = 0;
|
|
46
|
-
stat.mtimeMs = 0;
|
|
47
|
-
stat.ctimeMs = 0;
|
|
48
|
-
stat.birthtimeMs = 0;
|
|
49
|
-
statCacheMap.set(name, stat);
|
|
50
|
-
return stat;
|
|
51
|
-
},
|
|
52
|
-
set: function (name, stat) {
|
|
53
|
-
statCacheMap.set(name, stat);
|
|
54
|
-
},
|
|
55
|
-
has: function () {
|
|
56
|
-
return true;
|
|
57
|
-
},
|
|
27
|
+
return undefined;
|
|
28
|
+
// We use onWriteEntry to overwrite uid and gid in the tar archive
|
|
29
|
+
// Format is already validated in cli.ts to be "gid:uid"
|
|
30
|
+
const parts = layerOwner.split(":");
|
|
31
|
+
const gid = parseInt(parts[0], 10);
|
|
32
|
+
const uid = parseInt(parts[1], 10);
|
|
33
|
+
return (entry) => {
|
|
34
|
+
if (entry.header) {
|
|
35
|
+
entry.header.uid = uid;
|
|
36
|
+
entry.header.gid = gid;
|
|
37
|
+
entry.header.uname = "";
|
|
38
|
+
entry.header.gname = "";
|
|
39
|
+
// Set all timestamps to epoch to match original behavior
|
|
40
|
+
entry.header.atime = new Date(0);
|
|
41
|
+
entry.header.mtime = new Date(0);
|
|
42
|
+
entry.header.ctime = new Date(0);
|
|
43
|
+
}
|
|
58
44
|
};
|
|
59
45
|
}
|
|
60
46
|
const tarDefaultConfig = {
|
|
@@ -127,7 +113,7 @@ function addDataLayer(tmpdir, todir, options, config, manifest, files, comment)
|
|
|
127
113
|
comment +
|
|
128
114
|
(comment == "dependencies" ? ". Did you forget to run npm install?" : ""));
|
|
129
115
|
}
|
|
130
|
-
yield tar.create(Object.assign(Object.assign({}, tarDefaultConfig), Object.assign({
|
|
116
|
+
yield tar.create(Object.assign(Object.assign({}, tarDefaultConfig), Object.assign({ onWriteEntry: createOnWriteEntry(options.layerOwner), portable: !options.layerOwner, prefix: "/", cwd: buildDir, file: layerFile, gzip: true, noMtime: !(options.setTimeStamp || options.preserveTimeStamp) }, (options.setTimeStamp ? { mtime: new Date(options.setTimeStamp) } : {}))), filesToTar);
|
|
131
117
|
const fhash = yield calculateHash(layerFile);
|
|
132
118
|
const finalName = path.join(todir, fhash + ".tar.gz");
|
|
133
119
|
yield fse.move(layerFile, finalName);
|
package/lib/httpRequest.js
CHANGED
|
@@ -20,7 +20,6 @@ exports.dlJson = dlJson;
|
|
|
20
20
|
exports.followRedirects = followRedirects;
|
|
21
21
|
const https = require("https");
|
|
22
22
|
const http = require("http");
|
|
23
|
-
const URL = require("url");
|
|
24
23
|
const logger_1 = require("./logger");
|
|
25
24
|
const types_1 = require("./types");
|
|
26
25
|
exports.redirectCodes = [308, 307, 303, 302, 301];
|
|
@@ -28,9 +27,15 @@ function isOk(httpStatus) {
|
|
|
28
27
|
return httpStatus >= 200 && httpStatus < 300;
|
|
29
28
|
}
|
|
30
29
|
function createHttpOptions(method, url, headers) {
|
|
31
|
-
const
|
|
32
|
-
options
|
|
33
|
-
|
|
30
|
+
const parsedUrl = new URL(url);
|
|
31
|
+
const options = {
|
|
32
|
+
protocol: parsedUrl.protocol,
|
|
33
|
+
hostname: parsedUrl.hostname,
|
|
34
|
+
port: parsedUrl.port,
|
|
35
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
36
|
+
headers: headers,
|
|
37
|
+
method: method,
|
|
38
|
+
};
|
|
34
39
|
if (url.includes("X-Amz-Algorithm") && method == "GET") {
|
|
35
40
|
//We are using a pre-signed URL, so we don't need to send the Authorization header
|
|
36
41
|
options.headers["Authorization"] = "";
|
package/lib/registry.js
CHANGED
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.DEFAULT_DOCKER_REGISTRY = void 0;
|
|
13
13
|
exports.createRegistry = createRegistry;
|
|
14
14
|
exports.parseFullImageUrl = parseFullImageUrl;
|
|
15
|
-
const URL = require("url");
|
|
16
15
|
const fss = require("fs");
|
|
17
16
|
const fs_1 = require("fs");
|
|
18
17
|
const path = require("path");
|
|
@@ -130,7 +129,7 @@ function uploadContent(uploadUrl, file, fileConfig, allowInsecure, auth, content
|
|
|
130
129
|
}
|
|
131
130
|
function processToken(registryBaseUrl, allowInsecure, imagePath, token) {
|
|
132
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
const { hostname } = new URL
|
|
132
|
+
const { hostname } = new URL(registryBaseUrl);
|
|
134
133
|
const image = (0, utils_1.parseImage)(imagePath);
|
|
135
134
|
if ((hostname === null || hostname === void 0 ? void 0 : hostname.endsWith(".docker.io")) && !token)
|
|
136
135
|
return getDockerToken(image.path, allowInsecure);
|
|
@@ -182,8 +181,14 @@ function createRegistry(registryBaseUrl_1, imagePath_1, allowInsecure_1, auth_1)
|
|
|
182
181
|
return new Promise((resolve, reject) => {
|
|
183
182
|
const parameters = new URLSearchParams(mountParameters);
|
|
184
183
|
const url = `${registryBaseUrl}${image.path}/blobs/uploads/${parameters.size > 0 ? "?" + parameters : ""}`;
|
|
185
|
-
const
|
|
186
|
-
options
|
|
184
|
+
const parsedUrl = new URL(url);
|
|
185
|
+
const options = {
|
|
186
|
+
protocol: parsedUrl.protocol,
|
|
187
|
+
hostname: parsedUrl.hostname,
|
|
188
|
+
port: parsedUrl.port,
|
|
189
|
+
path: parsedUrl.pathname + parsedUrl.search,
|
|
190
|
+
method: "POST",
|
|
191
|
+
};
|
|
187
192
|
if (token)
|
|
188
193
|
options.headers = { authorization: token };
|
|
189
194
|
(0, httpRequest_1.request)(options, allowInsecure, (res) => {
|
|
@@ -195,7 +200,7 @@ function createRegistry(registryBaseUrl_1, imagePath_1, allowInsecure_1, auth_1)
|
|
|
195
200
|
resolve({ uploadUrl: location });
|
|
196
201
|
}
|
|
197
202
|
else {
|
|
198
|
-
const regURL = URL
|
|
203
|
+
const regURL = new URL(registryBaseUrl);
|
|
199
204
|
resolve({
|
|
200
205
|
uploadUrl: `${regURL.protocol}//${regURL.hostname}${regURL.port ? ":" + regURL.port : ""}${location}`,
|
|
201
206
|
});
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.3.
|
|
1
|
+
export declare const VERSION = "3.3.2";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "containerify",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"description": "Build node.js docker images without docker",
|
|
5
5
|
"main": "./lib/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"commander": "^13.1.0",
|
|
40
|
-
"fs-extra": "^11.3.
|
|
41
|
-
"tar": "^
|
|
40
|
+
"fs-extra": "^11.3.2",
|
|
41
|
+
"tar": "^7.5.7"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@eslint/eslintrc": "^3.3.1",
|