diff --git a/packages/testcontainers/src/container-runtime/clients/image/docker-image-client.ts b/packages/testcontainers/src/container-runtime/clients/image/docker-image-client.ts index 57befec23..0c57fce34 100644 --- a/packages/testcontainers/src/container-runtime/clients/image/docker-image-client.ts +++ b/packages/testcontainers/src/container-runtime/clients/image/docker-image-client.ts @@ -17,17 +17,13 @@ export class DockerImageClient implements ImageClient { constructor(protected readonly dockerode: Dockerode, protected readonly indexServerAddress: string) {} async build(context: string, opts: ImageBuildOptions): Promise { - const cleanOpts = Object.fromEntries( - Object.entries(opts).filter(([_, value]) => value !== undefined) - ) as ImageBuildOptions; - try { - log.debug(`Building image "${cleanOpts.t}" with context "${context}"...`); + log.debug(`Building image "${opts.t}" with context "${context}"...`); const isDockerIgnored = await this.createIsDockerIgnoredFunction(context); const tarStream = tar.pack(context, { ignore: (aPath) => { const relativePath = path.relative(context, aPath); - if (relativePath === cleanOpts.dockerfile) { + if (relativePath === opts.dockerfile) { return false; } else { return isDockerIgnored(relativePath); @@ -36,19 +32,19 @@ export class DockerImageClient implements ImageClient { }); await new Promise((resolve) => { this.dockerode - .buildImage(tarStream, cleanOpts) + .buildImage(tarStream, opts) .then((stream) => byline(stream)) .then((stream) => { stream.setEncoding("utf-8"); stream.on("data", (line) => { if (buildLog.enabled()) { - buildLog.trace(line, { imageName: cleanOpts.t }); + buildLog.trace(line, { imageName: opts.t }); } }); stream.on("end", () => resolve()); }); }); - log.debug(`Built image "${cleanOpts.t}" with context "${context}"`); + log.debug(`Built image "${opts.t}" with context "${context}"`); } catch (err) { log.error(`Failed to build image: ${err}`); throw err;