Dagger
Search

docker

A collection of functions for building, saving and publishing your Docker based projects

Installation

dagger install github.com/purpleclay/daggerverse/docker@0379ea49539f37560ca5199a26cb117d58bb1f1e

Entrypoint

Return Type
Docker !
Arguments
NameTypeDescription
registryString the address of the registry to authenticate with
usernameString the username for authenticating with the registry
passwordSecret the password for authenticating with the registry
Example
func (m *myModule) example() *Docker  {
	return dag.
			Docker()
}
@function
def example() -> dag.Docker:
	return (
		dag.docker()
	)
@func()
example(): Docker {
	return dag
		.docker()
}

Types

Docker

Docker dagger module

build()

Build an image using a Dockerfile. Supports cross-compilation

Return Type
Build !
Arguments
NameTypeDefault ValueDescription
dirDirectory !-the path to a directory that will be used as the docker context
fileString !"Dockerfile"the path to the Dockfile
args[String ! ] -a list of build arguments in the format of arg=value
targetString -the name of a target build stage
platform[String ! ] -a list of target platforms for cross-compilation
Example
dagger -m github.com/purpleclay/daggerverse/docker@0379ea49539f37560ca5199a26cb117d58bb1f1e call \
 build --dir DIR_PATH --file string \
 save
func (m *myModule) example(dir *Directory, file string) *DockerBuild  {
	return dag.
			Docker().
			Build(dir, file)
}
@function
def example(dir: dagger.Directory, file: str) -> dag.DockerBuild:
	return (
		dag.docker()
		.build(dir, file)
	)
@func()
example(dir: Directory, file: string): DockerBuild {
	return dag
		.docker()
		.build(dir, file)
}

Build

DockerBuild contains an image built from the provided Dockerfile, it serves as an intermediate type for chaining other functions. If multiple platforms were provided, then multiple images will exist

save()

Save the built image as a tarball ready for exporting

Return Type
Directory !
Arguments
NameTypeDefault ValueDescription
nameString "image"a name for the exported tarball, will automatically be suffixed by its platform (e.g. image_linux_amd64.)
Example
dagger -m github.com/purpleclay/daggerverse/docker@0379ea49539f37560ca5199a26cb117d58bb1f1e call \
 build --dir DIR_PATH --file string \
 save
func (m *myModule) example(dir *Directory, file string) *Directory  {
	return dag.
			Docker().
			Build(dir, file).
			Save()
}
@function
def example(dir: dagger.Directory, file: str) -> dagger.Directory:
	return (
		dag.docker()
		.build(dir, file)
		.save()
	)
@func()
example(dir: Directory, file: string): Directory {
	return dag
		.docker()
		.build(dir, file)
		.save()
}

publish()

Publish the built image to a target registry

Return Type
String !
Arguments
NameTypeDefault ValueDescription
refString !-a fully qualified image reference without tags
tags[String ! ] -a list of tags that should be published with the image. If any monorepo tags are detected, they will be sanitised default="latest"
Example
dagger -m github.com/purpleclay/daggerverse/docker@0379ea49539f37560ca5199a26cb117d58bb1f1e call \
 build --dir DIR_PATH --file string \
 publish --ref string
func (m *myModule) example(ctx context.Context, dir *Directory, file string, ref string) string  {
	return dag.
			Docker().
			Build(dir, file).
			Publish(ctx, ref)
}
@function
async def example(dir: dagger.Directory, file: str, ref: str) -> str:
	return await (
		dag.docker()
		.build(dir, file)
		.publish(ref)
	)
@func()
async example(dir: Directory, file: string, ref: string): Promise<string> {
	return dag
		.docker()
		.build(dir, file)
		.publish(ref)
}