#WithEntrypoint situation
1 messages · Page 1 of 1 (latest)
hey @sonic fjord ! any particular reason to use eval instead of just plain sh -c ""
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
oh, I see you're exporing shell variables from your first binary?
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
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
👍
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)
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
sure, happy to help. Glad you managed to make it work.
and then break in the publish
yes, that'd make sense
that's great. Happy hacking and we're around if you need us! 💪