diff --git a/CHANGELOG.md b/CHANGELOG.md index a15aab1..a964d6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,18 @@ # Changelog -## [2.5.1] - TBD +## [2.5.2] - 2023-10-11 + +### Fixed + +- Reverting 2.5.1, but allowing `ENTRYPOINT`, `WORKDIR` and `USER` to be explicitely set when using `customContent` + +## [2.5.1] - 2023-10-11 ### Fixed - Layers for `ENTRYPOINT`, `WORKDIR` and user information are now being added when using `customContent` -## [2.5.0] - TBD +## [2.5.0] - 2023-07-07 ### Added diff --git a/package-lock.json b/package-lock.json index 070d232..8eb8ac9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "containerify", - "version": "2.5.1", + "version": "2.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "containerify", - "version": "2.5.1", + "version": "2.5.2", "license": "Apache-2.0", "dependencies": { "commander": "^11.0.0", diff --git a/package.json b/package.json index f17098b..fe6e867 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "containerify", - "version": "2.5.1", + "version": "2.5.2", "description": "Build node.js docker images without docker", "main": "./lib/cli.js", "scripts": { diff --git a/src/appLayerCreator.ts b/src/appLayerCreator.ts index e635520..d9126b9 100644 --- a/src/appLayerCreator.ts +++ b/src/appLayerCreator.ts @@ -185,28 +185,19 @@ function parseCommandLineToParts(entrypoint: string) { } async function addAppLayers(options: Options, config: Config, todir: string, manifest: Manifest, tmpdir: string) { - 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; - }); - await addEnvsLayer(options, config); - await addLabelsLayer(options, config); if (options.customContent.length > 0) { + if (options.nonDefaults.workdir) await addWorkdirLayer(options, config, options.nonDefaults.workdir); + if (options.nonDefaults.entrypoint) await addEntrypointLayer(options, config, options.nonDefaults.entrypoint); + if (options.nonDefaults.user) await addUserLayer(options, config, options.nonDefaults.user); + await addEnvsLayer(options, config); + await addLabelsLayer(options, config); await addDataLayer(tmpdir, todir, options, config, manifest, options.customContent, "custom"); } else { + await addWorkdirLayer(options, config, options.workdir); + await addEntrypointLayer(options, config, options.entrypoint); + await addUserLayer(options, config, options.user); + await addEnvsLayer(options, config); + await addLabelsLayer(options, config); const appFiles = (await fs.readdir(options.folder)).filter((l) => !ignore.includes(l)); const depLayerContent = appFiles.filter((l) => depLayerPossibles.includes(l)); const appLayerContent = appFiles.filter((l) => !depLayerPossibles.includes(l)); @@ -218,6 +209,24 @@ async function addAppLayers(options: Options, config: Config, todir: string, man await addDataLayer(tmpdir, todir, options, config, manifest, [extraContent], "extra"); } } +async function addWorkdirLayer(options: Options, config: Config, workdir: string) { + addEmptyLayer(config, options, `WORKDIR ${workdir}`, (config) => (config.config.WorkingDir = workdir)); +} +async function addEntrypointLayer(options: Options, config: Config, entrypoint: string) { + const entrypointParts = parseCommandLineToParts(entrypoint); + addEmptyLayer( + config, + options, + `ENTRYPOINT ${JSON.stringify(entrypoint)}`, + (config) => (config.config.Entrypoint = entrypointParts), + ); +} +async function addUserLayer(options: Options, config: Config, user: string) { + addEmptyLayer(config, options, `USER ${user}`, (config) => { + config.config.User = user; + config.container_config.User = user; + }); +} async function addLabelsLayer(options: Options, config: Config) { if (Object.keys(options.labels).length > 0) { diff --git a/src/cli.ts b/src/cli.ts index 3e682b7..a4f1a71 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -33,9 +33,11 @@ const possibleArgs = { "--registry ": "Optional: Convenience argument for setting both from and to registry", "--platform ": "Optional: Preferred platform, e.g. linux/amd64 or arm64", "--token ": "Optional: Convenience argument for setting token for both from and to registry", - "--user ": "Optional: User account to run process in container - default: 1000", - "--workdir ": "Optional: Workdir where node app will be added and run from - default: /app", - "--entrypoint ": "Optional: Entrypoint when starting container - default: npm start", + "--user ": "Optional: User account to run process in container - default: 1000 (empty for customContent)", + "--workdir ": + "Optional: Workdir where node app will be added and run from - default: /app (empty for customContent)", + "--entrypoint ": + "Optional: Entrypoint when starting container - default: npm start (empty for customContent)", "--labels ": "Optional: Comma-separated list of key value pairs to use as labels", "--label