Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 758 Bytes

README.md

File metadata and controls

34 lines (25 loc) · 758 Bytes

Import example

The IMPORT command can be used to alias an Earthfile reference, allowing it to be reused without duplicating the path.

For example:

build:
    DO ./some/local/path+PRINT --string="IMPORT example"
    COPY ./some/local/path+get-file/file.txt ./
    RUN cat file.txt
    BUILD github.com/earthly/hello-world:main+hello

can be refactored as:

IMPORT ./some/local/path AS lib
IMPORT github.com/earthly/hello-world:main

build:
    DO lib+PRINT --string="IMPORT example"
    COPY lib+get-file/file.txt ./
    RUN cat file.txt
    BUILD hello-world+hello

Note that the IMPORT command only supports Earthfile references, not target references.

To run this example, execute:

earthly +build