You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
foo:
FROM alpine
ARG myvar
WORKDIR /test
RUN echo "myvar is $myvar\n; dir contents is $(ls -la)"
run:
FROM alpine
RUN echo bar > data
BUILD +foo --myvar="$(cat data)"
under 0.5.24, it worked:
$ earthly-v0.5.24 --buildkit-volume-name=five-two-four +run
buildkitd | Starting buildkit daemon as a docker container (earthly-buildkitd)...
buildkitd | ...Done
alpine | --> Load metadata linux/amd64
+run | --> FROM alpine
+run | [██████████] resolve docker.io/library/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300 ... 100%
+run | [██████████] sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3 ... 100%
+run | [██████████] extracting sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3 ... 100%
+run | --> RUN echo bar > data
+run | --> ARG myvar = RUN $(cat data)
+foo | myvar=bar
+foo | --> WORKDIR /test
+foo | myvar=bar
+foo | --> RUN echo "myvar is $myvar\n; dir contents is $(ls -la)"
+foo | myvar is bar\n; dir contents is total 8
+foo | drwxr-xr-x 2 root root 4096 Nov 26 19:04 .
+foo | drwxr-xr-x 1 root root 4096 Nov 26 19:04 ..
However under 0.6.0, it now fails:
1. Init 🚀
————————————————————————————————————————————————————————————————————————————————
buildkitd | Found buildkit daemon as docker container (earthly-buildkitd)
buildkitd | Updated image available. Restarting buildkit daemon...
buildkitd | ...Done
2. Build 🔧
————————————————————————————————————————————————————————————————————————————————
Error: build target: build main: bkClient.Build: failed to solve: parse build args: parse build arg myvar=$(cat data): the first command has to be FROM, FROM DOCKERFILE, LOCALLY, ARG, BUILD or IMPORT
If however we introduce a FROM ... under the base, like:
FROM alpine
foo:
FROM alpine
RUN echo foo-data /data
ARG myvar
RUN echo "myvar is $myvar\n"
run:
FROM alpine
RUN echo run-data > /data
BUILD +foo --myvar="$(cat /data)"
this works, and produces:
1. Init 🚀
————————————————————————————————————————————————————————————————————————————————
buildkitd | Found buildkit daemon as docker container (earthly-buildkitd)
2. Build 🔧
————————————————————————————————————————————————————————————————————————————————
alpine | --> Load metadata linux/amd64
+base | --> FROM alpine
+base | [██████████] 100% resolve docker.io/library/alpine@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300
+base | [██████████] 100% sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3
+base | [██████████] 100% extracting sha256:59bf1c3509f33515622619af21ed55bbe26d24913cedbca106468a5fb37a50c3
+base | --> RUN echo base-data /data
+base | base-data /data
+run | --> ARG myvar = RUN $(cat /data)
+run | cat: can't open '/data': No such file or directory
+run | --> RUN echo run-data > /data
+run | --> ARG myvar = RUN $(cat /data)
+foo | --> RUN echo foo-data /data
+foo | foo-data /data
+foo | myvar=run-data
+foo | --> RUN echo "myvar is $myvar\n"
+foo | myvar is run-data\n
output | --> exporting outputs
It's interesting to note: +run | cat: can't open '/data': No such file or directory indicates it's being evaluated under +base; however, when we make it to +foo | --> RUN echo "myvar is $myvar\n", it correctly prints out +foo | myvar is run-data\n. It looks like this is being (incorrectly) evaluated twice: once under +base and another time under +run.
The text was updated successfully, but these errors were encountered:
alexcb
changed the title
ARG
ARG is evaluated twice (once under +base, once under +target)
Nov 26, 2021
* Prevent parallel builds when arg is dynamic
This fixes#1448
Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
* expand isSafeAsyncBuildArg checking for new-style format
Additionally expands to check for build args such as:
BUILD +foo key="$(echo value)"
Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
under
0.5.24
, it worked:However under
0.6.0
, it now fails:If however we introduce a
FROM ...
under the base, like:this works, and produces:
It's interesting to note:
+run | cat: can't open '/data': No such file or directory
indicates it's being evaluated under+base
; however, when we make it to+foo | --> RUN echo "myvar is $myvar\n"
, it correctly prints out+foo | myvar is run-data\n
. It looks like this is being (incorrectly) evaluated twice: once under+base
and another time under+run
.The text was updated successfully, but these errors were encountered: