image
This module has been generated via dagger init and serves as a reference tobasic module structure as you get started with Dagger.
Two functions have been pre-created. You can modify, delete, or add to them,
as needed. They demonstrate usage of arguments and return types using simple
echo and grep commands. The functions can be called from the dagger CLI or
from one of the SDKs.
The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.
Installation
dagger install github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4bEntrypoint
Return Type
Image !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| baseHadolintContainer | Container | - | base hadolint container It need contain hadolint |
| buildContainer | Container | - | The external build of container Usefull when need build args |
Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
func (m *MyModule) Example() *dagger.Image {
return dag.
Image()
}@function
def example() -> dagger.Image:
return (
dag.image()
)@func()
example(): Image {
return dag
.image()
}Types
Image 🔗
build() 🔗
Build permit to build image from Dockerfile
Return Type
Build !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | the source directory |
| dockerfile | String | "Dockerfile" | The dockerfile path |
| withDirectories | [Directory ! ] | - | Set extra directories |
Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
build --source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.ImageBuild {
return dag.
Image().
Build(source)
}@function
def example(source: dagger.Directory) -> dagger.ImageBuild:
return (
dag.image()
.build(source)
)@func()
example(source: Directory): ImageBuild {
return dag
.image()
.build(source)
}ci() 🔗
Ci runs lint, build, and push (when enabled) as a single CI entrypoint.
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | Source directory |
| dockerfile | String | "Dockerfile" | Dockerfile path |
| ci | Boolean | - | Run in ci: push the image to the registry |
| registry | String | - | The registry server |
| repositoryName | String | - | The repository name |
| version | String | - | The image version to publish |
| registryUsername | Secret | - | The registry username |
| registryPassword | Secret | - | The registry password |
| dryRun | Boolean | - | Dry-run: skip the push and its requirement checks even when ci is set |
Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
ci --source DIR_PATHfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Directory {
return dag.
Image().
Ci(source)
}@function
def example(source: dagger.Directory) -> dagger.Directory:
return (
dag.image()
.ci(source)
)@func()
example(source: Directory): Directory {
return dag
.image()
.ci(source)
}generateCi() 🔗
GenerateCi generates CI pipeline files for the given CI system.
Return Type
Directory !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| ci | String ! | - | The CI runner: github, jenkins, or gitlab |
| dockerfile | String | "Dockerfile" | Dockerfile path to lint and build |
| branches | [String ! ] | ["main"] | Branches that trigger the pipeline |
| daggerVersion | String | - | Dagger CLI version to use in CI (empty = engine default) |
| registry | String | - | OCI registry URL where the image is pushed. Required by the generated pipeline (it runs with –ci true). |
| repository | String | - | Repository path inside the registry. Required when registry is set. |
| defaultBranch | String | "main" | Branch commits land here when running on a tag. |
| moduleRef | String | - | Configurable dagger module reference. Defaults to this module’s current version (auto-detected). |
| registryUsernameKey | String | - | GitHub: secret name for registry username (empty = github.actor). |
| registryPasswordKey | String | - | GitHub: secret name for registry password (empty = GITHUB_TOKEN). |
| registryCredential | String | - | Jenkins: credential id for registry username/password. |
| gitTokenCredential | String | - | Jenkins: credential id for git token. |
| registryUsernameVar | String | - | GitLab: CI/CD variable name for registry username. |
| registryPasswordVar | String | - | GitLab: CI/CD variable name for registry password. |
| gitTokenVar | String | - | GitLab: CI/CD variable name for git token. |
| daggerKubernetesToken | String | - | Jenkins: dagger kubernetes token credential ID. When set, the Jenkinsfile uses the daggerKubernetes shared library step. |
| daggerKubernetesUrl | String | - | Jenkins: dagger kubernetes server URL. |
| forceDaggerMd | Boolean | - | Force overwrite DAGGER.md even if it already exists in source. |
Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
generate-ci --ci stringfunc (m *MyModule) Example(ci string) *dagger.Directory {
return dag.
Image().
Generateci(ci)
}@function
def example(ci: str) -> dagger.Directory:
return (
dag.image()
.generateci(ci)
)@func()
example(ci: string): Directory {
return dag
.image()
.generateCi(ci)
}getBaseHadolintContainer() 🔗
GetBaseHadolintContainer return the default image for hadolint
Return Type
Container ! Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
get-base-hadolint-containerfunc (m *MyModule) Example() *dagger.Container {
return dag.
Image().
Getbasehadolintcontainer()
}@function
def example() -> dagger.Container:
return (
dag.image()
.getbasehadolintcontainer()
)@func()
example(): Container {
return dag
.image()
.getBaseHadolintContainer()
}lint() 🔗
Lint permit to lint dockerfile image
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| source | Directory ! | - | the source directory |
| dockerfile | String | - | The dockerfile path |
| threshold | String | - | The failure threshold |
Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
lint --source DIR_PATHfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory) string {
return dag.
Image().
Lint(ctx, source)
}@function
async def example(source: dagger.Directory) -> str:
return await (
dag.image()
.lint(source)
)@func()
async example(source: Directory): Promise<string> {
return dag
.image()
.lint(source)
}withBuildArg() 🔗
Return Type
Image !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| name | String ! | - | The build ard name |
| val | String ! | - | The build arg value |
Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
with-build-arg --name string --val stringfunc (m *MyModule) Example(name string, val string) *dagger.Image {
return dag.
Image().
Withbuildarg(name, val)
}@function
def example(name: str, val: str) -> dagger.Image:
return (
dag.image()
.withbuildarg(name, val)
)@func()
example(name: string, val: string): Image {
return dag
.image()
.withBuildArg(name, val)
}Build 🔗
getContainer() 🔗
GetContainer permit to get the container
Return Type
Container ! Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
build --source DIR_PATH \
get-containerfunc (m *MyModule) Example(source *dagger.Directory) *dagger.Container {
return dag.
Image().
Build(source).
Getcontainer()
}@function
def example(source: dagger.Directory) -> dagger.Container:
return (
dag.image()
.build(source)
.getcontainer()
)@func()
example(source: Directory): Container {
return dag
.image()
.build(source)
.getContainer()
}push() 🔗
Push permit to push image
Return Type
String !Arguments
| Name | Type | Default Value | Description |
|---|---|---|---|
| repositoryName | String ! | - | The repository name |
| version | String ! | - | The version |
| withRegistryUsername | Secret | - | The registry username |
| withRegistryPassword | Secret | - | The registry password |
| registryUrl | String ! | - | The registry url |
Example
dagger -m github.com/disaster37/dagger-library-go/image@6dc20d4b87a358515dd2f2ddb932f1868ce80d4b call \
build --source DIR_PATH \
push --repository-name string --version string --registry-url stringfunc (m *MyModule) Example(ctx context.Context, source *dagger.Directory, repositoryName string, version string, registryUrl string) string {
return dag.
Image().
Build(source).
Push(ctx, repositoryName, version, registryUrl)
}@function
async def example(source: dagger.Directory, repositoryname: str, version: str, registryurl: str) -> str:
return await (
dag.image()
.build(source)
.push(repositoryname, version, registryurl)
)@func()
async example(source: Directory, repositoryName: string, version: string, registryUrl: string): Promise<string> {
return dag
.image()
.build(source)
.push(repositoryName, version, registryUrl)
}