#I'm evaluating moving our pipelines to

1 messages · Page 1 of 1 (latest)

undone magnet
#

Its identical to what you are used to with docker build because it uses the exact same engine under the hood (build kit)

I think one very nice way to see what is going on is to pass a Dockerfile into dagger and see what happens.

Dagger supports Dockerfile out of the box: https://archive.docs.dagger.io/0.9/cookbook#build-image-from-dockerfile

(note these are the "old" docs, things should work more or less the same with Dagger functions but we need to update the docs to include this behavior, its a high priority and a WIP right now)

Filesystem

worn wolf
#

I will read those sir, thank you for the help

undone magnet
#

My pleasure!

worn wolf
#

Using dagger 0.10.1 I shold be able to do ´dag.host().file(filename)´ or ´dag.host().directory(".").file(filename)´, corect? I´m using python sdk

#

I´m getting Function execution error: ´Client´ object has no attribute ´host´

#

Sorry about the thread here instead of help, I will dig more, I feel Iºm letting something pass

undone magnet
#

Yeah sorry things are a bit different in 0.10.1, no worries about here or help its all good 🙂

Which SDK are you using?

worn wolf
#

python

undone magnet
#

The main difference with the new functions approach is you must pass in the directory as a part of the function call, this means you will need to accept that as an argument and then reference it from within your function.

Here is a simple example based on setting up a new module using dagger init

    @function 
    def build(self, dir: dagger.Directory) -> dagger.Container:
        """
        Multi Stage Python Build
        """
        # build app 
        builder = (
            dag.container().from_("golang:latest")
            .with_directory("/src", dir)
            .with_workdir("/src")
            .with_env_variable("CGO_ENABLED", "0")
            .with_exec(["go", "build", "-o", "myapp"])
        )

        # publish binary on alpine base 
        prod = (
            dag.container()
            .from_("alpine")
            .with_file("/bin/myapp", builder.file("/src/myapp"))
            .with_entrypoint(["/bin/myapp"])
        )

        return prod 

That functions accepts a directory, does a multi stage build, and returns the final container.

worn wolf
#
    @function 
    def build(self, dir: dagger.Directory) -> dagger.Container:
        """
        Multi Stage Python Build
        """

        local_dir = dir
        poetry_lock = local_dir.file("poetry.lock")
        pyproject = local_dir.file("pyptoject.toml")

        pysetup_path = "/opt/pysetup"

        # build app 
        builder = (
            dag.container().from_("golang:latest")
            .with_files(pysetup_path, [poetry_lock, pyproject])
            .with_workdir("/opt")
        )

The files are been stored in /opt/opt/pysetup.

withFiles doesn't seems to respect absolute path for source arg.

molten reef
#

Good find! Do you mind creating an issue?

worn wolf
#

Yeah, sure.

I'm running the codes in my work environment, later on I will create on my personal one and provide more information

molten reef