docker
A collection of functions for building, saving and publishing your Docker based projectsInstallation
dagger install github.com/purpleclay/daggerverse/docker@v0.6.0
Entrypoint
Return Type
Docker !
Arguments
Name | Type | Description |
---|---|---|
registry | String | the address of the registry to authenticate with |
username | String | the username for authenticating with the registry |
password | Secret | the password for authenticating with the registry |
Example
dagger -m github.com/purpleclay/daggerverse/docker@2a439e2b327ff561bea05a4edddd5276ac42407f call \
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 multi-platform images
Return Type
Build !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
dir | Directory ! | - | the path to a directory that will be used as the docker context |
file | String | "Dockerfile" | the path to the Dockfile |
args | [String ! ] | - | a list of build arguments in the format of arg=value |
target | String | - | the name of a target build stage |
platform | [Scalar ! ] | ["linux/amd64"] | a list of target platforms for cross-compilation |
Example
dagger -m github.com/purpleclay/daggerverse/docker@2a439e2b327ff561bea05a4edddd5276ac42407f call \
build --dir DIR_PATH
func (m *myModule) example(dir *Directory) *DockerBuild {
return dag.
Docker().
Build(dir)
}
@function
def example(dir: dagger.Directory) -> dag.DockerBuild:
return (
dag.docker()
.build(dir)
)
@func()
example(dir: Directory): DockerBuild {
return dag
.docker()
.build(dir)
}
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. A tarball will be generated using
the following convention <name>@<platform>.tar
(e.g. image~linux-amd64.tar)
Return Type
Directory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
name | String | "image" | a name for the exported tarball |
Example
dagger -m github.com/purpleclay/daggerverse/docker@2a439e2b327ff561bea05a4edddd5276ac42407f call \
build --dir DIR_PATH \
save
func (m *myModule) example(dir *Directory) *Directory {
return dag.
Docker().
Build(dir).
Save()
}
@function
def example(dir: dagger.Directory) -> dagger.Directory:
return (
dag.docker()
.build(dir)
.save()
)
@func()
example(dir: Directory): Directory {
return dag
.docker()
.build(dir)
.save()
}
image() 🔗
Retrieves a built image for a given platform as a container
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
platform | Scalar | "linux/amd64" | the platform of the docker image to return |
Example
dagger -m github.com/purpleclay/daggerverse/docker@2a439e2b327ff561bea05a4edddd5276ac42407f call \
build --dir DIR_PATH \
image
func (m *myModule) example(dir *Directory) *Container {
return dag.
Docker().
Build(dir).
Image()
}
@function
def example(dir: dagger.Directory) -> dagger.Container:
return (
dag.docker()
.build(dir)
.image()
)
@func()
example(dir: Directory): Container {
return dag
.docker()
.build(dir)
.image()
}
publish() 🔗
Publish the built image to a target registry. Supports publishing of mulit-platform images
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
ref | String ! | - | a fully qualified image reference without tags |
tags | [String ! ] | ["latest"] | a list of tags that should be published with the image |
Example
dagger -m github.com/purpleclay/daggerverse/docker@2a439e2b327ff561bea05a4edddd5276ac42407f call \
build --dir DIR_PATH \
publish --ref string
func (m *myModule) example(ctx context.Context, dir *Directory, ref string) string {
return dag.
Docker().
Build(dir).
Publish(ctx, ref)
}
@function
async def example(dir: dagger.Directory, ref: str) -> str:
return await (
dag.docker()
.build(dir)
.publish(ref)
)
@func()
async example(dir: Directory, ref: string): Promise<string> {
return dag
.docker()
.build(dir)
.publish(ref)
}