#WithEntrypoint situation

1 messages · Page 1 of 1 (latest)

sonic fjord
#

Hello. I'm trying to run WithEntrypoint([]string{"sh", "-c", "eval $(./prgetter && ./app)"} but not with success. Is it possible? I can run it using only shell in my pipelines but not with dagger yet.

The ideia is run this first binary and then the ./app webserver with eval like this.

hushed raptor
#

hey @sonic fjord ! any particular reason to use eval instead of just plain sh -c ""

sonic fjord
#

yeah, for some reason i cannot inject the response who comes from the first binary into my container os as export key=val

#

without eval it "works" i mean my container do not break but the os cannot recognize the environment variables

hushed raptor
#

oh, I see you're exporing shell variables from your first binary?

sonic fjord
#

yes

hushed raptor
# sonic fjord yes

this should work

    client.Container().
        From("alpine").
        WithEntrypoint([]string{"sh", "-c"}).
        WithNewFile("/export.sh", dagger.ContainerWithNewFileOpts{Contents: `#!bin/sh
export hello=world
        `, Permissions: 0755}).
        WithExec([]string{"source export.sh && echo $hello"}).Sync(ctx)
#

that's assuming your prgetter is actually a script

sonic fjord
#

actually it make an api call for aws (parameter store) and get a few key value variables from there

#

usually i can export them only printing

sonic fjord
#

but only with eval

hushed raptor
# sonic fjord but only with eval

this works:

    client.Container().
        From("alpine").
        WithEntrypoint([]string{"sh", "-c"}).
        WithNewFile("/export.sh", dagger.ContainerWithNewFileOpts{Contents: `#!bin/sh
echo foo=barbar`, Permissions: 0755}).
        WithExec([]string{"eval \"$(\"/export.sh\")\" && echo $foo"}).Sync(ctx)
sonic fjord
#

man, really appreciate that.
my container is a bit different but i use this escape characters shenanigans in my WithEntrypoint and it did work pretty well

#

WithEntrypoint([]string{"sh", "-c", "eval "$("./prgetter")" && ./app"}).

#

i couldn't use this with exec in the end because i'm trying to publish the image after. I suppose it get stucked in terminal because of the webserver

hushed raptor
sonic fjord
#

and then break in the publish

hushed raptor
#

that's great. Happy hacking and we're around if you need us! 💪