Third-Party Packages
Dagger Functions are just regular code, written in your usual programming language. One of the key advantages of this approach is that it opens up access to your language's existing ecosystem of packages or modules. You can easily import these packages/modules in your Dagger module via your language's package manager.
- Go
- Python
- TypeScript
To add a Go module, add it to your go.mod
file using go get
. For example:
go get github.com/spf13/cobra
To add a Python package, add it to your pyproject.toml
file using your chosen package manager. For example:
- uv
- poetry
- uv pip
- pip
uv add requests
poetry add requests
Add the dependency manually to pyproject.toml
:
[project]
dependencies = [
"requirements>=2.32.3",
]
Then install into your virtual environment:
uv pip install -e ./sdk -e .
There's no need to activate the virtual environment before uv pip install
, but it does need to exist.
Add the dependency manually to pyproject.toml
:
[project]
dependencies = [
"requirements>=2.32.3",
]
Then install into your virtual environment:
python -m pip install -e ./sdk -e .
If you haven't setup your local environment yet, see IDE Integration.
Third-party dependencies are managed in the same way as any normal Python project. The only limitation is in "pinning" the dependencies. Currently, Dagger can install directly from a uv.lock
file, or a pip-tools compatible requirements.lock
file (notice .lock
extension, not .txt
). See Language-native packaging for more information.
To add a TypeScript package, add it to the package.json
file using your favorite package manager. For example:
npm install pm2
Pinning a specific dependency version or adding local dependencies are supported, in the same way as any Node.js project.