Dagger
Search

dagger-modules

Reusable Dagger CI/CD modules for building, testing, and publishing container images.

Installation

dagger install git.xarif.de/base/dagger-modules@8ad656c3fe30e4c142a2d4d354065b4f13227576

Entrypoint

Return Type
DaggerModules
Example
dagger -m git.xarif.de/base/dagger-modules@8ad656c3fe30e4c142a2d4d354065b4f13227576 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 🔗

DaggerModules is the main entry point for the Dagger module.

buildImage() 🔗

BuildImage builds a container from a Dockerfile in the given source directory and, optionally, runs a YAML-defined test suite against the freshly-built container before returning it.

When --tests is omitted, the build is pure (no execution) and returns the container lazily. When --tests is supplied, tests are executed eagerly and any failure short-circuits the call with an error.

PublishImage delegates to this function; there is no separate TestImage.

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-Source directory containing the Dockerfile
dockerfileString "Dockerfile"Path to the Dockerfile relative to source root
buildArg[String ! ] -Repeatable build arguments in KEY=VALUE form (e.g. `--build-arg=VERSION=1.2.3`)
buildSecret[Secret ! ] -Repeatable build secrets, each provided as a Dagger secret. Inside the Dockerfile, mount as `RUN --mount=type=secret,id=<secret-name> ...`. The secret's Dagger name (set via `--build-secret=name:env://VAR`) is used as the secret id.
platformString -Target platform (e.g. `linux/amd64`, `linux/arm64`). Defaults to engine native.
targetString -Target build stage in a multi-stage Dockerfile.
testsFile -YAML test specification file. When provided, tests are executed against the built container and any failure aborts the call.
rootDirectory -Root directory of the repository. Used to resolve mount paths in test specs independently of the build-context (--source). Defaults to the caller's working directory.
Example
dagger -m git.xarif.de/base/dagger-modules@8ad656c3fe30e4c142a2d4d354065b4f13227576 call \
 build-image --source DIR_PATH
func (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.

Always pushes two tags: latest and the sanitized --ref-name.

When --ref-name is a SemVer-style tag (e.g. v1.2.3), additional floating tags v1.2 and v1 are also pushed unless --no-semver-tags is set. This is the conventional pattern for shared-action and GitHub Action repositories.

Additional ad-hoc tags can be supplied via repeatable --extra-tag flags.

If --tests is provided, tests must pass before any push happens. The build+test phase is delegated to BuildImage so the two functions stay in lockstep.

Returns the digest of the ref-tagged push.

Return Type
String !
Arguments
NameTypeDefault ValueDescription
sourceDirectory !-Source directory containing the Dockerfile
registryString !-Registry address (hostname or URL — protocol prefix is stripped automatically)
usernameString !-Registry username
passwordSecret !-Registry password or token
repositoryString !-Repository path, e.g. "myuser/myrepo" or "mygroup/myrepo"
refNameString !-Git ref name used as image tag alongside "latest"
dockerfileString "Dockerfile"Path to the Dockerfile relative to source root
testsFile -YAML test specification file — if provided, tests must pass before pushing
buildArg[String ! ] -Repeatable build arguments in KEY=VALUE form
buildSecret[Secret ! ] -Repeatable build secrets
platformString -Target platform (e.g. `linux/amd64`, `linux/arm64`)
targetString -Target build stage in a multi-stage Dockerfile
extraTag[String ! ] -Repeatable extra tags to push in addition to `latest`
noSemverTagsBoolean -Disable automatic SemVer floating-tag derivation (vMAJOR, vMAJOR.MINOR)
rootDirectory -Root directory of the repository. Used to resolve mount paths in test specs independently of the build-context (--source). Defaults to the caller's working directory.
Example
dagger -m git.xarif.de/base/dagger-modules@8ad656c3fe30e4c142a2d4d354065b4f13227576 call \
 publish-image --source DIR_PATH --registry string --username string --password env:MYSECRET --repository string --ref-name string
func (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)
}