containerify
Advanced tools
Comparing version 2.5.1 to 2.5.2
@@ -169,15 +169,19 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
addEmptyLayer(config, options, `WORKDIR ${options.workdir}`, (config) => (config.config.WorkingDir = options.workdir)); | ||
const entrypoint = parseCommandLineToParts(options.entrypoint); | ||
addEmptyLayer(config, options, `ENTRYPOINT ${JSON.stringify(entrypoint)}`, (config) => (config.config.Entrypoint = entrypoint)); | ||
addEmptyLayer(config, options, `USER ${options.user}`, (config) => { | ||
config.config.User = options.user; | ||
config.container_config.User = options.user; | ||
}); | ||
yield addEnvsLayer(options, config); | ||
yield addLabelsLayer(options, config); | ||
if (options.customContent.length > 0) { | ||
if (options.nonDefaults.workdir) | ||
yield addWorkdirLayer(options, config, options.nonDefaults.workdir); | ||
if (options.nonDefaults.entrypoint) | ||
yield addEntrypointLayer(options, config, options.nonDefaults.entrypoint); | ||
if (options.nonDefaults.user) | ||
yield addUserLayer(options, config, options.nonDefaults.user); | ||
yield addEnvsLayer(options, config); | ||
yield addLabelsLayer(options, config); | ||
yield addDataLayer(tmpdir, todir, options, config, manifest, options.customContent, "custom"); | ||
} | ||
else { | ||
yield addWorkdirLayer(options, config, options.workdir); | ||
yield addEntrypointLayer(options, config, options.entrypoint); | ||
yield addUserLayer(options, config, options.user); | ||
yield addEnvsLayer(options, config); | ||
yield addLabelsLayer(options, config); | ||
const appFiles = (yield fs_1.promises.readdir(options.folder)).filter((l) => !ignore.includes(l)); | ||
@@ -194,2 +198,21 @@ const depLayerContent = appFiles.filter((l) => depLayerPossibles.includes(l)); | ||
} | ||
function addWorkdirLayer(options, config, workdir) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
addEmptyLayer(config, options, `WORKDIR ${workdir}`, (config) => (config.config.WorkingDir = workdir)); | ||
}); | ||
} | ||
function addEntrypointLayer(options, config, entrypoint) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const entrypointParts = parseCommandLineToParts(entrypoint); | ||
addEmptyLayer(config, options, `ENTRYPOINT ${JSON.stringify(entrypoint)}`, (config) => (config.config.Entrypoint = entrypointParts)); | ||
}); | ||
} | ||
function addUserLayer(options, config, user) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
addEmptyLayer(config, options, `USER ${user}`, (config) => { | ||
config.config.User = user; | ||
config.container_config.User = user; | ||
}); | ||
}); | ||
} | ||
function addLabelsLayer(options, config) { | ||
@@ -196,0 +219,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -41,5 +41,5 @@ #!/usr/bin/env node | ||
"--token <path>": "Optional: Convenience argument for setting token for both from and to registry", | ||
"--user <user>": "Optional: User account to run process in container - default: 1000", | ||
"--workdir <directory>": "Optional: Workdir where node app will be added and run from - default: /app", | ||
"--entrypoint <entrypoint>": "Optional: Entrypoint when starting container - default: npm start", | ||
"--user <user>": "Optional: User account to run process in container - default: 1000 (empty for customContent)", | ||
"--workdir <directory>": "Optional: Workdir where node app will be added and run from - default: /app (empty for customContent)", | ||
"--entrypoint <entrypoint>": "Optional: Entrypoint when starting container - default: npm start (empty for customContent)", | ||
"--labels <labels>": "Optional: Comma-separated list of key value pairs to use as labels", | ||
@@ -132,5 +132,10 @@ "--label <label>": "Optional: Single label (name=value). This option can be used multiple times.", | ||
]); | ||
const options = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultOptions), configFromFile), cliParams), { customContent, | ||
const setOptions = Object.assign(Object.assign(Object.assign({}, configFromFile), cliParams), { customContent, | ||
extraContent, | ||
labels, envs: Object.entries(envs).map(([k, v]) => `${k}=${v}`) }); | ||
const options = Object.assign(Object.assign(Object.assign({}, defaultOptions), setOptions), { nonDefaults: { | ||
user: setOptions.user, | ||
workdir: setOptions.workdir, | ||
entrypoint: setOptions.entrypoint, | ||
} }); | ||
function exitWithErrorIf(check, error) { | ||
@@ -201,3 +206,3 @@ if (check) { | ||
} | ||
Object.keys(options.extraContent).forEach(k => { | ||
Object.keys(options.extraContent).forEach((k) => { | ||
exitWithErrorIf(!fs.existsSync(options.folder + k), "Could not find `" + k + "` in the folder " + options.folder); | ||
@@ -204,0 +209,0 @@ }); |
@@ -83,3 +83,8 @@ type Descriptor = { | ||
layerCacheFolder?: string; | ||
nonDefaults: { | ||
user?: string; | ||
workdir?: string; | ||
entrypoint?: string; | ||
}; | ||
}; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "2.5.1"; | ||
export declare const VERSION = "2.5.2"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
exports.VERSION = "2.5.1"; | ||
exports.VERSION = "2.5.2"; |
{ | ||
"name": "containerify", | ||
"version": "2.5.1", | ||
"version": "2.5.2", | ||
"description": "Build node.js docker images without docker", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cli.js", |
63822
1292