containerify
Advanced tools
Comparing version
@@ -169,3 +169,6 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (options.customContent.length > 0) { | ||
if (Object.entries(options.customContent).length > 0) { | ||
// We only add these layers if they have been explicitely set for customContent. This allows customContent | ||
// to be used to add compiled frontend code to an nginx container without also modifying the entrypoint, user, | ||
// and workdir. | ||
if (options.nonDefaults.workdir) | ||
@@ -179,3 +182,3 @@ yield addWorkdirLayer(options, config, options.nonDefaults.workdir); | ||
yield addLabelsLayer(options, config); | ||
yield addDataLayer(tmpdir, todir, options, config, manifest, options.customContent, "custom"); | ||
yield addDataLayer(tmpdir, todir, options, config, manifest, Object.entries(options.customContent), "custom"); | ||
} | ||
@@ -182,0 +185,0 @@ else { |
@@ -51,3 +51,3 @@ #!/usr/bin/env node | ||
"--allowInsecureRegistries": "Allow insecure registries (with self-signed/untrusted cert)", | ||
"--customContent <dirs/files>": "Optional: Skip normal node_modules and applayer and include specified root folder files/directories instead", | ||
"--customContent <dirs/files>": "Optional: Skip normal node_modules and applayer and include specified root folder files/directories instead. You can specify as local-path:absolute-container-path if you want to place it in a specific location", | ||
"--extraContent <dirs/files>": "Optional: Add specific content. Specify as local-path:absolute-container-path,local-path2:absolute-container-path2 etc", | ||
@@ -59,5 +59,6 @@ "--layerOwner <gid:uid>": "Optional: Set specific gid and uid on files in the added layers", | ||
}; | ||
function setKeyValue(target, keyValue, separator = "=") { | ||
function setKeyValue(target, keyValue, separator = "=", defaultValue) { | ||
var _a; | ||
const [k, v] = keyValue.split(separator, 2); | ||
target[k.trim()] = v.trim(); | ||
target[k.trim()] = (_a = v === null || v === void 0 ? void 0 : v.trim()) !== null && _a !== void 0 ? _a : defaultValue; | ||
} | ||
@@ -119,5 +120,5 @@ const cliLabels = {}; | ||
const envs = Object.assign(Object.assign(Object.assign({}, configFromFile.envs), envOpt), cliEnv); //Let cli arguments override file | ||
const customContent = []; | ||
(_e = configFromFile.customContent) === null || _e === void 0 ? void 0 : _e.forEach((c) => customContent.push(c)); | ||
(_f = cliOptions.customContent) === null || _f === void 0 ? void 0 : _f.split(",").forEach((c) => customContent.push(c)); | ||
const customContent = {}; | ||
(_e = configFromFile.customContent) === null || _e === void 0 ? void 0 : _e.forEach((c) => setKeyValue(customContent, c, ":", c)); | ||
(_f = cliOptions.customContent) === null || _f === void 0 ? void 0 : _f.split(",").forEach((c) => setKeyValue(customContent, c, ":", c)); | ||
const cliExtraContent = {}; | ||
@@ -190,3 +191,3 @@ (_g = cliOptions.extraContent) === null || _g === void 0 ? void 0 : _g.split(",").forEach((x) => setKeyValue(cliExtraContent, x, ":")); | ||
} | ||
options.customContent.forEach((p) => { | ||
Object.keys(options.customContent).forEach((p) => { | ||
exitWithErrorIf(!fs.existsSync(p), "Could not find " + p + " in the base folder " + options.folder); | ||
@@ -193,0 +194,0 @@ }); |
@@ -78,3 +78,3 @@ type Descriptor = { | ||
allowInsecureRegistries?: boolean; | ||
customContent: string[]; | ||
customContent: Record<string, string>; | ||
extraContent: Record<string, string>; | ||
@@ -81,0 +81,0 @@ layerOwner?: string; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "2.5.2"; | ||
export declare const VERSION = "2.6.0"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
exports.VERSION = "2.5.2"; | ||
exports.VERSION = "2.6.0"; |
{ | ||
"name": "containerify", | ||
"version": "2.5.2", | ||
"version": "2.6.0", | ||
"description": "Build node.js docker images without docker", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cli.js", |
@@ -21,2 +21,15 @@ # containerify | ||
### customContent - Adding compiled code to non-node container | ||
If you want to build a non-node container (e.g. add compiled frontend code to an nginx container), you can use `--customContent`. When doing this | ||
the normal `node_modules` etc layers will not be added, and workdir, user and entrypoint will not be overridden (allthough they can be explicitely modified | ||
if needed). | ||
``` | ||
npm run build | ||
containerify --fromImage nginx:alpine --folder . --toImage frontend:latest --customContent dist:/var/www/html --toRegistry https://registry.example.com/v2/ | ||
``` | ||
This will take nginx:alpine and copy the files in `./dist/` into `/var/www/html`. | ||
### Command line options | ||
@@ -23,0 +36,0 @@ |
65043
1.91%1296
0.31%77
20.31%