containerify 2.5.1 → 2.5.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 +32 -9
- package/lib/cli.js +10 -5
- package/lib/types.d.ts +5 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/appLayerCreator.js
CHANGED
|
@@ -166,19 +166,23 @@ function parseCommandLineToParts(entrypoint) {
|
|
|
166
166
|
}
|
|
167
167
|
function addAppLayers(options, config, todir, manifest, tmpdir) {
|
|
168
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
addEmptyLayer(config, options, `WORKDIR ${options.workdir}`, (config) => (config.config.WorkingDir = options.workdir));
|
|
170
|
-
const entrypoint = parseCommandLineToParts(options.entrypoint);
|
|
171
|
-
addEmptyLayer(config, options, `ENTRYPOINT ${JSON.stringify(entrypoint)}`, (config) => (config.config.Entrypoint = entrypoint));
|
|
172
|
-
addEmptyLayer(config, options, `USER ${options.user}`, (config) => {
|
|
173
|
-
config.config.User = options.user;
|
|
174
|
-
config.container_config.User = options.user;
|
|
175
|
-
});
|
|
176
|
-
yield addEnvsLayer(options, config);
|
|
177
|
-
yield addLabelsLayer(options, config);
|
|
178
169
|
if (options.customContent.length > 0) {
|
|
170
|
+
if (options.nonDefaults.workdir)
|
|
171
|
+
yield addWorkdirLayer(options, config, options.nonDefaults.workdir);
|
|
172
|
+
if (options.nonDefaults.entrypoint)
|
|
173
|
+
yield addEntrypointLayer(options, config, options.nonDefaults.entrypoint);
|
|
174
|
+
if (options.nonDefaults.user)
|
|
175
|
+
yield addUserLayer(options, config, options.nonDefaults.user);
|
|
176
|
+
yield addEnvsLayer(options, config);
|
|
177
|
+
yield addLabelsLayer(options, config);
|
|
179
178
|
yield addDataLayer(tmpdir, todir, options, config, manifest, options.customContent, "custom");
|
|
180
179
|
}
|
|
181
180
|
else {
|
|
181
|
+
yield addWorkdirLayer(options, config, options.workdir);
|
|
182
|
+
yield addEntrypointLayer(options, config, options.entrypoint);
|
|
183
|
+
yield addUserLayer(options, config, options.user);
|
|
184
|
+
yield addEnvsLayer(options, config);
|
|
185
|
+
yield addLabelsLayer(options, config);
|
|
182
186
|
const appFiles = (yield fs_1.promises.readdir(options.folder)).filter((l) => !ignore.includes(l));
|
|
183
187
|
const depLayerContent = appFiles.filter((l) => depLayerPossibles.includes(l));
|
|
184
188
|
const appLayerContent = appFiles.filter((l) => !depLayerPossibles.includes(l));
|
|
@@ -190,6 +194,25 @@ function addAppLayers(options, config, todir, manifest, tmpdir) {
|
|
|
190
194
|
}
|
|
191
195
|
});
|
|
192
196
|
}
|
|
197
|
+
function addWorkdirLayer(options, config, workdir) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
addEmptyLayer(config, options, `WORKDIR ${workdir}`, (config) => (config.config.WorkingDir = workdir));
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function addEntrypointLayer(options, config, entrypoint) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
const entrypointParts = parseCommandLineToParts(entrypoint);
|
|
205
|
+
addEmptyLayer(config, options, `ENTRYPOINT ${JSON.stringify(entrypoint)}`, (config) => (config.config.Entrypoint = entrypointParts));
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function addUserLayer(options, config, user) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
addEmptyLayer(config, options, `USER ${user}`, (config) => {
|
|
211
|
+
config.config.User = user;
|
|
212
|
+
config.container_config.User = user;
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
193
216
|
function addLabelsLayer(options, config) {
|
|
194
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
218
|
if (Object.keys(options.labels).length > 0) {
|
package/lib/cli.js
CHANGED
|
@@ -38,9 +38,9 @@ const possibleArgs = {
|
|
|
38
38
|
"--registry <path>": "Optional: Convenience argument for setting both from and to registry",
|
|
39
39
|
"--platform <platform>": "Optional: Preferred platform, e.g. linux/amd64 or arm64",
|
|
40
40
|
"--token <path>": "Optional: Convenience argument for setting token for both from and to registry",
|
|
41
|
-
"--user <user>": "Optional: User account to run process in container - default: 1000",
|
|
42
|
-
"--workdir <directory>": "Optional: Workdir where node app will be added and run from - default: /app",
|
|
43
|
-
"--entrypoint <entrypoint>": "Optional: Entrypoint when starting container - default: npm start",
|
|
41
|
+
"--user <user>": "Optional: User account to run process in container - default: 1000 (empty for customContent)",
|
|
42
|
+
"--workdir <directory>": "Optional: Workdir where node app will be added and run from - default: /app (empty for customContent)",
|
|
43
|
+
"--entrypoint <entrypoint>": "Optional: Entrypoint when starting container - default: npm start (empty for customContent)",
|
|
44
44
|
"--labels <labels>": "Optional: Comma-separated list of key value pairs to use as labels",
|
|
45
45
|
"--label <label>": "Optional: Single label (name=value). This option can be used multiple times.",
|
|
46
46
|
"--envs <envs>": "Optional: Comma-separated list of key value pairs to use av environment variables.",
|
|
@@ -128,9 +128,14 @@ const cliParams = (0, utils_1.omit)(cliOptions, [
|
|
|
128
128
|
"customContent",
|
|
129
129
|
"extraContent",
|
|
130
130
|
]);
|
|
131
|
-
const
|
|
131
|
+
const setOptions = Object.assign(Object.assign(Object.assign({}, configFromFile), cliParams), { customContent,
|
|
132
132
|
extraContent,
|
|
133
133
|
labels, envs: Object.entries(envs).map(([k, v]) => `${k}=${v}`) });
|
|
134
|
+
const options = Object.assign(Object.assign(Object.assign({}, defaultOptions), setOptions), { nonDefaults: {
|
|
135
|
+
user: setOptions.user,
|
|
136
|
+
workdir: setOptions.workdir,
|
|
137
|
+
entrypoint: setOptions.entrypoint,
|
|
138
|
+
} });
|
|
134
139
|
function exitWithErrorIf(check, error) {
|
|
135
140
|
if (check) {
|
|
136
141
|
logger_1.default.error("ERROR: " + error);
|
|
@@ -196,7 +201,7 @@ if (options.layerCacheFolder) {
|
|
|
196
201
|
options.layerCacheFolder += "/";
|
|
197
202
|
}
|
|
198
203
|
}
|
|
199
|
-
Object.keys(options.extraContent).forEach(k => {
|
|
204
|
+
Object.keys(options.extraContent).forEach((k) => {
|
|
200
205
|
exitWithErrorIf(!fs.existsSync(options.folder + k), "Could not find `" + k + "` in the folder " + options.folder);
|
|
201
206
|
});
|
|
202
207
|
function run(options) {
|
package/lib/types.d.ts
CHANGED
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.5.
|
|
1
|
+
export declare const VERSION = "2.5.2";
|
package/lib/version.js
CHANGED