Module attribute @some_token gets resolved during the compile time. So once the release is built - it will not refetch the value from the System env variables.
Essentially you want to have a function in the module:
defp some_token do
System.get_env("SOME_TOKEN") || raise "Missing SOME_TOKEN"
end
And then in the module instead of @some_token use some_token()
That will call System.get_env/2 on every call of some_token() just like when you tried in iex.
This approach is better, at least because now it will fetch env variable from the system only once on app start and then store it internally. (no need to fetch the system on every function call)
Many reasons why this might fail - first question would be, are you sure you are compiling this app on the same server environment?
Second thought would be to not rely on ENV vars, but Application vars and set the vars in a secret production file, only available on the compiling server, and on the production servers.