#What is retrieves?
1 messages ยท Page 1 of 1 (latest)
Thanks Marco. So, I have a working simple build function for a container in TS.
@func()
async build(src: Directory): Promise<Container> {
const ref = dag
.container()
.withDirectory("/path/to/dockerfile", src)
.withWorkdir("path/to/dockerfile")
.directory("path/to/dockerfile")
.dockerBuild()
return ref
}
And it seems to work.
However, the different withDirs and directory methods confuse me. ๐
If I change the paths to anything else, the build fails either with Dockerfile can't be found or a with more exotic lsat error and I'm uncertain what this works and other paths don't.
@bright hare since you're already passing a directory in the function argument that contains a dockerfile, you only need to do src.Directory("/path/to/dockerfile").dockerBuild() and that should be it
no need to create a dag.Container and add a directory since you already have a reference to the directory with the underlying Dockerifle somewhere ๐
๐คฆ๐ปโโ๏ธ I knew I was doing something stupid. ๐
Actually, src.dockerBuild() works too.
So,
@func()
async build(src: Directory): Promise<Container> {
const ref = src
.dockerBuild()
return ref
}
I still feel like I'm totally missing some common thread or concept or even paradigm shift to understanding how to use Dagger properly. ๐ค
this works as long as the Dockerifle is located at the top most directory in the src argument
if the Dockerfile is at some other level, you'd have to change the function call
Ok. Got it. To call the CLI, does the current working directly always have to be where the dagger.json file is located?
not necessarily. You can do dagger call -m $path/to/dagger.json and that works also
as long as the dagger.json eiher in a subfolder, or part of the same git project of your code
Thanks Marco. I think I'm getting it slowly but surely. ๐
sure, np! happy to answer any other question you might have!
@sturdy crane - Should I start a new question in #general or a thread in #1030538312508776540?
Or, can I just continue here?
a new thread would be the best even if it's a simple quieston as it helps keeping things organized
Btw, I got that code I posted from the Dagger Cook Book. So, is that recipe incorrect?
Yes, we should update that. cc @neon onyx
fixed @bright hare https://github.com/dagger/dagger/pull/9446#event-16067542393
will be published soon ๐