Fork me on GitHub
#graalvm
<
2021-04-26
>
Matsu12:04:30

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?

borkdude12:04:21

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

Matsu12:04:03

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

Matsu12:04:14

Cheers. I'll try that

borkdude12:04:25

else you will get to see the compile time environment variables

Matsu12:04:51

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

Matsu12:04:58

Would that fix it?

borkdude12:04:59

then that should work

Matsu12:04:34

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

borkdude12:04:43

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

borkdude12:04:51

the native image one

Matsu12:04:10

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

Matsu12:04:15

So no one will be touching them directly

borkdude12:04:31

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

Matsu12:04:39

Oh that's true

Matsu12:04:43

Maybe I'll wrap it then