ScriptsApr 7, 2026·2 min read

Dagger — CI/CD Pipelines as Code in Any Language

Run CI/CD pipelines locally and in the cloud with the same code. Write pipelines in TypeScript, Python, or Go instead of YAML. Containerized execution ensures identical results everywhere. 12,000+ stars.

TL;DR
Dagger replaces YAML-based CI/CD with real code in TypeScript, Python, or Go, running identically on your laptop and in CI.
§01

What it is

Dagger is a programmable CI/CD engine that lets you define pipelines in TypeScript, Python, or Go instead of vendor-specific YAML. Every pipeline step runs inside a container, so the behavior is identical whether you execute it on your laptop, in GitHub Actions, or in GitLab CI.

It targets platform engineers and DevOps teams tired of debugging YAML syntax errors, vendor lock-in, and the 'works on my machine' gap between local dev and CI environments.

§02

How it saves time or tokens

Traditional CI systems require pushing code to trigger a pipeline, waiting for results, then iterating. Dagger pipelines run locally in seconds, giving you instant feedback. Because pipelines are real code, you get IDE autocomplete, type checking, unit tests, and code reuse — none of which YAML supports. Debugging shifts from reading CI logs to running a debugger.

§03

How to use

  1. Install the Dagger CLI with curl -fsSL https://dl.dagger.io/dagger/install.sh | sh or brew install dagger/tap/dagger.
  2. Initialize a Dagger module in your project with dagger init --sdk=typescript (or python/go).
  3. Write your pipeline functions, then run them with dagger call <function-name>.
§04

Example

// dagger/src/index.ts
import { dag, Container, object, func } from '@dagger.io/dagger'

@object()
class MyPipeline {
  @func()
  async test(): Promise<string> {
    return dag
      .container()
      .from('node:20-slim')
      .withDirectory('/app', dag.host().directory('.'))
      .withWorkdir('/app')
      .withExec(['npm', 'install'])
      .withExec(['npm', 'test'])
      .stdout()
  }
}
§05

Related on TokRepo

§06

Common pitfalls

  • Dagger requires Docker (or a compatible container runtime) running locally. If Docker Desktop is not running, dagger call fails immediately.
  • Pipeline functions must be deterministic for caching to work. Non-deterministic steps (like fetching 'latest' tags) bust the cache on every run.
  • The SDK learning curve exists even though you write 'real code.' Understanding Dagger's container chaining model takes a few iterations.

Frequently Asked Questions

Does Dagger replace GitHub Actions or GitLab CI?+

Not exactly. Dagger replaces the YAML pipeline definitions, but you still need a CI runner to trigger builds on push or PR. You call Dagger from a minimal GitHub Actions workflow (or GitLab CI job). The key benefit is that the same pipeline runs locally and in CI without modification.

What languages can I write Dagger pipelines in?+

Dagger officially supports TypeScript, Python, and Go SDKs. Each SDK provides the same core functionality. Choose the language your team is most comfortable with. The underlying execution is identical regardless of SDK.

How does caching work in Dagger?+

Dagger automatically caches container layers and step outputs. If a step's inputs have not changed, Dagger skips re-execution and reuses the cached result. This makes subsequent pipeline runs significantly faster, similar to Docker layer caching but applied to your pipeline logic.

Can I use Dagger for production deployments?+

Yes. Dagger pipelines can include deployment steps (pushing Docker images, running Helm upgrades, calling cloud APIs). Since everything runs in containers, your deployment logic is reproducible and auditable.

How does Dagger compare to Earthly or Bazel?+

Earthly uses a Dockerfile-like syntax (Earthfile) while Dagger uses real programming languages. Bazel is a build system focused on hermetic builds for monorepos. Dagger is specifically designed for CI/CD pipelines and emphasizes local-remote parity and SDK-based authoring.

Citations (3)
🙏

Source & Thanks

Created by Dagger. Licensed under Apache 2.0.

dagger — stars 12,000+

Thanks for making CI/CD pipelines real code instead of YAML.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets