From e97959223c34f448785cae924f834184398faa2a Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 7 Aug 2024 20:23:52 +0200 Subject: [PATCH] buildx: use Buffer for base64 encoding of the Dockerfile Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- __tests__/.fixtures/lint.Dockerfile | 3 +++ src/buildx/buildx.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/__tests__/.fixtures/lint.Dockerfile b/__tests__/.fixtures/lint.Dockerfile index c50f223..d99f390 100644 --- a/__tests__/.fixtures/lint.Dockerfile +++ b/__tests__/.fixtures/lint.Dockerfile @@ -17,6 +17,9 @@ frOM busybox as base cOpy lint.Dockerfile . +# some special chars: distroless/python3-debian12のPythonは3.11 +# https://github.com/docker/build-push-action/issues/1204#issuecomment-2274056016 + from scratch MAINTAINER moby@example.com COPy --from=base \ diff --git a/src/buildx/buildx.ts b/src/buildx/buildx.ts index a8d16b2..db7ad17 100644 --- a/src/buildx/buildx.ts +++ b/src/buildx/buildx.ts @@ -347,7 +347,7 @@ export class Buildx { if (Util.isPathRelativeTo(workspaceDir, ls.DockerfilePath)) { dockerfiles.push({ path: path.relative(workspaceDir, ls.DockerfilePath), - content: btoa(fs.readFileSync(ls.DockerfilePath, {encoding: 'utf-8'})) + content: Buffer.from(fs.readFileSync(ls.DockerfilePath, {encoding: 'utf-8'}), 'utf-8').toString('base64') }); } else { core.debug(`Buildx.convertWarningsToGitHubAnnotations: skipping Dockerfile outside of workspace: ${ls.DockerfilePath}`);