#Update container image name and version

1 messages ยท Page 1 of 1 (latest)

nocturne chasm
#

Hi. I'm new to dagger, but i have managed to create a function, that builds and uploads a container from a dockerfile.
My question is, what is the best way to update my deployment.yaml with that new container name and version, and maybe even upload it to git ?
I found this, but i have a hard time getting it working, and i'm not sure it's the best way ?
https://daggerverse.dev/mod/github.com/matipan/daggerverse/image-updater@c3e082566aa7dc6f14de00d1241fceee8798bf3a

Btw. I'm doing everything in python.

My current code

from typing import Annotated

import dagger
from dagger import Doc, dag, function, object_type


@object_type
class App:

    @function
    def build(
        self,
        src: Annotated[
            dagger.Directory,
            Doc("location of directory containing Dockerfile"),
        ],
    ) -> str:
        """Build and publish image from existing Dockerfile"""
        ref = (
            dag.container()
            .with_directory("/src", src)
            .with_workdir("/src")
            .directory("/src")
            .docker_build()  # build from Dockerfile
            .publish("ttl.sh/my-shiny-app")
        )
        return ref
valid hornet
#

cc @floral abyss (who wrote that module)

I think that sounds like a reasonable way to go - it's maintained by one of the members of the dagger team, I think we use it internally? Curious why you don't think this is the best way (I'm a bit of a kube noob honestly)

nocturne chasm
#

Well mostly due to the fact, that i can't get it to work ๐Ÿ™‚
So instead of asking for how to fix it, i wanted to ask broader.

I'm currently testing with the following function

@function
    async def update(repo: str, branch: str, deploy_filepath: str, image_url: str, git_user: str, git_email: str, git_password: str, force_with_lease: bool) -> None:
        return await (
            dag.image_updater()
            .update(repo, branch, deploy_filepath, image_url, git_user, git_email, git_password, force_with_lease)
        )

And i'm running it like this (from a makefile)

dagger call update \
        --branch=$branch \
        --git-user=$GIT_USERNAME \
        --repo=http://$GIT-HOST/myapp.git \
        --git-email=${GIT_USERNAME}@git.educates.dev \
        --deploy_filepath=/ \
        --forceWithLease=true \
        --image-url=xxx.xxx \
        --git_password=$GIT_PASSWORD
#

The error i keep getting is :

[~/exercises/app] $ make update
โœ” app: App! 0.6s
โœ˜ App.update(branch: "main", deployFilepath: "/", forceWithLease: true, gitEmail: "educates-cli-w09-s003@git.educates.dev", gitPassword: "IT_PASSWORD", gitUser: "IT_USERNAME", imageUrl: "xxx.xxx", repo: "http://git-educates-cli-w09-s003.192.168.50.243.nip.io/myapp.git"): Void 0.6s
! call function "update": process "/runtime" did not complete successfully: exit code: 1
โ”ƒ โ•ญโ”€ Error โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ                                       
โ”ƒ โ”‚ Function execution error: Unable to bind arguments: got an unexpected        โ”‚                                       
โ”ƒ โ”‚ keyword argument 'repo'                                                      โ”‚                                       
โ”ƒ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ                                       

Error: response from query: input: app.update resolve: call function "update": process "/runtime" did not complete successfully: exit code: 1

Stderr:
โ•ญโ”€ Error โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Function execution error: Unable to bind arguments: got an unexpected        โ”‚
โ”‚ keyword argument 'repo'                                                      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
make: *** [Makefile:5: update] Error 1

So any help is appreciated ๐Ÿ™‚

nocturne chasm
#

Sometimes talking about a problem helps.
In this case, i found the error.
My init script, that prepares my env, did not install the image-updater correctly.
So the errors i was seeing, was due to that.

I got it working, and just testet it, and it works.

So thanks ๐Ÿ™‚

floral abyss
#

Nice!!! Good to know you got it working! Let me know if the module is lacking in any way! We started with something super simple that worked for our case, we can always adapt it ๐Ÿ‘