Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildx: use Buffer for base64 encoding of the Dockerfile #428

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions __tests__/.fixtures/lint.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

frOM busybox as base

Check warning on line 17 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

All commands within the Dockerfile should use the same casing (either upper or lower)

ConsistentInstructionCasing: Command 'frOM' should match the case of the command majority (uppercase) More info: https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/

Check warning on line 17 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

All commands within the Dockerfile should use the same casing (either upper or lower)

ConsistentInstructionCasing: Command 'frOM' should match the case of the command majority (uppercase) More info: https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/
cOpy lint.Dockerfile .

Check warning on line 18 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

All commands within the Dockerfile should use the same casing (either upper or lower)

ConsistentInstructionCasing: Command 'cOpy' should match the case of the command majority (uppercase) More info: https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/

# some special chars: distroless/python3-debian12のPythonは3.11
# https://github.com/docker/build-push-action/issues/1204#issuecomment-2274056016

from scratch

Check warning on line 23 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

All commands within the Dockerfile should use the same casing (either upper or lower)

ConsistentInstructionCasing: Command 'from' should match the case of the command majority (uppercase) More info: https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/
MAINTAINER moby@example.com

Check warning on line 24 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

The MAINTAINER instruction is deprecated, use a label instead to define an image author

MaintainerDeprecated: Maintainer instruction is deprecated in favor of using label More info: https://docs.docker.com/go/dockerfile/rule/maintainer-deprecated/
COPy --from=base \

Check warning on line 25 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

All commands within the Dockerfile should use the same casing (either upper or lower)

ConsistentInstructionCasing: Command 'COPy' should match the case of the command majority (uppercase) More info: https://docs.docker.com/go/dockerfile/rule/consistent-instruction-casing/
/lint.Dockerfile \
/

CMD [ "echo", "Hello, Norway!" ]

Check warning on line 29 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

Multiple instructions of the same type should not be used in the same stage

MultipleInstructionsDisallowed: Multiple CMD instructions should not be used in the same stage because only the last one will be used More info: https://docs.docker.com/go/dockerfile/rule/multiple-instructions-disallowed/
CMD [ "echo", "Hello, Sweden!" ]
ENTRYPOINT my-program start

Check warning on line 31 in __tests__/.fixtures/lint.Dockerfile

View workflow job for this annotation

GitHub Actions / test-itg (buildx/buildx.test.itg.ts, ubuntu-latest)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
2 changes: 1 addition & 1 deletion src/buildx/buildx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
Loading