containerify 2.5.0 → 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.
@@ -167,18 +167,20 @@ function parseCommandLineToParts(entrypoint) {
167
167
  function addAppLayers(options, config, todir, manifest, tmpdir) {
168
168
  return __awaiter(this, void 0, void 0, function* () {
169
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);
170
176
  yield addEnvsLayer(options, config);
171
177
  yield addLabelsLayer(options, config);
172
178
  yield addDataLayer(tmpdir, todir, options, config, manifest, options.customContent, "custom");
173
179
  }
174
180
  else {
175
- addEmptyLayer(config, options, `WORKDIR ${options.workdir}`, (config) => (config.config.WorkingDir = options.workdir));
176
- const entrypoint = parseCommandLineToParts(options.entrypoint);
177
- addEmptyLayer(config, options, `ENTRYPOINT ${JSON.stringify(entrypoint)}`, (config) => (config.config.Entrypoint = entrypoint));
178
- addEmptyLayer(config, options, `USER ${options.user}`, (config) => {
179
- config.config.User = options.user;
180
- config.container_config.User = options.user;
181
- });
181
+ yield addWorkdirLayer(options, config, options.workdir);
182
+ yield addEntrypointLayer(options, config, options.entrypoint);
183
+ yield addUserLayer(options, config, options.user);
182
184
  yield addEnvsLayer(options, config);
183
185
  yield addLabelsLayer(options, config);
184
186
  const appFiles = (yield fs_1.promises.readdir(options.folder)).filter((l) => !ignore.includes(l));
@@ -192,6 +194,25 @@ function addAppLayers(options, config, todir, manifest, tmpdir) {
192
194
  }
193
195
  });
194
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
+ }
195
216
  function addLabelsLayer(options, config) {
196
217
  return __awaiter(this, void 0, void 0, function* () {
197
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 options = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultOptions), configFromFile), cliParams), { customContent,
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
@@ -80,5 +80,10 @@ export type Options = {
80
80
  layerOwner?: string;
81
81
  buildFolder?: string;
82
82
  layerCacheFolder?: string;
83
+ nonDefaults: {
84
+ user?: string;
85
+ workdir?: string;
86
+ entrypoint?: string;
87
+ };
83
88
  };
84
89
  export {};
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "2.5.0";
1
+ export declare const VERSION = "2.5.2";
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "2.5.0";
4
+ exports.VERSION = "2.5.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "containerify",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "Build node.js docker images without docker",
5
5
  "main": "./lib/cli.js",
6
6
  "scripts": {
@@ -18,11 +18,6 @@
18
18
  },
19
19
  "author": "Erlend Oftedal <erlend@oftedal.no>",
20
20
  "license": "Apache-2.0",
21
- "dependencies": {
22
- "commander": "^10.0.0",
23
- "fs-extra": "^11.1.0",
24
- "tar": "^6.1.13"
25
- },
26
21
  "repository": {
27
22
  "type": "git",
28
23
  "url": "https://github.com/eoftedal/containerify.git"
@@ -35,6 +30,11 @@
35
30
  "container",
36
31
  "image"
37
32
  ],
33
+ "dependencies": {
34
+ "commander": "^11.0.0",
35
+ "fs-extra": "^11.1.0",
36
+ "tar": "^6.1.13"
37
+ },
38
38
  "devDependencies": {
39
39
  "@types/fs-extra": "^11.0.1",
40
40
  "@types/minizlib": "^2.1.4",
@@ -45,6 +45,6 @@
45
45
  "eslint": "^8.33.0",
46
46
  "eslint-config-prettier": "^8.6.0",
47
47
  "prettier": "^2.8.3",
48
- "typescript": "^4.9.5"
48
+ "typescript": "^5.1.6"
49
49
  }
50
50
  }