### Start Ollama Server Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/configuration/llm Starts the Ollama server with host binding to make it accessible externally. Ensure Ollama is installed first. ```bash OLLAMA_HOST="0.0.0.0:11434" ollama serve ``` -------------------------------- ### Container Build Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/dang Demonstrates how to define a `build` function that returns a `Container!` type, setting up a Node.js environment and installing dependencies. ```APIDOC ## Container Build Example ### Description This code snippet shows a `build` function that returns a `Container!`. It initializes a container from a Node.js base image, sets up the working directory, installs npm packages, and runs a build script. ### Type Definition ``` pub build: Container! { container .from("node:20") .withDirectory("/app", source) .withWorkdir("/app") .withExec(["npm", "install"]) .withExec(["npm", "run", "build"]) } ``` ``` -------------------------------- ### Install and Check Dagger Modules Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/adopting/workspace-setup Installs recommended modules and runs checks. `dagger mod install` creates or updates `.dagger/config.toml`. Repeat until coverage is satisfactory. ```bash dagger mod install github.com/dagger/eslint dagger check ``` -------------------------------- ### Install Dagger CLI with install.sh and sudo Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Installs the Dagger CLI using the install.sh script with sudo privileges when the user lacks permissions for the default installation directory. ```bash curl -fsSL https://dl.dagger.io/dagger/install.sh | BIN_DIR=/usr/local/bin sudo -E sh ``` -------------------------------- ### Go Example Function Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/testing Implement a Go function within an example module to demonstrate calling another module's function. This example calls the 'Hello' function from the 'Greeter' module. ```go func (m *Examples) GreeterHello(ctx context.Context) error { greeting, err := dag.Greeter().Hello(ctx, "World") if err != nil { return err } // Do something with the greeting _ = greeting return nil } ``` -------------------------------- ### Install Recommended Dagger Modules Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/quickstart Install selected Dagger modules for linting, testing, and formatting. This creates a .dagger/config.toml file. ```bash dagger mod install github.com/dagger/eslint dagger mod install github.com/dagger/vitest dagger mod install github.com/dagger/prettier ``` -------------------------------- ### Fork and Clone Example Project Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/quickstart Use the GitHub CLI to fork the example project and clone it locally. Ensure your 'origin' remote points to your fork. ```bash gh repo fork dagger/hello-dagger --clone --default-branch-only cd hello-dagger ``` -------------------------------- ### Go Example Module Configuration Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/testing Configure a Go example module by creating a dagger.json file. This sets up the module name, engine version, SDK source, and dependencies. ```bash mkdir -p examples/go cd examples/go cat > dagger.json <<'EOF' { "name": "examples-go", "engineVersion": "latest", "sdk": { "source": "go" }, "source": ".", "dependencies": [ { "name": "greeter", "source": "../.." } ] } EOF ``` -------------------------------- ### Start Dagger Services Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/cli Starts services defined by the module and exposes them on the host. Use the `-l` flag to list available services or specify a service pattern to start only specific services. ```bash dagger up [options] [pattern...] ``` ```bash dagger up ``` ```bash dagger up -l ``` ```bash dagger up web ``` -------------------------------- ### Manually Install Dagger Modules Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/adopting/workspace-setup Installs specific modules directly if you already know which ones you need. The first install creates `.dagger/config.toml`. ```bash dagger mod install github.com/dagger/eslint dagger mod install github.com/dagger/vitest dagger mod install github.com/dagger/prettier ``` -------------------------------- ### Example Ollama Environment Variables Configuration Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/configuration/llm An example configuration setting the base URL to 'http://192.168.64.1:11434/v1/' and the model to 'qwen2.5-coder:14b'. The trailing slash in the URL is mandatory. ```bash OPENAI_BASE_URL=http://192.168.64.1:11434/v1/ OPENAI_MODEL=qwen2.5-coder:14b ``` -------------------------------- ### Install and Run Go Module Checks Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/go Install the Go module and then run general checks or specific Go workflows like testing all modules. ```bash dagger mod install github.com/dagger/go dagger check # run every check in the workspace dagger check go:test-all # run Go tests across every module dagger check go:lint-all # run golangci-lint across every module ``` -------------------------------- ### Setup Dagger Cloud Integration Provider Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/cli Use this command to set up a Dagger Cloud integration provider. The `--open` flag can be used to automatically open the setup URL in a browser. ```bash dagger integration setup ``` -------------------------------- ### TypeScript Example Module Configuration Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/testing Set up a TypeScript example module with a dagger.json file, defining its name, engine version, SDK, and module dependencies. ```bash mkdir -p examples/typescript cd examples/typescript cat > dagger.json <<'EOF' { "name": "examples-typescript", "engineVersion": "latest", "sdk": { "source": "typescript" }, "source": ".", "dependencies": [ { "name": "greeter", "source": "../.." } ] } EOF ``` -------------------------------- ### Install Python SDK Locally Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/python Install the Python SDK locally into an active virtual environment using `uv sync` or `uv pip install`. This ensures IDEs can resolve imports. ```bash uv sync / uv pip install -e ./sdk -e . ``` -------------------------------- ### Install and Run Vitest Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/vitest Install the Vitest module and then run the default check or a specific Vitest test suite. ```bash dagger mod install github.com/dagger/vitest dagger check # run every check in the workspace dagger check vitest:test # run the Vitest suite ``` -------------------------------- ### List and Filter Services Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/using-dagger/services Commands to list available services or start specific ones. You can list all services, start a single service by name, or start multiple services by listing their names. ```bash dagger up -l # list available services dagger up web # start only the 'web' service dagger up web api redis # start multiple services ``` -------------------------------- ### Install Jest Module and Run Checks Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/jest Installs the Jest module and demonstrates how to run all checks or specifically the Jest test suite. ```bash dagger mod install github.com/dagger/jest dagger check # run every check in the workspace dagger check jest:test # run the Jest suite ``` -------------------------------- ### Python Example Module Configuration Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/testing Configure a Python example module by creating a dagger.json file. This specifies the module's name, Dagger engine version, SDK source, and any dependencies. ```bash mkdir -p examples/python cd examples/python cat > dagger.json <<'EOF' { "name": "examples-python", "engineVersion": "latest", "sdk": { "source": "python" }, "source": ".", "dependencies": [ { "name": "greeter", "source": "../.." } ] } EOF ``` -------------------------------- ### Install Dagger CLI with Homebrew on macOS Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Installs the latest stable release of the Dagger CLI using Homebrew. Assumes Homebrew is already installed. ```bash brew install dagger/tap/dagger ``` -------------------------------- ### Install Prettier Module and Run Checks Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/prettier Installs the Prettier module and demonstrates how to run general workspace checks or specific Prettier formatting checks. ```bash dagger mod install github.com/dagger/prettier dagger check # run every check in the workspace dagger check prettier:check # fail when source files are not formatted ``` -------------------------------- ### Start All Services Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/using-dagger/services Use this command to start all services defined in your workspace. Services run in ephemeral containers and their ports are tunneled to your local machine. Stop them with Ctrl+C. ```bash dagger up ``` -------------------------------- ### Install PSScriptAnalyzer Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/psscriptanalyzer Installs the PSScriptAnalyzer Dagger module. This is the first step before using any of its functionalities. ```bash dagger mod install github.com/dagger/PsScriptAnalyzer ``` -------------------------------- ### Install a Dagger module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/cli Installs a Dagger module from a given URL and tag into the current workspace. If no workspace configuration exists, it will be created. ```bash dagger workspace install github.com/shykes/daggerverse/hello@v0.3.0 ``` -------------------------------- ### Install Module as Dependency Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/python Consumers can install your module as a dependency using the workspace tooling. ```bash dagger mod install github.com/you/your-module@v0.1.0 ``` -------------------------------- ### Install Go Module for Code Generation Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live Installs the Go Dagger module. This module is used for running code generators. ```bash dagger mod install github.com/dagger/go dagger generate ``` -------------------------------- ### Check Dagger CLI installation path on Linux Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Verifies the installation path of the Dagger CLI on Linux after installation with install.sh to the user's local bin directory. ```bash type dagger # Expected output: dagger is $HOME/.local/bin/dagger ``` -------------------------------- ### Service Integration Test Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/dang Demonstrates setting up a `Service` for integration tests, including a PostgreSQL database, and binding it to a test container. ```APIDOC ## Service Integration Test Example ### Description This code snippet defines a `MyCi` type that includes a `db` service (PostgreSQL) and an `integrationTest` function. The `integrationTest` function runs Go tests within a container that is bound to the `db` service. ### Type Definition ``` type MyCi { pub source: Directory! new(ws: Workspace!) { self.source = ws.directory("/") self } let db: Service { container .from("postgres:16") .withEnvVariable("POSTGRES_PASSWORD", "test") .withExposedPort(5432) .asService } pub integrationTest: Void @check { container .from("golang:1.22") .withDirectory("/app", source) .withServiceBinding("db", db) .withEnvVariable("DATABASE_URL", "postgres://postgres:test@db:5432/postgres") .withExec(["go", "test", "-tags=integration", "./..."]) .sync } } ``` ### Function: integrationTest #### Description Runs integration tests for the project. ``` -------------------------------- ### Install a Dagger Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules Installs a Dagger module from a given repository. This command is used to add a module to your workspace. ```bash dagger mod install github.com/dagger/go ``` -------------------------------- ### Install Dagger Helm Chart Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/adopting/scaling/openshift Install or upgrade the Dagger Helm chart in the `dagger` namespace using the configured `values.yaml` file. ```bash helm upgrade --create-namespace --install --namespace dagger dagger oci://registry.dagger.io/dagger-helm -f values.yaml ``` -------------------------------- ### Create Virtual Environment and Install Dependencies with uv Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/python Creates a virtual environment using 'uv venv' and installs dependencies from 'requirements.lock', including the SDK and the current project, in an editable mode. ```bash uv venv uv pip install -r requirements.lock -e ./sdk -e . ``` -------------------------------- ### greet Function Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/typescript A simple Dagger function that returns a greeting, demonstrating default and optional arguments. ```APIDOC ## greet ### Description Returns a greeting, optionally personalized. ### Method `greet(name?: string): string` ### Parameters #### Path Parameters None #### Query Parameters - **name** (string) - Optional - The name to greet. #### Request Body None ### Request Example ```bash dagger call greet dagger call greet --name=Sam ``` ### Response #### Success Response (200) - **result** (string) - The greeting message. #### Response Example ```json { "result": "Hello, world!" } ``` ```json { "result": "Hello, Sam!" } ``` ``` -------------------------------- ### test Function Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/typescript An example of a Dagger function that accepts a Directory and returns a Container, demonstrating the use of caches. ```APIDOC ## test ### Description Runs tests on a given source directory within a Node.js container with caching. ### Method `test(source: Directory): Container` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None explicitly shown for the function call itself. ### Response #### Success Response (200) - **container** (Container) - The resulting Dagger container after running tests. #### Response Example ```json { "container": { /* Container object details */ } } ``` ``` -------------------------------- ### Get Help for Init Function Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/python View the help message for the `init` function within the Python SDK. ```bash dagger -m github.com/dagger/python-sdk call init --help ``` -------------------------------- ### Verify Dagger CLI installation on Windows Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Confirms the successful installation of the Dagger CLI on Windows by checking its version. ```powershell dagger version ``` -------------------------------- ### Install and Run ESLint Check Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/eslint Install the ESLint module and run ESLint against the workspace source. This command runs ESLint using the project's local configuration. ```bash dagger mod install github.com/dagger/eslint dagger check dagger check eslint:lint ``` -------------------------------- ### Dagger Check Examples Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/cli Provides examples of using the 'dagger check' command for various scenarios, such as running all checks, listing checks, or running a specific check against an explicit workspace. ```bash dagger check # Run all checks dagger check -l # List all available checks dagger check go:lint # Run the go:lint check and any subchecks dagger -W github.com/acme/ws check go:lint # Run check(s) against explicit workspace ``` -------------------------------- ### Install Dagger CLI on Linux with install.sh Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Installs the latest stable release of the Dagger CLI on Linux by downloading and executing the install.sh script, placing the binary in the user's local bin directory. ```bash curl -fsSL https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh ``` -------------------------------- ### Install git-clone Task from Tekton Hub Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/adopting/triggers/tekton Installs the git-clone Task from Tekton Hub to enable repository cloning capabilities. ```bash tkn hub install task git-clone ``` -------------------------------- ### Recommend Dagger Modules Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/quickstart Scan your project to get recommendations for Dagger modules that match your tools. ```bash dagger mod recommend ``` -------------------------------- ### Install a Dagger Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/cli Installs a module into the current workspace. This command can take a module path and optionally a name for the module within the workspace. ```bash dagger module install [options] [flags] ``` ```bash dagger module install github.com/shykes/daggerverse/hello@v0.3.0 ``` -------------------------------- ### Eslint Module Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/dang A complete example of a Dagger module for linting, modeled after dagger/eslint. It utilizes a base Node.js image and runs ESLint on the project source. ```go type Eslint { "The source directory for the project." pub source: Directory! pub baseImageAddress: String! new( ws: Workspace!, baseImageAddress: String! = "node:25-alpine", ) { self.source = ws.directory("/") self.baseImageAddress = baseImageAddress self } pub lint: Void @check { nodejs(source, baseImageAddress).base.withExec(["npx", "eslint", "."]).sync null } } ``` -------------------------------- ### Install Biome Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/biomejs Install the Biome module using the dagger CLI. This command adds the module to your Dagger project. ```bash dagger mod install github.com/dagger/biomejs ``` -------------------------------- ### Install ShellCheck Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/shellcheck Install the ShellCheck module using the dagger CLI. This command fetches the module from its source repository. ```bash dagger mod install github.com/dagger/shellcheck ``` -------------------------------- ### Install Dagger CLI on Windows with winget Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Installs the latest stable release of the Dagger CLI on Windows using the Windows Package Manager (winget). ```powershell winget install Dagger.Cli ``` -------------------------------- ### Install ESLint and Prettier Modules Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live Installs the ESLint and Prettier Dagger modules. These modules can then be used for linting and formatting code across a project stack. ```bash dagger mod install github.com/dagger/eslint dagger mod install github.com/dagger/prettier dagger check ``` -------------------------------- ### Binary File Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/dang Illustrates how to define a `binary` function that returns a `File!` type, accessing a specific file within the built container. ```APIDOC ## Binary File Example ### Description This code snippet defines a `binary` function that returns a `File!`. It accesses a specific file located at `/app/dist/server.js` within the built container. ### Type Definition ``` pub binary: File! { build.file("/app/dist/server.js") } ``` ``` -------------------------------- ### Ruff Module Linting Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/go A comprehensive Go example demonstrating a Dagger module for linting Python code with Ruff. It includes custom types, secret handling, and error reporting. ```go package main import ( "context" "encoding/json" "errors" "fmt" "strings" "github.com/dagger/dagger/modules/ruff/internal/dagger" ) // Ruff is a fast Python linter implemented in Rust type Ruff struct{} // Lint a Python codebase func (ruff Ruff) Lint( // The Python source directory to lint source *dagger.Directory, ) *LintRun { return &LintRun{Source: source} } // The result of running the Ruff lint tool type LintRun struct { // +private Source *dagger.Directory } // Return a JSON report file for this run func (run LintRun) Report() *dagger.File { cmd := []string{"/ruff", "check", "--exit-zero", "--output-format", "json", "."} return dag. CurrentModule(). Source(). Directory("build"). DockerBuild(). WithMountedDirectory("", run.Source). WithExec(cmd, dagger.ContainerWithExecOpts{RedirectStdout: "ruff-report.json"}). File("ruff-report.json") } // Return an error if the run reported any issues func (run LintRun) Assert(ctx context.Context) error { contents, err := run.Report().Contents(ctx) if err != nil { return err } var issues []struct { Message string `json:"message"` } if err := json.Unmarshal([]byte(contents), &issues); err != nil { return err } if len(issues) > 0 { var lines []string for _, i := range issues { lines = append(lines, " - "+i.Message) } return errors.New(fmt.Sprintf("%d issues\n%s", len(issues), strings.Join(lines, "\n"))) } return nil } ``` -------------------------------- ### Install and Run Helm Checks with Dagger Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/helm Installs the Helm module and then runs all available checks within the workspace. This is a common starting point for integrating Helm validation into a Dagger workflow. ```bash dagger mod install github.com/dagger/helm dagger check # run every check in the workspace dagger check helm:lint # lint every discovered chart dagger check helm:assert-template # render discovered values files and fail on errors ``` -------------------------------- ### deploy Function Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/typescript An asynchronous Dagger function that deploys a service using a secret token, demonstrating secret handling. ```APIDOC ## deploy ### Description Deploys a service using a provided secret token. ### Method `async deploy(token: Secret): Promise` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash dagger call deploy --token=env:DEPLOY_TOKEN dagger call deploy --token=file:./token.txt dagger call deploy --token=cmd:"gh auth token" dagger call deploy --token=op://vault/item/field ``` ### Response #### Success Response (200) - **stdout** (string) - The standard output from the deployment command. #### Response Example ```json { "stdout": "[Deployment output as string]" } ``` ``` -------------------------------- ### Example Usage of Update Command Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/cli Illustrates how to invoke the 'dagger workspace update' command, either generally or for a specific module like 'wolfi'. ```bash "dagger workspace update" or "dagger workspace update wolfi" ``` -------------------------------- ### Define a Database Service Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/python Implement a function decorated with @function and @up to define a long-running service. This example starts a PostgreSQL database service. ```python import dagger from dagger import dag, function, object_type, up @object_type class MyModule: @function @up def database(self) -> dagger.Service: """Returns a postgres database service""" return ( dag.container() .from_("postgres:16") .with_exposed_port(5432) .as_service() ) ``` -------------------------------- ### Azure Pipelines YAML for Dagger Checks Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/adopting/triggers/azure-pipelines This YAML configuration sets up an Azure Pipeline to automatically check out code, install the Dagger CLI, and run Dagger checks. It includes environment variable setup for Dagger Cloud integration. ```yaml trigger: - main pool: name: 'Azure Pipelines' vmImage: ubuntu-latest steps: # full clone checkout required to prevent azure pipeline traces from being orphaned in the Dagger Cloud UI - checkout: self fetchDepth: 0 displayName: 'Checkout Source Code, fetch full history' # branch checkout required to prevent azure pipeline traces from being orphaned in the Dagger Cloud UI - script: git checkout $(Build.SourceBranchName) displayName: 'Checkout Source Branch' - script: curl -fsSL https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh displayName: 'Install Dagger CLI' - script: dagger check displayName: 'Run Dagger checks' env: # assumes the Dagger Cloud token is # in a secret named DAGGER_CLOUD_TOKEN # set via the Azure Pipeline settings UI/CLI # the secret is then explicitly mapped to the script env DAGGER_CLOUD_TOKEN: $(DAGGER_CLOUD_TOKEN) ``` -------------------------------- ### MyModule.build Function Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/typescript A Dagger function that returns a custom object type, containing a binary file and its version. ```APIDOC ## MyModule.build ### Description Builds a binary and returns its file and version information. ### Method `build(): BuildResult` ### Parameters None ### Request Example None explicitly shown for the function call itself. ### Response #### Success Response (200) - **binary** (File) - The built binary file. - **version** (string) - The version of the built application. #### Response Example ```json { "binary": { /* File object details */ }, "version": "1.0.0" } ``` ``` -------------------------------- ### Install Pytest Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/pytest Install the Pytest module using the dagger mod install command. ```bash dagger mod install github.com/dagger/pytest ``` -------------------------------- ### Configure ESLint Settings Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/modules/eslint Example of how to configure ESLint settings, such as package manager and base image, in the Dagger configuration file. ```toml [modules.eslint.settings] packageManager = "pnpm" baseImageAddress = "node:22-alpine" ``` -------------------------------- ### Go Workspace Setup Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/go Commands to initialize and use a Go workspace, stitching together multiple modules. This helps IDE tooling recognize all modules. ```bash # in the root of your repository go work init go work use ./ go work use ./path/to/module ``` -------------------------------- ### Check Dagger CLI installation path on macOS Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Verifies the installation path of the Dagger CLI on macOS after installation with Homebrew. ```bash type dagger # Expected output on macOS ARM: # dagger is /opt/homebrew/bin/dagger # Expected output on macOS Intel: # dagger is /usr/local/bin/dagger ``` -------------------------------- ### Install Dagger CLI with install.sh script Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Installs the latest stable release of the Dagger CLI using the install.sh script. This method is suitable for Linux and can be used on macOS if Homebrew is not preferred. ```bash curl -fsSL https://dl.dagger.io/dagger/install.sh | BIN_DIR=/usr/local/bin sh ``` -------------------------------- ### Execute Common Programming Language Scripts Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/cli Examples of using 'dagger exec' to run scripts written in Go, Node.js, and Python. ```bash dagger exec go run main.go ``` ```bash dagger exec node index.mjs ``` ```bash dagger exec python main.py ``` -------------------------------- ### Check installed Dagger CLI version Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Displays the currently installed version of the Dagger CLI. This command can be run after installation via Homebrew or install.sh. ```bash ./bin/dagger version # Expected output: dagger v0.21.3 (registry.dagger.io/engine:v0.21.3) darwin/amd64 ``` -------------------------------- ### Start and return an HTTP service Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/go This function starts a simple HTTP service within a container and returns it as a Dagger service. The service is configured to serve files from a working directory and exposes port 8080. ```APIDOC ## HttpService ### Description Starts and returns an HTTP service. ### Method (Not applicable, this is a Go function) ### Endpoint (Not applicable, this is a Go function) ### Parameters (None) ### Request Example (See Go code example for usage) ### Response #### Success Response (200) - **dagger.Service**: A Dagger service representing the running HTTP server. #### Response Example (See Go code example for usage) ``` -------------------------------- ### Check installed Dagger CLI version on Linux Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Displays the currently installed version of the Dagger CLI on Linux. This command confirms the installation and version number. ```bash ./bin/dagger version # Expected output: dagger v0.21.3 (registry.dagger.io/engine:v0.21.3) linux/amd64 ``` -------------------------------- ### Build Go Binary with Directory Exclusion Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/types/directory This example demonstrates building a Go binary within a container, excluding Git files and internal directories from the source. It then creates a new container including only the built binary. ```java import io.dagger.module.annotation.Function; import io.dagger.module.annotation.Object; import java.util.List; @Object public class MyModule { @Function public Container foo(Directory source) { Container builder = dag() .container() .from("golang:latest") .withDirectory( "/src", source, new Container.WithDirectoryArguments().withExclude(List.of("*.git", "internal"))) .withWorkdir("/src/hello") .withExec(List.of("go", "build", "-o", "hello.bin", ".")); return dag() .container() .from("alpine:latest") .withDirectory( "/app", builder.directory("/src/hello"), new Container.WithDirectoryArguments().withInclude(List.of("hello.bin"))) .withEntrypoint(List.of("/app/hello.bin")); } } ``` -------------------------------- ### TypeScript Example Function Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/testing Implement a TypeScript function in an example module to demonstrate calling Dagger functions. This example invokes the 'hello' function of the 'greeter' module. ```typescript @object() export class Examples { @func() greeterHello(): Promise { return dag .greeter() .hello("World") .then((_: string) => { // Do something with the greeting return; }); } } ``` -------------------------------- ### Install development release of Dagger CLI Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Installs the latest development release of the Dagger CLI by setting DAGGER_COMMIT=head in the install.sh script. This installs the CLI in the ./bin/dagger directory. ```bash curl -fsSL https://dl.dagger.io/dagger/install.sh | DAGGER_COMMIT=head sh ``` -------------------------------- ### Create Go Test Module Configuration Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/testing Sets up a Dagger test module in Go, including its configuration file and dependency on the greeter module. ```Shell mkdir tests cd tests cat > dagger.json <<'EOF' { "name": "tests", "engineVersion": "latest", "sdk": { "source": "go" }, "source": ".", "dependencies": [ { "name": "greeter", "source": ".." } ] } EOF ``` -------------------------------- ### Initialize Bun and Configure Dagger Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/configuration/modules Initialize Bun, install dependencies to generate a lock file, and configure the Dagger module. The module's `source` field must match the directory containing the lock file. ```bash bun init bun install # to generate the bun.lock file cat > dagger.json <<'EOF' { "name": "example", "engineVersion": "latest", "sdk": { "source": "typescript" }, "source": "." } EOF ``` -------------------------------- ### Python Example Function Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/testing Define a Python function within an example module to showcase interaction with other Dagger modules. This example calls the 'hello' function from the 'greeter' module. ```python @object_type class Examples: @function async def greeter_hello(self): greeting = await dag.greeter().hello("World") # Do something with the greeting ``` -------------------------------- ### Install development release of Dagger CLI on Windows PowerShell Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/getting-started/installation Installs the latest development release of the Dagger CLI on Windows using PowerShell. This command downloads and executes an installation script. ```powershell iwr -useb https://dl.dagger.io/dagger/install.ps1 | iex; Install-Dagger -DaggerCommit head ``` -------------------------------- ### Recommend Dagger Modules Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/adopting/workspace-setup Scans your project and suggests modules for detected tools, frameworks, and languages. Run this from the root of your repository. ```bash dagger mod recommend ``` -------------------------------- ### Initialize a new Go module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/go Create a new Go module using the SDK's `init` function. The module will be created inside a Git repository. The `--name` argument is required. ```bash dagger -m github.com/dagger/go-sdk call init --name my-module ``` -------------------------------- ### Get Python Version Configuration Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/python Confirm the configured Python version using `mod config get`. ```bash mod config get ``` -------------------------------- ### Constructor and Foo Function Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/go Demonstrates a module constructor (`New`) that accepts a Dagger Workspace to initialize the module's state with the project source. It also includes a 'Foo' function that uses the initialized source to list entries from a container. ```APIDOC ## New (Constructor) ### Description Initializes the module with the Dagger workspace, providing access to the project's source code. ### Method New ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **ws** (*dagger.Workspace) - Required - The current workspace, auto-populated by Dagger. ### Response #### Success Response (200) * **MyModule** - The initialized module object. #### Response Example ```json { "Source": "/" } ``` ## Foo ### Description Lists the entries within the project's source directory by mounting it into an Alpine container. ### Method Foo ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```bash dagger call foo ``` ### Response #### Success Response (200) * **[String]** - A list of strings representing the entries in the source directory. #### Response Example ```json [ "file1.txt", "subdir" ] ``` ``` -------------------------------- ### Security.describe Function Example Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/typescript An example of a Dagger function that accepts an enum as an argument, restricting input to predefined values. ```APIDOC ## Security.describe ### Description Describes a security scan at a given severity level. ### Method `describe(severity: Severity): string` ### Parameters #### Path Parameters None #### Query Parameters - **severity** (Severity) - Required - The severity level for the scan. Must be one of: Low, Medium, High, Critical. #### Request Body None ### Request Example None explicitly shown for the function call itself. ### Response #### Success Response (200) - **result** (string) - A description of the scan severity. #### Response Example ```json { "result": "scanning at severity [severity]" } ``` ``` -------------------------------- ### Initialize Container from Base Image (Go) Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/types/container Initializes a container from a specified base image using the `dagger.Container` type. ```Go package main import ( "context" "dagger/my-module/internal/dagger" ) type MyModule struct{} func (m *MyModule) Version( ctx context.Context, // +defaultAddress="alpine:latest" ctr *dagger.Container, ) (string, error) { return ctr.WithExec([]string{"cat", "/etc/alpine-release"}).Stdout(ctx) } ``` -------------------------------- ### Starter main.dang Module Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/dang The entry point for a starter Dang module, defining a simple 'hello' function. ```dang """ Starter Dang module generated by dang-sdk. """ type My_ci { """ Return a greeting from this Dang module. """ pub hello: String! { "hello from Dang" } } ``` -------------------------------- ### Initialize Deno and Configure Dagger Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/reference/configuration/modules Initialize Deno and configure the Dagger module. The module's `source` field must match the directory containing the `deno.json` file. Deno runtime support is experimental. ```bash deno init cat > dagger.json <<'EOF' { "name": "example", "engineVersion": "latest", "sdk": { "source": "typescript" }, "source": "." } EOF ``` -------------------------------- ### Accessing Files and Directories with Workspace Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/dang Demonstrates how to use ws.directory() for directories and ws.file() for files within a module. It illustrates absolute path resolution from the workspace root and relative path resolution from the workspace current working directory. ```go type MyCi { pub source: Directory! pub config: File! new(ws: Workspace!) { # Absolute: from the workspace root self.source = ws.directory("/src") # Relative: from the workspace cwd self.config = ws.file("tsconfig.json") self } } ``` -------------------------------- ### Initialize a Go module with a specific template Source: https://dx-d2f5ba4257e3a6c74e8c.exe.xyz/a/Us9cYiP9MvVPfiiDVnIjxwIuD3XBO1Vb/svc/docs-live/extending/sdks/go Use the `--template` argument to initialize a module from a specific starter template within the SDK module's `templates` directory. List available templates with `dagger -m github.com/dagger/go-sdk call templates`. ```bash dagger -m github.com/dagger/go-sdk call init --name my-module --template