coen.bakker
Recommended way to set env variables when using Ueberauth in development?
I am currently using Ueberauth to allow users to use third-parties to authenticate themselves. I can make the *_CLIENT_ID and *_CLIENT_SECRET available in my dev/test env with, for example:
export GOOGE_CLIENT_ID = "..."
export GOOGLE_CLIENT_ID = "..."
But how can I prevent having to export the variables with each new shell session?
Maybe I have taken a wrong approach to setting the env variables altogether? What is the recommended way to make them available to a dev/test environment?
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 10 of 27 Posts
coen.bakker
Is it common to add a shell script somewhere? I see that Fly.io generated an
env.sh.eexto export some variables. Should I do the same? Not sure how to run that before each compile, however…sodapopcan
For development, the answer is probably to use direnv.
Personally, I just make myself a shell script in the root directory that I call
devthat has the following as a bare minimum.Then just
./devto start the dev server.For production is dependent on how you deploy, of course.
coen.bakker
This is great. Thank you.
For production I use Fly.io. You can set “secrets” with their cli and on their website.
D4no0
Or you can create an additional config file that you will add to gitignore and import from
dev.exsortest.exs.coen.bakker
Is that was dev.secrets.exs was/is?
D4no0
I mean there is no convention, but yeah, I’ve seen this used in a few projects.
coen.bakker
I’ve seen it around also.
I got the impression that it used to be generated in Phoenix apps in a previous version of the phx generator. See for example here: https://stackoverflow.com/q/68239156.
But thanks again.
pdgonzalez872
My 2c: I tent to prefer explicitness for env vars, rather than having things magically get loaded. I’ve seen and used this mechanism before:
direnvworks well, but assumes folks have it set up (most do). The above is more explicit in my opinion. I don’t mind the verbosity, mostly due to me rarely having to type that out (always on a readme or in a shell history somewhere).When working with others, there is usually something on the readme that will help (including yourself when you forget
) As far as the mechanics:
.env.examplethat is committed to the repo (example).envfile in.gitignore(example).envfile in the readme (example)If you don’t have a lot of env vars, I’d start with
SOME_VAR=your_var mix phx.serverand build from that. Then, consider the above if that sounds interesting.sodapopcan
I don’t know why I never thought of this—it seems so obvious, lol.
The dev script still comes in handy, at least for one project, where I need to start up multiple nodes. Of course, Docker is probably the “real” answer there, but I’m stubborn. Maybe there is another way? Though this is getting a little off topic of purely ENV vars.
arcanemachine
I use (and love)
direnv, but for working with others, I find that dotenvy is a good solution with less friction thandirenv.It’s another dependency, but it gets rolled in with the others when you run
mix deps.get. Plus it works in all environments, instead of only ones wheredirenvis installed (CI, shared dev boxes, etc.).I’ve encountered the custom
config.exsstrategy mentioned by @D4no0, and I’m not a fan of the concept. Dotenv files are closer to a “universal” configuration system, so that’s a big plus for me. It allows me to share a config system between my Elixir project, my Docker Compose config, etc.