dagger-modules
Reusable Dagger CI/CD modules for building and pushing container images.
Installation
dagger install git.xarif.de/base/dagger-modules@1503dfdc764cd5c48d8e198a5d9a844c9461a700Entrypoint
Return Type
DaggerModules Example
dagger -m git.xarif.de/base/dagger-modules@1503dfdc764cd5c48d8e198a5d9a844c9461a700 call \
func (m *MyModule) Example() *dagger.DaggerModules {
return dag.
DaggerModules()
}@function
def example() -> dagger.DaggerModules:
return (
dag.dagger_modules()
)@func()
example(): DaggerModules {
return dag
.daggerModules()
}Types
DaggerModules 🔗
buildImage() 🔗
BuildImage builds a container from a Dockerfile in the given source directory.
Return Type
Container !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Source directory containing the Dockerfile |
| dockerfile | String | "Dockerfile" | Path to the Dockerfile relative to source root |
Example
dagger -m git.xarif.de/base/dagger-modules@1503dfdc764cd5c48d8e198a5d9a844c9461a700 call \
build-image --source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Container {
return dag.
DaggerModules().
BuildImage(source)
}@function
def example(source: dagger.Directory) -> dagger.Container:
return (
dag.dagger_modules()
.build_image(source)
)@func()
example(source: Directory): Container {
return dag
.daggerModules()
.buildImage(source)
}publishImage() 🔗
PublishImage builds and pushes a container image to an OCI registry. If a test spec file is provided, tests must pass before pushing. Returns the image digest of the ref-tagged push.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Source directory containing the Dockerfile |
| registry | String ! | - | Registry address (hostname or URL — protocol prefix is stripped automatically) |
| username | String ! | - | Registry username |
| password | Secret ! | - | Registry password or token |
| repository | String ! | - | Repository path, e.g. "myuser/myrepo" or "mygroup/myrepo" |
| refName | String ! | - | Git ref name used as image tag alongside "latest" |
| dockerfile | String | "Dockerfile" | Path to the Dockerfile relative to source root |
| tests | File | - | YAML test specification file — if provided, tests must pass before pushing |
Example
dagger -m git.xarif.de/base/dagger-modules@1503dfdc764cd5c48d8e198a5d9a844c9461a700 call \
publish-image --source DIR_PATH --registry string --username string --password env:MYSECRET --repository string --ref-name stringfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory, registry string, username string, password *dagger.Secret, repository string, refName string) string {
return dag.
DaggerModules().
PublishImage(ctx, source, registry, username, password, repository, refName)
}@function
async def example(source: dagger.Directory, registry: str, username: str, password: dagger.Secret, repository: str, ref_name: str) -> str:
return await (
dag.dagger_modules()
.publish_image(source, registry, username, password, repository, ref_name)
)@func()
async example(source: Directory, registry: string, username: string, password: Secret, repository: string, refName: string): Promise<string> {
return dag
.daggerModules()
.publishImage(source, registry, username, password, repository, refName)
}testImage() 🔗
TestImage builds a container and runs tests defined in a YAML spec file. Returns a summary of passed tests or an error on first failure.
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Source directory containing the Dockerfile |
| tests | File ! | - | YAML test specification file |
| dockerfile | String | "Dockerfile" | Path to the Dockerfile relative to source root |
Example
dagger -m git.xarif.de/base/dagger-modules@1503dfdc764cd5c48d8e198a5d9a844c9461a700 call \
test-image --source DIR_PATH --tests file:pathfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory, tests *dagger.File) string {
return dag.
DaggerModules().
TestImage(ctx, source, tests)
}@function
async def example(source: dagger.Directory, tests: dagger.File) -> str:
return await (
dag.dagger_modules()
.test_image(source, tests)
)@func()
async example(source: Directory, tests: File): Promise<string> {
return dag
.daggerModules()
.testImage(source, tests)
}