The Daggerverse in Practice

March 13, 2024

Mar 13, 2024

Jeremy Adams

Share
Share
Share
Share

Yesterday we introduced the Daggerverse, a searchable index of Dagger Functions. It already has thousands of functions, packaged in hundreds of modules developed by Daggernauts around the world. Let’s try some of them!

Lint a Python project with Ruff

In this Python linting example, we clone a perfectly good Python project, check it with Ruff (the excellent Python code linter and formatter), and then intentionally break something to see Ruff at work. This type of task works equally well as part of your inner dev loop or in CI as a quality check.

# Lint a Python project with Ruff:
# Function called from Module: check
# Input(s): a Directory arg, --directory
# Output(s): string (if there's an issue)
git clone https://github.com/ollama/ollama-python.git
cd ollama-python

# --directory . means we're passing in the current directory
dagger -m github.com/kpenfound/dagger-modules/ruff \
call check --directory .
# No output means, all clear!

# Let's make it break!
echo "foobar" >> pyproject.toml
dagger -m github.com/kpenfound/dagger-modules/ruff \
call check --directory .
# Oh yeah, ruff caught that.

Play YAML invaders

For a fun diversion, try this module with a simple play function. It requires no inputs and returns a Dagger Container type. Container types are useful for passing between functions in code, and you can also call any built-in Container functions from the dagger CLI by chaining. In this case, we invoke terminal to get an interactive session inside the Container returned by play. Many Daggernauts are experimenting with dev containers loaded with all the tools they need without installing anything locally.

# Just for fun, play a game of yamlinvaders:
# Function called from Module: play
# Input(s): <none>

Scan a container for vulnerabilities

Scanning for vulnerabilities is equally important throughout the development process and after container images land in registries, since CVEs can pop up at any time. It’s easy to package or wrap any tools and provide functions to give them a great developer experience.



Integrate with Docker registries

Building and pushing container images is a core use case for many of us, but usually a ton of “glue” is required for the last mile due to registry-specific differences in auth models, CLIs or libraries, internal tagging conventions, required compliance and security checks, and the vagaries of our CI systems. This glue usually takes the form of a pile of Bash and YAML that’s hard to test and maintain. Here are a few Dagger modules that show how you can create functions in real code that expose your ideal API, with sane defaults, and without extraneous details. Combine build and scan modules for a complete, custom solution that runs on any machine or in CI with just the dagger CLI.



Call the same function in the CLI and in code

Often, when building a developer platform or learning a new toolchain, we need to work with unfamiliar technologies. Some of these are daunting in their complexity. By leveraging the distilled knowledge of the community, you can become a pro in building Golang, running Dapr, or deploying to Netlify. Just a few inputs and outputs away. For example, Golang might seem easy if you write Go every day, but if you’re a Bash, Python, or TypeScript dev, can you use a Golang module with functions for building a Go project and returning the result in a container? Sure thing!



# Python
@function
def example() -> dagger.Container:
	return (
		dag.golang().build_container()
	)
// TypeScript
@func()
  example(): Container {
    return dag.golang().buildContainer()
}


Share your examples

Want to share a fun or powerful function you found (or published) on the Daggerverse? Share it on our Discord server, or on social like LinkedIn or X!

Yesterday we introduced the Daggerverse, a searchable index of Dagger Functions. It already has thousands of functions, packaged in hundreds of modules developed by Daggernauts around the world. Let’s try some of them!

Lint a Python project with Ruff

In this Python linting example, we clone a perfectly good Python project, check it with Ruff (the excellent Python code linter and formatter), and then intentionally break something to see Ruff at work. This type of task works equally well as part of your inner dev loop or in CI as a quality check.

# Lint a Python project with Ruff:
# Function called from Module: check
# Input(s): a Directory arg, --directory
# Output(s): string (if there's an issue)
git clone https://github.com/ollama/ollama-python.git
cd ollama-python

# --directory . means we're passing in the current directory
dagger -m github.com/kpenfound/dagger-modules/ruff \
call check --directory .
# No output means, all clear!

# Let's make it break!
echo "foobar" >> pyproject.toml
dagger -m github.com/kpenfound/dagger-modules/ruff \
call check --directory .
# Oh yeah, ruff caught that.

Play YAML invaders

For a fun diversion, try this module with a simple play function. It requires no inputs and returns a Dagger Container type. Container types are useful for passing between functions in code, and you can also call any built-in Container functions from the dagger CLI by chaining. In this case, we invoke terminal to get an interactive session inside the Container returned by play. Many Daggernauts are experimenting with dev containers loaded with all the tools they need without installing anything locally.

# Just for fun, play a game of yamlinvaders:
# Function called from Module: play
# Input(s): <none>

Scan a container for vulnerabilities

Scanning for vulnerabilities is equally important throughout the development process and after container images land in registries, since CVEs can pop up at any time. It’s easy to package or wrap any tools and provide functions to give them a great developer experience.



Integrate with Docker registries

Building and pushing container images is a core use case for many of us, but usually a ton of “glue” is required for the last mile due to registry-specific differences in auth models, CLIs or libraries, internal tagging conventions, required compliance and security checks, and the vagaries of our CI systems. This glue usually takes the form of a pile of Bash and YAML that’s hard to test and maintain. Here are a few Dagger modules that show how you can create functions in real code that expose your ideal API, with sane defaults, and without extraneous details. Combine build and scan modules for a complete, custom solution that runs on any machine or in CI with just the dagger CLI.



Call the same function in the CLI and in code

Often, when building a developer platform or learning a new toolchain, we need to work with unfamiliar technologies. Some of these are daunting in their complexity. By leveraging the distilled knowledge of the community, you can become a pro in building Golang, running Dapr, or deploying to Netlify. Just a few inputs and outputs away. For example, Golang might seem easy if you write Go every day, but if you’re a Bash, Python, or TypeScript dev, can you use a Golang module with functions for building a Go project and returning the result in a container? Sure thing!



# Python
@function
def example() -> dagger.Container:
	return (
		dag.golang().build_container()
	)
// TypeScript
@func()
  example(): Container {
    return dag.golang().buildContainer()
}


Share your examples

Want to share a fun or powerful function you found (or published) on the Daggerverse? Share it on our Discord server, or on social like LinkedIn or X!

Yesterday we introduced the Daggerverse, a searchable index of Dagger Functions. It already has thousands of functions, packaged in hundreds of modules developed by Daggernauts around the world. Let’s try some of them!

Lint a Python project with Ruff

In this Python linting example, we clone a perfectly good Python project, check it with Ruff (the excellent Python code linter and formatter), and then intentionally break something to see Ruff at work. This type of task works equally well as part of your inner dev loop or in CI as a quality check.

# Lint a Python project with Ruff:
# Function called from Module: check
# Input(s): a Directory arg, --directory
# Output(s): string (if there's an issue)
git clone https://github.com/ollama/ollama-python.git
cd ollama-python

# --directory . means we're passing in the current directory
dagger -m github.com/kpenfound/dagger-modules/ruff \
call check --directory .
# No output means, all clear!

# Let's make it break!
echo "foobar" >> pyproject.toml
dagger -m github.com/kpenfound/dagger-modules/ruff \
call check --directory .
# Oh yeah, ruff caught that.

Play YAML invaders

For a fun diversion, try this module with a simple play function. It requires no inputs and returns a Dagger Container type. Container types are useful for passing between functions in code, and you can also call any built-in Container functions from the dagger CLI by chaining. In this case, we invoke terminal to get an interactive session inside the Container returned by play. Many Daggernauts are experimenting with dev containers loaded with all the tools they need without installing anything locally.

# Just for fun, play a game of yamlinvaders:
# Function called from Module: play
# Input(s): <none>

Scan a container for vulnerabilities

Scanning for vulnerabilities is equally important throughout the development process and after container images land in registries, since CVEs can pop up at any time. It’s easy to package or wrap any tools and provide functions to give them a great developer experience.



Integrate with Docker registries

Building and pushing container images is a core use case for many of us, but usually a ton of “glue” is required for the last mile due to registry-specific differences in auth models, CLIs or libraries, internal tagging conventions, required compliance and security checks, and the vagaries of our CI systems. This glue usually takes the form of a pile of Bash and YAML that’s hard to test and maintain. Here are a few Dagger modules that show how you can create functions in real code that expose your ideal API, with sane defaults, and without extraneous details. Combine build and scan modules for a complete, custom solution that runs on any machine or in CI with just the dagger CLI.



Call the same function in the CLI and in code

Often, when building a developer platform or learning a new toolchain, we need to work with unfamiliar technologies. Some of these are daunting in their complexity. By leveraging the distilled knowledge of the community, you can become a pro in building Golang, running Dapr, or deploying to Netlify. Just a few inputs and outputs away. For example, Golang might seem easy if you write Go every day, but if you’re a Bash, Python, or TypeScript dev, can you use a Golang module with functions for building a Go project and returning the result in a container? Sure thing!



# Python
@function
def example() -> dagger.Container:
	return (
		dag.golang().build_container()
	)
// TypeScript
@func()
  example(): Container {
    return dag.golang().buildContainer()
}


Share your examples

Want to share a fun or powerful function you found (or published) on the Daggerverse? Share it on our Discord server, or on social like LinkedIn or X!

Get Involved With the community

Discover what our community is doing, and join the conversation on Discord & GitHub to help shape the evolution of Dagger.

Subscribe to our newsletter

Get Involved With the community

Discover what our community is doing, and join the conversation on Discord & GitHub to help shape the evolution of Dagger.

Subscribe to our newsletter

Get Involved With the community

Discover what our community is doing, and join the conversation on Discord & GitHub to help shape the evolution of Dagger.

Subscribe to our newsletter