#How to pass context to the build method
1 messages · Page 1 of 1 (latest)
@rugged portal seems to be a string? Looks to me that seems to be the path that you want your docker build to run from (https://docs.dagger.io/current/sdk/nodejs/reference/classes/api_client_gen.Container#build)
Similarly to docker build <context>
I just checked the code and seems like it needs a DirectoryID basically (https://github.com/dagger/dagger/blob/3642f7fb8f03df3b403652f8454adfebad57bf5a/sdk/nodejs/api/client.gen.ts#L131)
so you can do something like this
// get reference to the local project
const source = await client.host().directory(".", ["node_modules/"]).id();
// build Dockerfile
const build = await client
.container().build(source.id).exitCode()
console.log(build)
that will basically look for a Dockerfile in the directory where you're running your script and build it
Hi @rugged portal 👋 ! Did you manage to sort this out ? Thanks