Reading env variables with custom app
-
wrote on Feb 22, 2024, 6:39 PM last edited by girish Feb 23, 2024, 9:25 AM
I am trying to install a custom app written in Phoenix Elixir.
My dockerfile ends with that:
ADD start.sh /app/start.sh RUN chmod +x /app/start.sh CMD [ "/app/start.sh" ]
Earlier, I set my environment variables like that:
ENV SECRET_KEY_BASE=default
Here is my startup script:
#!/bin/bash set -eu # Load environment variables source ./env.list # Start PROGRAM exec ./_build/prod/rel/PROGRAM/bin/PROGRAM start
But the environment variables don't seem to be read properly, so the app doesn't start in Cloudron. What am I doing wrong?
-
wrote on Feb 22, 2024, 7:27 PM last edited by
are they set in env.list ?
-
wrote on Feb 22, 2024, 8:08 PM last edited by
Yes, in this format:
SECRET_KEY_BASE=KEYI learned now that I can run them via Cloudron CLI using cloudron set env, but I wonder if it was still possible to do that automatically.
-
wrote on Feb 22, 2024, 8:27 PM last edited by
what if you included them as part of the exec?
-
wrote on Feb 23, 2024, 2:42 AM last edited by
Do you mean to put the exact keys into the dockerfile? I tried that with ENV SECRET_KEY_BASE=KEY, but it didn't work.
-
wrote on Feb 23, 2024, 2:44 AM last edited by
No, that's a different part of the build/install process.
The envs need to be available as you launch the app.
-
wrote on Feb 23, 2024, 3:20 AM last edited by
How would this look like then?
-
wrote on Feb 23, 2024, 3:39 AM last edited by
First, I'd define them explicitly in the startup script, to see if the exec can see them then.
So instead of source .env , export ENV=KEY
-
wrote on Feb 23, 2024, 4:00 AM last edited by
Yes, that works, thank you!
-
-