> For the complete documentation index, see [llms.txt](https://docs.earthbuild.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.earthbuild.dev/docs/examples.md).

# Examples

## Examples of CI integration

Examples of integrating EarthBuild into various CI systems can be found on the following pages:

* [Circle CI](/ci-integration/vendor-specific-guides/circle-integration.md)
* [GitHub Actions](/ci-integration/vendor-specific-guides/gh-actions-integration.md)
* [AWS CodeBuild](/ci-integration/vendor-specific-guides/codebuild-integration.md)
* [Jenkins](/ci-integration/vendor-specific-guides/jenkins.md)
* [Kubernetes](/ci-integration/vendor-specific-guides/kubernetes.md)

For more general information on CI systems not listed above, see the [CI integration guide](/ci-integration/overview.md).

## Examples by dev environments

Examples of how EarthBuild can be integrated into different dev environments

* [GitHub Codespaces](https://github.com/earthly/codespaces-example) - shows how Earthfiles can be used in GitHub Codespaces and Devcontainers

## Example Earthfiles

In this section, you will find some examples of Earthfiles to familiarize yourself with EarthBuild.

The code for all the examples is available in the [examples GitHub directory](https://github.com/earthbuild/earthbuild/tree/main/examples).

### Examples from the Basics tutorial

If you are new to EarthBuild, you may find the [Basics tutorial](/basics.md) helpful.

* [tutorial](https://github.com/earthbuild/earthbuild/tree/main/examples/tutorial)
* [go](https://github.com/earthbuild/earthbuild/tree/main/examples/tutorial/go)
* [js](https://github.com/earthbuild/earthbuild/tree/main/examples/tutorial/js)
* [java](https://github.com/earthbuild/earthbuild/tree/main/examples/tutorial/java)
* [python](https://github.com/earthbuild/earthbuild/tree/main/examples/tutorial/python)

### Examples by language

Please note that these examples, although similar, are distinct from the ones used in the [tutorial](https://github.com/earthbuild/earthbuild/tree/main/examples/tutorial).

* [c](https://github.com/earthbuild/earthbuild/tree/main/examples/c)
* [clojure](https://github.com/earthbuild/earthbuild/tree/main/examples/clojure)
* [cobol](https://github.com/earthbuild/earthbuild/tree/main/examples/cobol)
* [cpp](https://github.com/earthbuild/earthbuild/tree/main/examples/cpp)
* [dotnet](https://github.com/earthbuild/earthbuild/tree/main/examples/dotnet)
* [elixir](https://github.com/earthbuild/earthbuild/tree/main/examples/elixir)
* [go](https://github.com/earthbuild/earthbuild/tree/main/examples/go)
* [java](https://github.com/earthbuild/earthbuild/tree/main/examples/java)
* [js](https://github.com/earthbuild/earthbuild/tree/main/examples/js)
* [python](https://github.com/earthbuild/earthbuild/tree/main/examples/python)
* [ruby](https://github.com/earthbuild/earthbuild/tree/main/examples/ruby)
* [ruby-on-rails](https://github.com/earthbuild/earthbuild/tree/main/examples/ruby-on-rails)
* [rust](https://github.com/earthbuild/earthbuild/tree/main/examples/rust)
* [scala](https://github.com/earthbuild/earthbuild/tree/main/examples/scala)
* [typescript-node](https://github.com/earthbuild/earthbuild/tree/main/examples/typescript-node)

### Examples by use-cases

* [integration-test](https://github.com/earthbuild/earthbuild/tree/main/examples/integration-test) - shows how `WITH DOCKER` and `docker-compose` can be used to start up services and then run an integration test suite.
* [monorepo](https://github.com/earthbuild/earthbuild/tree/main/examples/monorepo) - shows how multiple sub-projects can be co-located in a single repository and how the build can be fragmented across these.
* [multirepo](https://github.com/earthbuild/earthbuild/tree/main/examples/multirepo) - shows how artifacts from multiple repositories can be referenced in a single build. See also the `grpc` example for a more extensive use-case.

### Examples by EarthBuild features

* [import](https://github.com/earthbuild/earthbuild/tree/main/examples/import) - shows how to use the `IMPORT` command to alias Earthfile references.
* [cutoff-optimization](https://github.com/earthbuild/earthbuild/tree/main/examples/cutoff-optimization) - shows that if an intermediate artifact does not change, then the rest of the build will use the cache, even if the source has changed.
* [multiplatform](https://github.com/earthbuild/earthbuild/tree/main/examples/multiplatform) - shows how EarthBuild can execute builds and create images for multiple platforms, using QEMU emulation.
* [multiplatform-cross-compile](https://github.com/earthbuild/earthbuild/tree/main/examples/multiplatform-cross-compile) - shows has through the use of cross-compilation, you can create images for multiple platforms, without using QEMU emulation.

### Examples by use of other technologies

* [grpc](https://github.com/earthbuild/earthbuild/tree/main/examples/grpc) - shows how to use EarthBuild to compile a protobuf grpc definition into protobuf code for both a Go-based server, and a python-based client, in a multirepo setup.
* [terraform](https://github.com/earthbuild/earthbuild/tree/main/examples/terraform) - shows how Terraform could be used from EarthBuild.

### Other

* [readme](https://github.com/earthbuild/earthbuild/tree/main/examples/readme) - some sample code we used in our README.
* [tests](https://github.com/earthbuild/earthbuild/tree/main/tests) - a suite of tests EarthBuild uses to ensure that its features are working correctly.

### Larger Examples And Community Examples

The repositories below predate the EarthBuild fork and are maintained under the `earth` organization, so they invoke the CLI as `earth` rather than `earth`. The Earthfile syntax they demonstrate applies unchanged to EarthBuild -- treat them as examples of Earthfile usage rather than as current installation or invocation guidance.

* [EarthBuild, Rust, GoLang, NodeJS and GitHub Actions Example](https://github.com/earthly/earth-vs-gha)
* [Cloud Services In GoLang](https://github.com/earthly/cloud-services-example)
* [Earthfile workshop Repo](https://github.com/earthly/workshop-2023-09-18)
* [Python & C Example](https://github.com/earthly/pymerge)
* [Python Docker Example](https://github.com/earthly/build-transpose/blob/main/Earthfile)
* [Awesome EarthBuild - Community Examples](https://github.com/earthly/awesome-earth)

### EarthBuild's own build

As a distinct example of a complete build, you can take a look at EarthBuild's own build. EarthBuild builds itself, and the build files are available on GitHub:

* [Earthfile](https://tinyurl.com/yt3d3cx6) - the root build file
* [buildkitd/Earthfile](https://tinyurl.com/yvnpuru7) - the build of the BuildKit daemon
* [AST/parser/Earthfile](https://tinyurl.com/2k3u4vty) - the build of the parser, which generates .go files
* [tests/Earthfile](https://tinyurl.com/2p8ws579) - system and smoke tests
* [earthfile-grammar/Earthfile](https://tinyurl.com/2vyjprt6) - the build of the VS Code extension

To invoke EarthBuild's build, check out the code and then run the following in the root of the repository

```bash
earth +all
```

[![asciicast](https://asciinema.org/a/313845.svg)](https://asciinema.org/a/313845)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.earthbuild.dev/docs/examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
