#Can you configure a dagger image in one SDK and then use that image in another?

1 messages · Page 1 of 1 (latest)

balmy matrix
#

Specifically configure in Node and then run via graphql or go.
For example in node I want to do do like:

client.container().from("node:latest").withDirectory(...).withExec(...).withExec(...)

and then I want to output the like base64 configuration that generates and in another process continue building on it or actually run it

#

I am pretty sure this is similar to "environments" in zenith although I am interested in doing this today with what is available

tough birch
#

Yeah, if they share the same session, you can pass the id string.

balmy matrix
#

in the javascript SDK how do I get the ID string?

tough birch
#

It's up to you. You need to save it somewhere in one SDK and open in the other. But you should only do this if they're sharing the same session, not to deserialize at a later time.

#

An example is doing dagger run script.sh where you call the SDKs inside.

pale willow
#

^ this. You need to wrap your pipeline with dagger run so the session is shared across all SDK's

balmy matrix
#

oh yeah I mean is there any way to literally get the ID string using the javascript library right now? like a function that returns it

tough birch
#

Yeah, it's just await container.id().

#
import { connect, Client, ContainerID } from '@dagger.io/dagger'

connect(async (client: Client) => {
    const cid = await client.container().from("alpine").withExec(["echo", "hello"]).id() as string
    console.log(await client.container({id: cid as ContainerID}).stdout())
})
#

Conversion to/from string to demonstrate serialization/deserialization between different SDKs.