forked from earthly/earthly
-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Does existing documentation exist?
https://docs.earthbuild.dev/docs/earthfile#copy
Request
Earthbuild docs as far as i understand them say that COPY from a target is behaving like BUILD. But this is not the case if it comes to ARG's. COPY does automatically pass args and BUILD does not.
What is not clear from the docs:
- BUILD needs --pass-args to populate ARG to child target but COPY does automatically do that
- We can call a parent target and pass ARG's which are only defined in child target even without passing them to COPY
- If we call earth cli with ARG which is not defined in parent target the ARG is still available in child target but not in parent(which is correct but not clear).
Earthfile
VERSION 0.8
FROM alpine:latest
deps:
ARG MY_ARG=default
RUN echo "${MY_ARG}" > /my_arg.txt
RUN echo "MY_ARG from deps '$(cat /my_arg.txt)'"
SAVE ARTIFACT /my_arg.txt
build:
BUILD +deps
RUN echo "Build arg '${MY_ARG}'"
copy:
COPY +deps/my_arg.txt ./my_arg.txt
RUN echo "Build arg '${MY_ARG}'"
RUN echo "Copied arg from deps '$(cat /my_arg.txt)'"
Different outputs with and without passing ARG.
earth --no-cache +build
Init 🚀
————————————————————————————————————————————————————————————————————————————————
...
+deps | MY_ARG from deps 'default'
+build | Build arg ''
...
========================== 🌍 earth Build ✅ SUCCESS ==========================
earth --no-cache +build-pass-arg
Init 🚀
————————————————————————————————————————————————————————————————————————————————
...
+deps | MY_ARG from deps 'passed_arg'
+build-pass-arg | Build arg ''
...
========================== 🌍 earth Build ✅ SUCCESS ==========================
earth --no-cache +copy
Init 🚀
————————————————————————————————————————————————————————————————————————————————
...
+deps | MY_ARG from deps 'default'
+copy | Copied arg from deps 'default'
+copy | Build arg ''
...
========================== 🌍 earth Build ✅ SUCCESS ==========================
earth --no-cache +build --MY_ARG=hugo
Init 🚀
————————————————————————————————————————————————————————————————————————————————
...
+deps | MY_ARG from deps 'hugo'
+build | Build arg ''
========================== 🌍 earth Build ✅ SUCCESS ==========================
earth --no-cache +build-pass-arg --MY_ARG=hugo
Init 🚀
————————————————————————————————————————————————————————————————————————————————
...
+deps | MY_ARG from deps 'passed_arg'
+build-pass-arg | Build arg ''
...
========================== 🌍 earth Build ✅ SUCCESS ==========================
earth --no-cache +copy --MY_ARG=hugo
Init 🚀
————————————————————————————————————————————————————————————————————————————————
...
+deps | MY_ARG from deps 'hugo'
+copy | Build arg ''
+copy | Copied arg from deps 'hugo'
...
========================== 🌍 earth Build ✅ SUCCESS ==========================
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels