Allow POSIX variable substitution to remove optional colon by jedevc · Pull Request #3611 · moby/buildkit (original) (raw)
Overall SGTM to support the syntax without :
(I must admit that I never use that syntax, and always forget it's also supported). Do we need changes in the classic builder to keep the format compatible?
I was curious what we did before with PR with -
(without a :
), as I wasn't sure if we previously considered ${BUILD-ARG}
to be a build-arg named BUILD-ARG
(with a hyphen in the name), but looks like we're good there; previously it was an error, so nobody should be able to depend on that.
docker build -t foo -<<'EOF'
syntax=docker/dockerfile:1
FROM alpine ARG BUILD-ARG=hello world LABEL mylabel=${BUILD-ARG} EOF
With BuildKit:
Dockerfile:4
--------------------
2 | FROM alpine
3 | ARG BUILD-ARG=hello world
4 | >>> LABEL mylabel=${BUILD-ARG}
5 |
--------------------
ERROR: failed to solve: failed to process "${BUILD-ARG}": missing ':' in substitution
Classic builder:
Step 3/3 : LABEL mylabel=${BUILD-ARG}
failed to process "${BUILD-ARG}": missing ':' in substitution
When used without ${}
; (both with BuildKit and the classic builder);
docker build -t foo -<<'EOF'
syntax=docker/dockerfile:1
FROM alpine ARG BUILD-ARG=hello world LABEL mylabel=$BUILD-ARG EOF
docker image inspect foo --format='{{json .Config.Labels}}' | jq . { "mylabel": "-ARG" }
Which looks to match behavior in the shell;
echo "${BUILD-ARG}" ARG echo "$BUILD-ARG" -ARG