UNPKG

buildahcker

Version:

Buildahcker is a node.js library to create and run commands in OCI (Open Container Initiative) container images (or docker images), based on Buildah and a hash-based cache. It also contains utilities to easily create a partitioned bootable disk image of a

50 lines (49 loc) 2.01 kB
import type { ExecOptions } from "./exec"; export interface AtomicStep { (container: Container): Promise<void>; getCacheKey?(): Promise<string | undefined>; } export type Step = AtomicStep | Step[]; export interface StepExecutor { executeStep(step: Step): Promise<void>; } export interface ContainerOptions extends ExecOptions { } export interface CommitOptions { timestamp?: number; } export declare class Container implements StepExecutor { #private; options?: ContainerOptions | undefined; private constructor(); static from(image: string, options?: ContainerOptions): Promise<Container>; get name(): string; get mountPath(): string; mount(): Promise<string>; toPathInContainer(absolutePath: string): string; tempFolder(): Promise<{ pathInHost: string; pathInContainer: string; remove: () => Promise<void>; }>; resolve(subPath: string, strictDotDot?: boolean): Promise<string>; resolveParent(subPath: string, strictDotDot?: boolean): Promise<string>; remove(): Promise<void>; run(command: string[], buildahOptions?: string[]): Promise<{ stdout: Buffer<ArrayBufferLike>; stderr: Buffer<ArrayBufferLike>; }>; commit({ timestamp }?: CommitOptions): Promise<string>; executeStep(step: Step): Promise<void>; } export declare const temporaryContainer: <T>(image: string, fn: (container: Container) => Promise<T>, containerOptions?: ContainerOptions) => Promise<T>; export type ImageOrContainer = Container | string; export declare const withImageOrContainer: <T>(source: ImageOrContainer, fn: (container: Container) => Promise<T>, containerOptions?: ContainerOptions) => Promise<T>; export declare const runInImageOrContainer: ({ source, command, buildahRunOptions, ...containerOptions }: { source: ImageOrContainer; command: string[]; buildahRunOptions?: string[]; } & ContainerOptions) => Promise<{ stdout: Buffer<ArrayBufferLike>; stderr: Buffer<ArrayBufferLike>; }>;