docs/current_docs/introduction/features/reusability.mdx
Dagger lets you encapsulate common tasks and workflows in reusable, shareable Dagger modules. These Dagger modules are simply collections of Dagger Functions, packaged together for easy sharing and consumption. Their design is inspired by Go modules:
Modern development takes place in a mix of languages, tools and platforms. In these environments, no one language or tool can "win"; every component must be interoperable with every other. Dagger is ideally suited to these polyglot environments, because Dagger modules are portable and reusable across languages. For example, a Python function can call a Go function, which can call a TypeScript function, and so on.
This feature immediately unlocks cross-team collaboration: even though different teams might prefer different languages, the Dagger modules they create are instantly compatible and usable by other teams. It also means that you no longer need to care which language your CI tooling is written in; you can use the one that you're most comfortable with or that best suits your requirements.
Here's an example, where a Dagger Function written in Python calls both core functions and third-party Dagger Functions written in Go:
@function
async def ci(self, source: dagger.Directory) -> str:
# Use third-party Golang module to configure project
go_project = dag.golang().with_project(source)
# Run Go tests using Golang module
await go_project.test()
# Get container with built binaries using Golang module
image = await go_project.build_container()
# Push image to a registry using core Dagger API
ref = await image.publish("ttl.sh/demoapp:1h")
# Scan image for vulnerabilities using third-party Trivy module
return await dag.trivy().scan_container(dag.container().from_(ref))
Modules integrate seamlessly with Dagger Cloud, which offers a collaborative environment to manage modules, visualize dependencies, and trace executions.
To make it easier to search and consume Dagger modules, the Daggerverse is a free service run by Dagger, which indexes all publicly available Dagger modules. These might be Dagger modules developed by your team, your organization or the broader Dagger community. By importing and reusing these Dagger modules in your workflows and across your teams, you can significantly speed up development.