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:
- Create a Dockerfile (named "Dockerfile"):
FROM alpine
CMD ["sleep", "infinity"]
- Create a bake file (named "docker-bake.hcl"):
target "default" {
dockerfile = "Dockerfile"
context = BAKE_CMD_CONTEXT
tags = ["myimage:myversion"]
}
- 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.
I noticed that when I use the
BAKE_CMD_CONTEXTbuilt-in variable in a local HCL bake file, the build fails.Steps to reproduce:
docker buildx bakeExpected outcome:
The docker image specified should be built
Actual outcome:
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.