Dagger
Search

cowsay

Not intended to be used as a dagger module because it's so simple, more of an example to copy from.

Example .github/workflows/docker-publish.yaml:

``` name: 'build-and-push'

on: push: branches: - main

jobs: dagger: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout uses: actions/checkout@v4

- name: Dagger Build & Push uses: dagger/dagger-for-github@v5 with: version: "0.11.0" verb: call args: build-and-push --registry=$DOCKER_REGISTRY --image-name=$DOCKER_IMAGE_NAME --username=$DOCKER_USERNAME --password=env:DOCKER_PASSWORD --build-context . env: DOCKER_REGISTRY: ghcr.io DOCKER_IMAGE_NAME: ${{ github.repository }} DOCKER_USERNAME: ${{ github.actor }} DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} ```

This is how you acquire "packages" write permission, then call the dagger-for-github module with DOCKER_REGISTRY, DOCKER_IMAGE_NAME, DOCKER_USERNAME and DOCKER_PASSWORD set appropriately.

Nothing in the dagger module is specific to GHCR, it's just: * Build the container in the usual way with Dagger. Here we make a cowsay container that says "How now, brown cow", showing how to pass build context from the filesystem * Use `ctr.WithRegistryAuth(registry, username, password).Publish(ctx, registry+"/"+imageName)` to publish the container to the ghcr registry.

Installation

dagger install github.com/lukemarsden/dagger-ghcr-demo@v0.1.0

Entrypoint

Return Type
Cowsay
Example
dagger -m github.com/lukemarsden/dagger-ghcr-demo@afe4a466cc46f76e96d9c4554faae99580dcbf8f call \
func (m *myModule) example() *Cowsay  {
	return dag.
			Cowsay()
}
@function
def example() -> dag.Cowsay:
	return (
		dag.cowsay()
	)
@func()
example(): Cowsay {
	return dag
		.cowsay()
}

Types

Cowsay 🔗

build() 🔗

Application specific build logic

Return Type
Container !
Arguments
NameTypeDefault ValueDescription
buildContextDirectory !-No description provided
Example
dagger -m github.com/lukemarsden/dagger-ghcr-demo@afe4a466cc46f76e96d9c4554faae99580dcbf8f call \
 build --build-context DIR_PATH
func (m *myModule) example(buildContext *Directory) *Container  {
	return dag.
			Cowsay().
			Build(buildContext)
}
@function
def example(build_context: dagger.Directory) -> dagger.Container:
	return (
		dag.cowsay()
		.build(build_context)
	)
@func()
example(buildContext: Directory): Container {
	return dag
		.cowsay()
		.build(buildContext)
}

buildAndPush() 🔗

Take the built container and push it

Return Type
Void !
Arguments
NameTypeDefault ValueDescription
registryString !-No description provided
imageNameString !-No description provided
usernameString !-No description provided
passwordSecret !-No description provided
buildContextDirectory !-No description provided
Example
dagger -m github.com/lukemarsden/dagger-ghcr-demo@afe4a466cc46f76e96d9c4554faae99580dcbf8f call \
 build-and-push --registry string --image-name string --username string --password env:MYSECRET --build-context DIR_PATH
func (m *myModule) example(ctx context.Context, registry string, imageName string, username string, password *Secret, buildContext *Directory)   {
	return dag.
			Cowsay().
			BuildAndPush(ctx, registry, imageName, username, password, buildContext)
}
@function
async def example(registry: str, image_name: str, username: str, password: dagger.Secret, build_context: dagger.Directory) -> None:
	return await (
		dag.cowsay()
		.build_and_push(registry, image_name, username, password, build_context)
	)
@func()
async example(registry: string, imageName: string, username: string, password: Secret, buildContext: Directory): Promise<void> {
	return dag
		.cowsay()
		.buildAndPush(registry, imageName, username, password, buildContext)
}