Automation

Migrate from Earthly to Dagger: Errors, Fixes and Timings

Your Earthfile still builds, but nobody is fixing Earthly anymore, and the Satellites that kept CI fast were switched off in July 2025. If you want to migrate Earthly to Dagger without guessing, the useful question is what breaks on the way and whether the new pipeline is actually as quick. We moved a small Go service with test, lint, build and image targets from an Earthfile to a Dagger Python module, then timed both tools on the same box.

Original content from computingforgeeks.com - post 165365

The guide covers the concept mapping, the finished module, the four errors we hit while porting it, the CI change and a cold, warm and one-line-change timing comparison. I ran through this again on Ubuntu 24.04 with Dagger v0.21.12 and Earthly v0.8.16 in November 2026, and the migrated pipeline works end to end.

What happened to Earthly, and can you keep running it?

Earthly still runs locally, but it is frozen. On 16 April 2025, founder Vlad A. Ionescu announced the end of Earthly Cloud and Satellites and the end of active maintenance of the open source project. The hosted services stopped on 16 July 2025, and the last 0.8.x release removed every cloud dependency so the CLI keeps working offline. Pull requests are no longer reviewed, and a community fork has to ship under a new name.

So an Earthfile you have today will keep building, which is why there is no rush to rip it out on a Friday. The risk is slower: a BuildKit or Docker change that nobody upstream will patch, plus the reference docs moving away. While writing this, docs.earthly.dev already redirected to Lunar, the new product from the Earthly team, and we read the Earthfile reference from the docs/ folder of the GitHub repository instead. Both tools sit on BuildKit, which is why the Dagger port below keeps most of the caching model you already understand.

Dagger also runs an Earthly soft landing offer with a migration workshop and a free year of its Team cloud tier for teams coming from Earthly. You do not need any of that to follow this guide, because everything here runs on a single Docker host.

How Earthfile concepts map to Dagger

Every Earthfile target becomes a function on one Dagger object, and every Earthfile command becomes a method call on a container. The table is the mapping we used for the port, written from the module that actually ran rather than from the docs.

EarthfileDagger Python SDKNote from the port
+target@function methodCalled as dagger call target
FROM golang:1.26-alpinedag.container().from_(...)Image tag lives in a constant
FROM +depsself.deps(source)Plain Python call, cached by inputs
COPY . ..with_directory("/app", source)DefaultPath(".") removes the --source flag
RUN.with_exec([...])Arguments as a list, no shell
CACHE /path.with_mounted_cache(path, dag.cache_volume(name))Named volumes are shared across functions
SAVE ARTIFACT ... AS LOCALReturn dagger.File, then export --pathExport happens in the CLI chain
SAVE IMAGE myapp:tagReturn dagger.Container, then export-image --nameCannot be called inside the function
SAVE IMAGE --pushcontainer.publish(address)Returns the pushed digest
BUILD +a BUILD +banyio task groupRuns both in parallel
SatellitesPersistent engine or Dagger CloudCovered in Step 7

Two rows matter more than the rest. Image export and registry pushes moved out of the build logic and into the command line. On the Earthly side, CACHE has a scoping rule that hides most of its benefit unless you name the cache. Both come back in the timings and in the errors section.

Step 1: Install Dagger next to Earthly

Install the Dagger CLI on the same machine that runs Earthly, so you can compare the two pipelines before switching CI. Dagger needs a working Docker engine, the same requirement Earthly has, and our lab box was an Ubuntu 24.04 VM called homelab-ci with Docker from the Ubuntu archive. If Docker is missing, the Docker and Compose install on Ubuntu gets you there first.

We pin the stable 0.x line on purpose. The install page on docs.dagger.io now defaults to the 1.0 beta, which changes what dagger init creates, so an unpinned copy of that page gives you a different project layout from the one shown here.

export DAGGER_VERSION="0.21.12" # pin: 0.x module layout used in this guide #https://github.com/dagger/dagger/releases
curl -fsSL https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=${DAGGER_VERSION} BIN_DIR=$HOME/.local/bin sh

Make sure ~/.local/bin is on your PATH, then confirm the CLI and the engine image agree on the version:

dagger version

You should see the engine image the CLI will pull on first use:

dagger v0.21.12 (image://registry.dagger.io/engine:v0.21.12) linux/amd64

For the Rocky or Alma variant of this step, or a system-wide install under /usr/local/bin, the Dagger install guide for Ubuntu and its Rocky Linux and AlmaLinux counterpart cover the details.

Step 2: Look at the Earthfile you are migrating

The project is a small Go HTTP service with one dependency (github.com/google/uuid), one test and an Earthfile with six targets. This is the exact Earthfile we timed, so you can compare it line by line with the module in Step 4.

VERSION 0.8
FROM golang:1.26-alpine
WORKDIR /app

deps:
    COPY go.mod go.sum .
    RUN go mod download
    SAVE ARTIFACT go.mod AS LOCAL go.mod
    SAVE ARTIFACT go.sum AS LOCAL go.sum

build:
    FROM +deps
    COPY . .
    RUN go build -o /usr/local/bin/myapp .
    SAVE ARTIFACT /usr/local/bin/myapp AS LOCAL bin/myapp

test:
    FROM +deps
    COPY . .
    RUN go test -v ./...

lint:
    FROM +deps
    COPY . .
    RUN go vet ./...

docker:
    FROM alpine:3.23
    COPY +build/myapp /usr/local/bin/myapp
    ENTRYPOINT ["/usr/local/bin/myapp"]
    EXPOSE 8080
    ARG tag=latest
    SAVE IMAGE myapp:${tag}

all:
    BUILD +test
    BUILD +lint
    BUILD +docker

Before touching anything, we ran earthly +all to get a baseline. How fast is the pipeline you are leaving? On our VM, starting from earthly prune --reset, it looked like this:

  • Cold run: 1m11s
  • Two warm runs: 1.5s and 1.3s, every step *cached*
  • One-line change to main.go: 1m2s

The one-line case is slow because COPY . . invalidated test, vet and build, so Go recompiled everything from scratch. Keep those numbers in mind, since that case is where the two tools differ most.

Step 3: Run dagger init inside the Earthly repo

Initialise a Dagger module in the root of the repository, next to the Earthfile. We chose the Python SDK because the Earthfile logic is mostly sequencing and Python reads closest to it, but the Go and TypeScript SDKs map the same way.

cd ~/myapp
dagger init --sdk=python --name=myapp

The first run pulls the engine image, starts it as a Docker container named dagger-engine-v0.21.12 and loads the Python SDK, which took 1m7s on our VM. Notice the warning about a LICENSE file in the output below.

dagger init adding a Python module and dagger.json to an Earthly Go project on Ubuntu 24.04

Three new paths appear in git status: .dagger/ with the SDK and your source, dagger.json, and a generated Apache-2.0 LICENSE. That last one is easy to commit by accident. If your repository already has a licence elsewhere, or none at all on purpose, delete the generated file before your first commit.

Step 4: Port the Earthfile targets to a Dagger module

Our module replaces the generated example in .dagger/src/myapp/main.py. Open it in your editor:

vim .dagger/src/myapp/main.py

Replace the contents with the module below. It is the file we ran for every capture in this guide, one function per Earthfile target, with the docstrings pointing back at the target each one replaces.

from typing import Annotated

import anyio
import dagger
from dagger import DefaultPath, Ignore, dag, function, object_type

GO_IMAGE = "golang:1.26-alpine"
RUNTIME_IMAGE = "alpine:3.23"

Source = Annotated[
    dagger.Directory,
    DefaultPath("."),
    Ignore([".git", ".dagger", "bin", "Earthfile"]),
]


@object_type
class Myapp:
    @function
    def deps(self, source: Source) -> dagger.Container:
        """Go toolchain with modules downloaded (Earthfile +deps)"""
        return (
            dag.container()
            .from_(GO_IMAGE)
            .with_mounted_cache("/go/pkg/mod", dag.cache_volume("go-mod"))
            .with_mounted_cache("/root/.cache/go-build", dag.cache_volume("go-build"))
            .with_workdir("/app")
            .with_file("/app/go.mod", source.file("go.mod"))
            .with_file("/app/go.sum", source.file("go.sum"))
            .with_exec(["go", "mod", "download"])
        )

    @function
    def build(self, source: Source) -> dagger.File:
        """Static Go binary (Earthfile +build)"""
        return (
            self.deps(source)
            .with_directory("/app", source)
            .with_env_variable("CGO_ENABLED", "0")
            .with_exec(["go", "build", "-o", "/out/myapp", "."])
            .file("/out/myapp")
        )

    @function
    async def test(self, source: Source) -> str:
        """go test (Earthfile +test)"""
        return await (
            self.deps(source)
            .with_directory("/app", source)
            .with_exec(["go", "test", "-v", "./..."])
            .stdout()
        )

    @function
    async def lint(self, source: Source) -> str:
        """go vet (Earthfile +lint)"""
        return await (
            self.deps(source)
            .with_directory("/app", source)
            .with_exec(["go", "vet", "./..."])
            .stdout()
        )

    @function
    def image(self, source: Source) -> dagger.Container:
        """Runtime image (Earthfile +docker, before SAVE IMAGE)"""
        return (
            dag.container()
            .from_(RUNTIME_IMAGE)
            .with_file("/usr/local/bin/myapp", self.build(source))
            .with_entrypoint(["/usr/local/bin/myapp"])
            .with_exposed_port(8080)
        )

    @function
    async def publish(self, source: Source, address: str) -> str:
        """Push the image to a registry and return the digest ref"""
        return await self.image(source).publish(address)

    @function
    async def all(self, source: Source) -> dagger.Container:
        """test + lint in parallel, then the runtime image (Earthfile +all)"""
        async with anyio.create_task_group() as tg:
            tg.start_soon(self.test, source)
            tg.start_soon(self.lint, source)
        return self.image(source)

A few choices in that file came straight out of the errors in the last section of this guide, so they are worth calling out before you adapt it to your own repo:

  • DefaultPath(".") so dagger call test works without --source=.
  • Ignore([...]) keeps .git and the module out of the build context
  • Two named cache volumes, go-mod and go-build, shared by every function
  • publish takes the registry address as an argument instead of a hardcoded name
  • all returns a container rather than exporting it

Those cache volumes are what changes your build times. The original Earthfile had no CACHE lines at all, so a fair comparison also needs an Earthfile with caches, which we ran in Step 6. Keep the Earthfile in the repository until CI has run on Dagger for a while, because it is your rollback.

Step 5: Run test, lint, build and the image with dagger call

Each Earthfile target is now a dagger call subcommand, so you can run them one at a time exactly as you used to run earthly +test. Start with the tests, the lint and a local copy of the binary:

dagger call test
dagger call lint
dagger call build export --path=./bin/myapp

The first test run took 28.5s, mostly the Go module download and first compile. The lint run that followed finished in 7.5s because it reused the go-build cache volume the test had just filled, which an Earthfile without CACHE cannot do.

Migrated Dagger module running go test, go vet and exporting the Go binary

The exported bin/myapp is an 8.4 MB statically linked x86-64 binary, the same thing SAVE ARTIFACT ... AS LOCAL used to write. Next, replace earthly +all and SAVE IMAGE. The all function returns a container, and the CLI chain loads it into the local Docker engine:

dagger call all export-image --name=myapp:latest

Then run the image the way you would have run the Earthly one, and hit it with curl to prove the binary inside works:

docker images myapp
docker run -d --rm --name myapp-smoke -p 8080:8080 myapp:latest
curl -s localhost:8080/

For SAVE IMAGE --push, call publish with the registry address. We used ttl.sh, an anonymous registry that deletes an image once the time limit in its tag runs out, so the test push needed no credentials. Swap in your own registry path once you have run docker login against it.

dagger call publish --address=ttl.sh/myapp-b5e1c6cb:1h

In the capture below you can see all three: the image in Docker at 26.1 MB, the response from the container, and the digest reference returned by the push.

dagger call all export-image loading myapp into Docker, curl response and publish to ttl.sh

Docker lists image ID 3a405c23760d, which matches the start of the pushed digest, so the local and registry copies are the same build. The Earthly image for the same code came out at 26 MB too, which is expected since both copy one static binary onto the same Alpine base.

Step 6: Compare build times and cache behaviour

Earthly is faster on this project once both tools have a fair cache setup, and Dagger only looks faster against an Earthfile that has no CACHE lines. We timed four setups on the same VM, each with time around the full pipeline, after resetting the cache with earthly prune --reset or dagger core engine local-cache prune (and once with a freshly created engine).

SetupColdWarm, nothing changedOne-line change in main.go
Earthfile as written (no CACHE)1m11s1.5s / 1.3s1m2s
Earthfile, top-level CACHE only1m37snot timed1m8s
Earthfile, CACHE --id in each target42s1.7s3.7s
Dagger module with cache volumes1m47s (1m52s on a new engine)4.8s / 4.7s10.6s

Cold numbers swing with image pulls from Docker Hub, so read them as a range, not a ranking. The warm and one-line columns are the stable ones. Dagger spends about four seconds on every invocation loading the module workspace before any build step runs. That overhead is why its warm floor sits near 4.7s, against 1.3s for Earthly. On the one-line change, the pipeline function itself took 5.6s, with go vet in 0.4s and go test in 0.8s from the warm build cache. Module load and image export made up the rest.

One-line change rebuild timings: Earthly with CACHE id 3.7 seconds vs Dagger 10.6 seconds

Look at the second Earthfile row. Adding two cache mounts for the Go module and build directories at the top of the file did not make the one-line rebuild any faster (1m8s against 1m2s). A CACHE without --id belongs to the target that declares it, and version 0.8 stopped passing it to child targets unless you add --persist. So the compiling targets never saw it. Naming the caches and declaring them inside each target is what made Earthly fast. In our timed file, deps carries the go-mod line, and build, lint and test carry both, like this:

test:
    FROM +deps
    CACHE --id=go-mod /go/pkg/mod
    CACHE --id=go-build /root/.cache/go-build
    COPY . .
    RUN go test -v ./...

Named caches are the same idea as the two dag.cache_volume calls in the Dagger module, which is why both tools land within seconds of each other once the cache is shared. So is Dagger slower? On a tiny Go repo, yes, and staying on Earthly would win if speed were the only goal. People move for the frozen upstream, though, and on a real repository with a few minutes of compile time, a four-second module load stops mattering. If you want the CI angle rather than local runs, our Dagger and GitHub Actions comparison looks at where the runner cache lives.

Step 7: Update the CI job and replace Satellites

The CI change is the same command swap you just made locally: earthly +target becomes dagger call target. On GitHub Actions, the dagger/dagger-for-github action installs the CLI and runs a call through its call input. Pin the Dagger version so CI matches what you tested:

name: ci
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v7
      - name: Test and lint
        uses: dagger/[email protected]
        with:
          version: "0.21.12"
          call: all
      - name: Log in to GHCR
        if: github.ref == 'refs/heads/main'
        uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Lowercase image name
        if: github.ref == 'refs/heads/main'
        run: echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
      - name: Push image
        if: github.ref == 'refs/heads/main'
        uses: dagger/[email protected]
        with:
          version: "0.21.12"
          call: publish --address=${{ env.IMAGE }}:${{ github.sha }}

Calling all without a chained export still runs the tests and lint and builds the image, it just does not load it anywhere. The push needs a registry login first, because dagger call publish reads the Docker credential store on the runner, and without it you get the same push access denied error covered later. GHCR also rejects repository names with capitals, hence the lowercase step. The Dagger GitHub Actions pipeline guide walks through secrets, GHCR login and caching in more depth. On GitLab, install the CLI in before_script on a job that has a Docker service, then run the same calls. Both docker:dind and the Dagger engine need a runner with privileged = true, which the GitLab.com hosted Linux runners allow but many self-hosted runners do not:

build:
  image: docker:cli
  services:
    - docker:dind
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""
  before_script:
    - apk add --no-cache curl
    - curl -fsSL https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.21.12 BIN_DIR=/usr/local/bin sh
  script:
    - dagger call all

If your GitLab registry login is already wired into the job, the pattern from our GitLab CI image build and push guide carries over, with dagger call publish in place of docker push.

Satellites were really one thing: a long-lived BuildKit with a warm cache. You have two ways to get that back:

  1. A self-hosted runner that keeps the dagger-engine container and its volume
  2. Dagger Cloud, billed by usage on top of a plan minimum

The persistent runner is what made our warm runs fast, and it costs nothing extra. On Dagger Cloud pricing, Starter is $20 a month for one user and Scale is $200 a month with unlimited users. Pipeline CPU costs 0.5¢ per CPU-minute for new work and 0.1¢ for repeat work that could have come from cache, and you pay the plan price or the usage, whichever is higher. Ephemeral hosted runners lose the engine cache after every job, so on those runners the cold column above is roughly what each build will cost you.

What broke during the migration

Our first attempt used a module written for an older version of this guide, pinned to golang:1.22-alpine and pushing to a hardcoded myregistry/myapp. Every error below came from that module or from the first version of the new one, and each fix is already in the file in Step 4.

Error: go: go.mod requires go >= 1.26 (running go 1.22.12; GOTOOLCHAIN=local)

The Go image in the module was older than the go line in go.mod. Inside the container GOTOOLCHAIN=local is set, so Go refuses to download a newer toolchain and the test fails before compiling anything. The fix is to keep the image tag in the module in step with go.mod, which is why GO_IMAGE is a constant at the top of the file. The same mismatch would break the Earthfile, so check both when you bump Go.

dagger call test failing with go.mod requires go 1.26 and required flag source not set

The second command in that capture shows the next error, which appeared as soon as we dropped the flag.

Error: required flag(s) “source” not set

A function with a plain source: dagger.Directory argument makes --source mandatory on every call, so dagger call test fails while parsing arguments. Earthly users never had to pass the build context, so this one feels like a regression until you annotate the argument with DefaultPath("."). After that the module picks up the repository root on its own, and --source still works when you want a different directory.

Error: push access denied, repository does not exist or may require authorization

With the Go image fixed, dagger call publish --source=. failed after 28s with insufficient_scope: authorization failed, and all failed the same way because it called publish. The old module hardcoded myregistry/myapp, a Docker Hub path nobody owns. Taking the address as an argument fixes it, and it also stops all from pushing on every local run, which Earthly only did with --push.

dagger call publish push access denied error and export image client has no supported api error

Our first test with the new module produced the last error in that capture, a different problem that only shows up once you stop pushing from inside all.

Error: client has no supported api for loading image

Our first version of the new all function called export_image("myapp:latest") inside the module, the obvious translation of SAVE IMAGE. It failed after 5.2s, because module code runs inside the engine and has no route to your Docker daemon. Return the dagger.Container instead and chain export-image --name=myapp:latest on the command line, where the CLI talks to the host. The same rule applies to export --path for files.

Earthly CACHE did not speed up the rebuild

Strictly speaking this is the Earthly side of the comparison, but it will catch you if you tune the Earthfile before migrating. Top-level CACHE lines in the base target are scoped to that target and are not handed to children in version 0.8, so the one-line rebuild went from 1m2s to 1m8s. Use CACHE --id=<name> inside every target that compiles, as shown in Step 6, and the rebuild drops to 3.7s.

bin/myapp missing after earthly +all

After earthly +all, listing bin failed even though the build target saves the binary locally. Earthly only writes local artifacts for targets reached through a chain of BUILD commands. Our +all only reaches +build through a COPY in the docker target. Dagger makes the export explicit with dagger call build export --path=./bin/myapp, so if any CI step depended on that file appearing, give it its own call.

What I would change for production

Pin the engine first. The version in dagger.json and the one in CI should move together, because Dagger 1.0 is close and its migration notes change the project files. Upgrading on your own schedule beats finding out from a red pipeline. A short list of what we would do on a real repo:

  • Pin engineVersion and the CI version to the same release
  • Expect dagger-module.toml and dagger.toml in 1.0
  • Keep a persistent runner instead of paying for cache
  • Leave the Earthfile in place as the rollback

For a homelab or a single build box, skip Dagger Cloud entirely, since the warm engine cache is most of what Satellites sold. On a team, run both pipelines side by side for a week, with the Earthfile using CACHE --id so the comparison is honest. Delete it only once the Dagger job has stayed green on main long enough that nobody reaches for earthly any more. If your CI runs on Forgejo rather than GitHub or GitLab, the same dagger call all line works as a step in a Woodpecker CI pipeline, as long as that step can reach a Docker engine.

Keep reading

OpenCode CLI Cheat Sheet: Commands, Sessions and Fixes (PDF) AI OpenCode CLI Cheat Sheet: Commands, Sessions and Fixes (PDF) Install DeepSeek Harness (dsh) on Linux: Ubuntu, Debian, Rocky AI Install DeepSeek Harness (dsh) on Linux: Ubuntu, Debian, Rocky Best UI Applications for Managing Docker Containers Containers Best UI Applications for Managing Docker Containers Encapsule on Fedora 45: Isolated Dev Containers vs Toolbx Containers Encapsule on Fedora 45: Isolated Dev Containers vs Toolbx EcoFlow Home Assistant: Best Backup Batteries With Local Control Automation EcoFlow Home Assistant: Best Backup Batteries With Local Control Install Rundeck on Ubuntu 24.04 / Debian 13 Automation Install Rundeck on Ubuntu 24.04 / Debian 13

Leave a Comment

Press ESC to close