Excluding patterns

When a build takes place, the earth command sends any necessary local build contexts to the BuildKit daemon. In order to avoid sending unwanted files, you may exclude certain patterns by specifying an .earthignore file.

The .earthignore file must be present in the same directory as the target being built.

The syntax of the .earthignore file is the same as the syntax of a .dockerignore file. Behind the scenes, the matching is performed using the Go filepath.Match funcion.

Patterns of files to exclude from the build context are specified as one pattern per line, with empty lines or lines starting with # being ignored. Each pattern has the following syntax:

{ term }
'*' matches any sequence of non-Separator characters
'?' matches any single non-Separator character
'[' [ '^' ] { character-range } ']'
character class (must be non-empty)
c matches character c (c != '*', '?', '\\', '[')
'\\' c matches character c
c matches character c (c != '\\', '-', ']')
'\\' c matches character c
lo '-' hi matches character c for lo <= c <= hi


Currently .earthignore is only applied to local targets. If an .earthignore file is specified within the context of a remote target, it will be silently ignored and exclusions would not take place.