FROM
command in Earthly has the ability to reference another target's image as its base image, like in the case below where the +build
target uses the image from the +deps
target.FROM
also has the ability to import targets from Earthfiles in different directories. Let's say we have a directory structure like this./services/service-one
from inside the Earthfile in the root of our directory../services/service-one/Earthfile
./Earthfile
FROM
that there is another Earthfile in the services/service-one
directory and that the Earthfile contains a target called +deps
. In this case, if we were to run +build
Earthly is smart enough to go into the subdirectory, run the +deps
target in that Earthfile, and then use it as the base image for +build
.IMPORT
command../services/service-one
directory that contains its own Earthfile. We import it and then use the AS
keyword to give it an alias.+build
target we can inherit from any target in the imported Earthfile by passing alias+target-name
. In this case the Earthfile in the service directory has a target named +deps
.