graalvm

Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to https://github.com/clj-easy/graal-docs and https://github.com/BrunoBonacci/graalvm-clojure. GraalVM slack: https://www.graalvm.org/slack-invitation/.
Matsu 2021-04-26T12:45:30.127900Z

I can't seem to be able to access env variables with (System/getenv "foobar") when running a native image. Is there some hoops I gotta jump through to make it work?

borkdude 2021-04-26T12:46:21.128500Z

@matias287 you need to defer getting those environment variables to runtime, so wrap it in a function or a delay

Matsu 2021-04-26T12:48:03.129700Z

So instead of (def ACCESS_TOKEN (System/getenv "foo")) I should do (defn [] get_access_token (System/getenv "foo")) ?

borkdude 2021-04-26T12:48:08.129900Z

yes

Matsu 2021-04-26T12:48:14.130100Z

Cheers. I'll try that

borkdude 2021-04-26T12:48:25.130400Z

else you will get to see the compile time environment variables

Matsu 2021-04-26T12:48:51.130900Z

What if I provide the env variable in compile time already?

Matsu 2021-04-26T12:48:58.131200Z

Would that fix it?

borkdude 2021-04-26T12:48:59.131300Z

then that should work

Matsu 2021-04-26T12:49:34.132200Z

I have 2 different docker containers doing the code => jar and jar => native image tasks. Which one would I need to expose it to?

borkdude 2021-04-26T12:49:43.132500Z

but this is possibly a security issue if you distribute those binaries to people you don't trust

borkdude 2021-04-26T12:49:51.132700Z

the native image one

Matsu 2021-04-26T12:50:10.133100Z

Yeah the current use case is just that I build the image, and push it to aws lambda

Matsu 2021-04-26T12:50:15.133300Z

So no one will be touching them directly

borkdude 2021-04-26T12:50:31.133700Z

also you don't have any way to refresh the token without re-building your native image

Matsu 2021-04-26T12:50:39.133900Z

Oh that's true

Matsu 2021-04-26T12:50:43.134100Z

Maybe I'll wrap it then