containerify 2.5.2 → 2.6.0
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/README.md +13 -0
- package/lib/appLayerCreator.js +5 -2
- package/lib/cli.js +8 -7
- package/lib/types.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,19 @@ This will pull the `node:13-slim` image from Docker hub, build the image by addi
|
|
|
18
18
|
containerify --fromImage node:13-slim --folder src/ --toImage myapp:latest --toRegistry https://registry.example.com/v2/ --setTimeStamp=$(git show -s --format="%aI" HEAD)
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
### customContent - Adding compiled code to non-node container
|
|
22
|
+
|
|
23
|
+
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
|
|
24
|
+
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
|
|
25
|
+
if needed).
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
npm run build
|
|
29
|
+
containerify --fromImage nginx:alpine --folder . --toImage frontend:latest --customContent dist:/var/www/html --toRegistry https://registry.example.com/v2/
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This will take nginx:alpine and copy the files in `./dist/` into `/var/www/html`.
|
|
33
|
+
|
|
21
34
|
### Command line options
|
|
22
35
|
|
|
23
36
|
```
|
package/lib/appLayerCreator.js
CHANGED
|
@@ -166,7 +166,10 @@ 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
|
-
if (options.customContent.length > 0) {
|
|
169
|
+
if (Object.entries(options.customContent).length > 0) {
|
|
170
|
+
// We only add these layers if they have been explicitely set for customContent. This allows customContent
|
|
171
|
+
// to be used to add compiled frontend code to an nginx container without also modifying the entrypoint, user,
|
|
172
|
+
// and workdir.
|
|
170
173
|
if (options.nonDefaults.workdir)
|
|
171
174
|
yield addWorkdirLayer(options, config, options.nonDefaults.workdir);
|
|
172
175
|
if (options.nonDefaults.entrypoint)
|
|
@@ -175,7 +178,7 @@ function addAppLayers(options, config, todir, manifest, tmpdir) {
|
|
|
175
178
|
yield addUserLayer(options, config, options.nonDefaults.user);
|
|
176
179
|
yield addEnvsLayer(options, config);
|
|
177
180
|
yield addLabelsLayer(options, config);
|
|
178
|
-
yield addDataLayer(tmpdir, todir, options, config, manifest, options.customContent, "custom");
|
|
181
|
+
yield addDataLayer(tmpdir, todir, options, config, manifest, Object.entries(options.customContent), "custom");
|
|
179
182
|
}
|
|
180
183
|
else {
|
|
181
184
|
yield addWorkdirLayer(options, config, options.workdir);
|
package/lib/cli.js
CHANGED
|
@@ -48,16 +48,17 @@ const possibleArgs = {
|
|
|
48
48
|
"--setTimeStamp <timestamp>": "Optional: Set a specific ISO 8601 timestamp on all entries (e.g. git commit hash). Default: 1970 in tar files, and current time on manifest/config",
|
|
49
49
|
"--verbose": "Verbose logging",
|
|
50
50
|
"--allowInsecureRegistries": "Allow insecure registries (with self-signed/untrusted cert)",
|
|
51
|
-
"--customContent <dirs/files>": "Optional: Skip normal node_modules and applayer and include specified root folder files/directories instead",
|
|
51
|
+
"--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",
|
|
52
52
|
"--extraContent <dirs/files>": "Optional: Add specific content. Specify as local-path:absolute-container-path,local-path2:absolute-container-path2 etc",
|
|
53
53
|
"--layerOwner <gid:uid>": "Optional: Set specific gid and uid on files in the added layers",
|
|
54
54
|
"--buildFolder <path>": "Optional: Use a specific build folder when creating the image",
|
|
55
55
|
"--layerCacheFolder <path>": "Optional: Folder to cache base layers between builds",
|
|
56
56
|
"--version": "Get containerify version",
|
|
57
57
|
};
|
|
58
|
-
function setKeyValue(target, keyValue, separator = "=") {
|
|
58
|
+
function setKeyValue(target, keyValue, separator = "=", defaultValue) {
|
|
59
|
+
var _a;
|
|
59
60
|
const [k, v] = keyValue.split(separator, 2);
|
|
60
|
-
target[k.trim()] = v.trim();
|
|
61
|
+
target[k.trim()] = (_a = v === null || v === void 0 ? void 0 : v.trim()) !== null && _a !== void 0 ? _a : defaultValue;
|
|
61
62
|
}
|
|
62
63
|
const cliLabels = {};
|
|
63
64
|
commander_1.program.on("option:label", (ops) => {
|
|
@@ -114,9 +115,9 @@ Object.keys(envOpt)
|
|
|
114
115
|
exitWithErrorIf(true, `Env ${l} specified both with --envs and --env`);
|
|
115
116
|
});
|
|
116
117
|
const envs = Object.assign(Object.assign(Object.assign({}, configFromFile.envs), envOpt), cliEnv); //Let cli arguments override file
|
|
117
|
-
const customContent =
|
|
118
|
-
(_e = configFromFile.customContent) === null || _e === void 0 ? void 0 : _e.forEach((c) => customContent
|
|
119
|
-
(_f = cliOptions.customContent) === null || _f === void 0 ? void 0 : _f.split(",").forEach((c) => customContent
|
|
118
|
+
const customContent = {};
|
|
119
|
+
(_e = configFromFile.customContent) === null || _e === void 0 ? void 0 : _e.forEach((c) => setKeyValue(customContent, c, ":", c));
|
|
120
|
+
(_f = cliOptions.customContent) === null || _f === void 0 ? void 0 : _f.split(",").forEach((c) => setKeyValue(customContent, c, ":", c));
|
|
120
121
|
const cliExtraContent = {};
|
|
121
122
|
(_g = cliOptions.extraContent) === null || _g === void 0 ? void 0 : _g.split(",").forEach((x) => setKeyValue(cliExtraContent, x, ":"));
|
|
122
123
|
const extraContent = Object.assign(Object.assign({}, configFromFile.extraContent), cliExtraContent);
|
|
@@ -184,7 +185,7 @@ if (options.fromRegistry && !options.fromRegistry.endsWith("/"))
|
|
|
184
185
|
if (!options.fromRegistry && !((_k = (_j = (_h = options.fromImage) === null || _h === void 0 ? void 0 : _h.split(":")) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.includes("/"))) {
|
|
185
186
|
options.fromImage = "library/" + options.fromImage;
|
|
186
187
|
}
|
|
187
|
-
options.customContent.forEach((p) => {
|
|
188
|
+
Object.keys(options.customContent).forEach((p) => {
|
|
188
189
|
exitWithErrorIf(!fs.existsSync(p), "Could not find " + p + " in the base folder " + options.folder);
|
|
189
190
|
});
|
|
190
191
|
if (options.layerCacheFolder) {
|
package/lib/types.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export type Options = {
|
|
|
75
75
|
setTimeStamp?: string;
|
|
76
76
|
verbose?: boolean;
|
|
77
77
|
allowInsecureRegistries?: boolean;
|
|
78
|
-
customContent: string
|
|
78
|
+
customContent: Record<string, string>;
|
|
79
79
|
extraContent: Record<string, string>;
|
|
80
80
|
layerOwner?: string;
|
|
81
81
|
buildFolder?: string;
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.
|
|
1
|
+
export declare const VERSION = "2.6.0";
|
package/lib/version.js
CHANGED