New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

containerify

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

containerify - npm Package Compare versions

Comparing version 2.6.0 to 2.6.1

3

lib/cli.js

@@ -35,2 +35,3 @@ #!/usr/bin/env node

"--toRegistry <registry url>": "Optional: URL of registry to push base image to - Default: https://registry-1.docker.io/v2/",
"--optimisticToRegistryCheck": "Treat redirects as layer existing in remote registry. Potentially unsafe, but can save bandwidth.",
"--toToken <token>": "Optional: Authentication token for target registry",

@@ -235,3 +236,3 @@ "--toTar <path>": "Optional: Export to tar file",

if (options.toRegistry) {
const toRegistry = (0, registry_1.createRegistry)(options.toRegistry, (_b = options.toToken) !== null && _b !== void 0 ? _b : "");
const toRegistry = (0, registry_1.createRegistry)(options.toRegistry, (_b = options.toToken) !== null && _b !== void 0 ? _b : "", options.optimisticToRegistryCheck);
yield toRegistry.upload(options.toImage, todir);

@@ -238,0 +239,0 @@ }

import { Platform } from "./types";
export declare function createRegistry(registryBaseUrl: string, token: string): {
export declare function createRegistry(registryBaseUrl: string, token: string, optimisticToRegistryCheck?: boolean): {
download: (imageStr: string, folder: string, preferredPlatform: Platform, cacheFolder?: string) => Promise<void>;

@@ -4,0 +4,0 @@ upload: (imageStr: string, folder: string) => Promise<void>;

@@ -16,6 +16,6 @@ "use strict";

const URL = require("url");
const fss = require("fs");
const fs_1 = require("fs");
const path = require("path");
const fse = require("fs-extra");
const fss = require("fs");
const fileutil = require("./fileutil");

@@ -25,3 +25,3 @@ const logger_1 = require("./logger");

const utils_1 = require("./utils");
const redirectCodes = [307, 303, 302];
const redirectCodes = [308, 307, 303, 302, 301];
function request(options, callback) {

@@ -133,3 +133,7 @@ return (options.protocol == "https:" ? https : http).request(options, (res) => {

}
function headOk(url, headers) {
function headOk(url, headers, optimisticCheck = false, depth = 0) {
if (depth >= 5) {
logger_1.default.info("Followed five redirects, assuming layer does not exist");
return new Promise((resolve) => resolve(false));
}
return new Promise((resolve, reject) => {

@@ -141,7 +145,21 @@ logger_1.default.debug(`HEAD ${url}`);

request(options, (res) => {
var _a;
logger_1.default.debug(`HEAD ${url}`, res.statusCode);
// Not found
if (res.statusCode == 404)
return resolve(false);
// OK
if (res.statusCode == 200)
return resolve(true);
// Redirected
if (redirectCodes.includes((_a = res.statusCode) !== null && _a !== void 0 ? _a : 0) && res.headers.location) {
if (optimisticCheck)
return resolve(true);
return resolve(headOk(res.headers.location, headers, optimisticCheck, ++depth));
}
// Unauthorized
// Possibly related to https://gitlab.com/gitlab-org/gitlab/-/issues/23132
if (res.statusCode == 401) {
return resolve(false);
}
reject(toError(res));

@@ -182,3 +200,3 @@ }).end();

}
function createRegistry(registryBaseUrl, token) {
function createRegistry(registryBaseUrl, token, optimisticToRegistryCheck = false) {
const auth = token.startsWith("Basic ") ? token : "Bearer " + token;

@@ -188,3 +206,3 @@ function exists(image, layer) {

const url = `${registryBaseUrl}${image.path}/blobs/${layer.digest}`;
return yield headOk(url, buildHeaders(layer.mediaType, auth));
return yield headOk(url, buildHeaders(layer.mediaType, auth), optimisticToRegistryCheck, 0);
});

@@ -191,0 +209,0 @@ }

@@ -64,2 +64,3 @@ type Descriptor = {

toRegistry?: string;
optimisticToRegistryCheck?: boolean;
toToken?: string;

@@ -66,0 +67,0 @@ toTar?: string;

@@ -1,1 +0,1 @@

export declare const VERSION = "2.6.0";
export declare const VERSION = "2.6.1";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.VERSION = "2.6.0";
exports.VERSION = "2.6.1";
{
"name": "containerify",
"version": "2.6.0",
"version": "2.6.1",
"description": "Build node.js docker images without docker",

@@ -5,0 +5,0 @@ "main": "./lib/cli.js",

@@ -24,11 +24,10 @@ # containerify

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).
the normal `node_modules` etc layers will not be added. By default it does _NOT_ modify then entrypoint, user or workdir, so the base image settings are still used when running. You can still override with `--entrypoint` etc. if needed.
```
npm run build
containerify --fromImage nginx:alpine --folder . --toImage frontend:latest --customContent dist:/var/www/html --toRegistry https://registry.example.com/v2/
npm run build # or some other build command
containerify --fromImage nginx:alpine --folder . --toImage frontend:latest --customContent dist:/usr/share/nginx/html --toRegistry https://registry.example.com/v2/
```
This will take nginx:alpine and copy the files in `./dist/` into `/var/www/html`.
This will take the `nginx:alpine` image, and copy the files from `./dist/` into `/usr/share/nginx/html`.

@@ -48,2 +47,3 @@ ### Command line options

--toRegistry <registry url> Optional: URL of registry to push base image to - Default: https://registry-1.docker.io/v2/
--optimisticToRegistryCheck Optional: Treat redirects as layer existing in remote registry. Potentially unsafe, but could save bandwidth.
--toToken <token> Optional: Authentication token for target registry

@@ -50,0 +50,0 @@ --toTar <path> Optional: Export to tar file

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc