Skip to content

[BUG] Bake build fails when using BAKE_CMD_CONTEXT locally #1627

Description

@nVlast

I noticed that when I use the BAKE_CMD_CONTEXT built-in variable in a local HCL bake file, the build fails.

Steps to reproduce:

  1. Create a Dockerfile (named "Dockerfile"):
FROM alpine
CMD ["sleep", "infinity"]
  1. Create a bake file (named "docker-bake.hcl"):
target "default" {
  dockerfile = "Dockerfile"
  context = BAKE_CMD_CONTEXT
  tags = ["myimage:myversion"]
}
  1. Run docker buildx bake

Expected outcome:
The docker image specified should be built

Actual outcome:

ERROR: could not find cwd:: stat cwd:: no such file or directory

I looked into it a bit further, and it seems that when the aforementioned built-in variable was introduced, while the context was arranged to be "cleaned" from the cwd protocol, the dockerfilePath is left with a cwd reference in it. Perhaps something as simple as adding a !strings.HasPrefix(contextPath, "cwd://") check here would be sufficient but take that with a pinch of salt as I'm not all that familiar with the codebase.

Also, if this variable was never meant to work in a local setting, please close this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions