Earthly
Fleetingbeware that save artifact is not robust at all
behave like –if-exists sometimes
this won’t fail
test:
FROM alpine
SAVE ARTIFACT nothing
But it will correctly save the artifact if it exists
does not undertand absolute path when using –if-exists, WORKDIR
https://github.com/earthly/earthly/issues/2014
When using –if-exists, save artifact interpret the path as relative, /a/b/c becomes ./a/b/c. This messes up with WORKDIR.
This does not save the file
VERSION 0.8
test:
FROM alpine
WORKDIR /app
RUN echo foo > /app/something
SAVE ARTIFACT --if-exists /app/something AS LOCAL something
While this does
VERSION 0.8
test:
FROM alpine
RUN mkdir /app
RUN echo foo > /app/something
SAVE ARTIFACT --if-exists /app/something AS LOCAL something
And this as well
VERSION 0.8
test:
FROM alpine
WORKDIR /app
RUN echo foo > /app/something
SAVE ARTIFACT --if-exists /app/../something AS LOCAL something
Use the pattern IF + SAVE ARTIFACT, to be sure.
#+BEGIN_SRC earthfile VERSION 0.8
test: FROM alpine WORKDIR /app RUN echo foo > /app/something IF test -e “/app/something” SAVE ARTIFACT /app/something AS LOCAL something END #+END_ARC
connecting to a docker registry from within
Not yet, but planned and discussed in https://github.com/earthly/earthly/issues/1722
try finally save artifact does not work well
If we want to save a directory, it won’t work -> https://github.com/earthly/earthly/issues/2817
We have to use a workaround like https://github.com/earthly/earthly/issues/2817#issuecomment-1536766279 to actually save a file
BUT…
- this is not to be copy pasted as-is for we also want to save the artifact in case of success,
- the file size is limited -> https://github.com/earthly/earthly/issues/2452
So far, the best I can think of is to
- allow the failing test to pass,
- save its exit code as an artifact,
- add a check in the command that runs earthly about the exit code,
This is an example of this workaround.
mytest:
...
RUN --no-cache mycommand ; echo $? > res.txt
IF test "$(cat res.txt)" != "0"
# to undertand this better -> https://konubinix.eu/braindump/posts/56c711e5-6d29-4b9d-b630-f75c92800c61/?title=earthly_try_finally_save_artifact_does_not_work_well
RUN echo "$(tput setaf 1)BEWARE THAT THE TEST FAILED! DON'T BE FOOLED BY FACT EARTHLY WILL RETURN IN GREEN!"
END
SAVE ARTIFACT --if-exists somewantedartifact AS LOCAL somewantedartifact
SAVE ARTIFACT res.txt AS LOCAL res.txt
runtest() {
earthly +mytest && return "$(cat res.txt)"
}
runtest
caching
- Référence externe : https://docs.earthly.dev/docs/caching/caching-in-earthfiles
disable layer caching is to use the RUN –push flag. This flag is useful when you want to perform an operation with external effects (e.g. deploying to production). By default Earthly does not run –push commands unless the –push flag is also specified when invoking Earthly itself (earthly –push +my-target). RUN –push commands are never cached.
— https://docs.earthly.dev/docs/caching/caching-in-earthfiles
cache bust
-
Référence externe : https://docs.earthly.dev/docs/caching/caching-in-earthfiles#cache-size
If the configured cache size is too small, then Earthly might garbage-collect cached layers more often than you might expect. This can manifest in builds randomly not using cache for certain layers. Usually it is the biggest layers that suffer from this (and oftentimes the biggest layers are the most expensive to recreate).
— https://docs.earthly.dev/docs/caching/caching-in-earthfiles#cache-size
wait
-
Référence externe : https://docs.earthly.dev/docs/earthfile#wait
The WAIT clause executes the encapsulated commands and waits for them to complete. This includes pushing and outputting local artifacts – a feature which can be used to control the order of interactions with the outside world.
Notes pointant ici
- a python runtime on android (blog)
- Access ECR with Earthly secrets (and no need for credential helper / aws CLI installed)
- clk k8s and earthly in a local dev env (blog)
- devops
- docker looses the dns configuration
- don’t create a CI that is hard to run on your machine anymore
- earthly buildkit docker server gave HTTP response to HTTPS client
- earthly buildkitd won’t work if started in network=host
- how I debug MTU issues in k3d in docker in earthly in docker in k8s (blog)
- how I debug my k8s tests not running
- my issues with literate programming
- setting up my raspberry pi fleet
- several flavors of testing one’s code
- with earthly