sen
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
dev.exs
config :myapp, :enable, value: “${enable}”
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
chensan
I don’t remember there’s such thing like
${}in Elixir, you might mean#{}for string interpolation?You can use
System.get_env("enable")to get environment variable in yourdev.exsfile.sen
Hi chensan,
Thanks for help.
seen like this , currently i am keep trying.
http://engineering.avvo.com/articles/using-env-with-elixir-and-docker.html
chensan
That post is using Exrm for building OTP release, that’s why it’s using
${}, also exrm is deprecated now. Since you’re configurating yourdev.exs, there’s no need to use exrm, just useSystem.get_env.pedromvieira
Check out this guide Kubernetes Native Phoenix Apps.
I’ve had to adapt it a little to my umbrella use case but is really good and up to date.
dersar00
Hi, @sen!
For using environment variables you can create a
.envfile anywhere in your project folder, I prefer to create it inproject_name/configfolder, with a content like here:after saving file, source it using
source config/.envfrom project directory, then u can use those variables in your project using commmand:System.get_env("FILE_FOLDER")Good luck!
IMPORTANT: don’t add spaces before and after equal sign.
dimitarvp
I am very strongly interested in a blog post about this, if you decide to write one!
sen
Thanks all.
I am doing like this, when i build and run docker after, can get the value in HomeController test.
But endpoint and route nothing to change, cant get the value.
I want to enable/disable plugin. if true will enable that plugin.
Anyone know the reason? if cant doing like this, i will change other way.
prod.exs
config :myapp, :enable, value: “${ENABLE}”
endpoint.ex
if Application.get_env(:myapp, :enable)[:value] do
disable/enable plugin…
end
Josh
I’m a little confused about the best way to store secrets.
When I looked for a way to automatically load a
.envfile, I found a dotenv package that says “This isn’t the Elixir way.”The tutorial I read said to hard-code the Guardian secret in
config/config.exs, but that doesn’t seem right.I was going to do this, but I’m wondering if it isn’t a good idea because of the message in the README of that dotenv package:
I could manually
source config/.envbefore starting the server, but I’m probably going to forget to do that sometimes.It’s confusing, because
prod.secret.exsalso usesSystem.get_env("DATABASE_URL"). If secrets were meant to be hard-coded there, why would it look for environment variables by default and/or not be excluded automatically in.gitignore?Does anyone know of an automated way to load the
.envfile that still follows “the Elixir way”?Josh
I don’t know if this is the correct solution, but it looks like development keys are meant to be hard-coded into version control, like the default
secret_key_baseinconfig/config.exs? I usually create a.envfor development when using other languages, but after looking through all the config files, it looks like the default setup will override the defaultconfig.exssettings (anddev.exsisn’t loaded) when you’re running in production.(I’m guessing that the tutorial I read probably should have recommended putting the Guardian key in
dev.exsinstead ofconfig.exs.)If I’m mistaken, please let me know.
BrightEyesDavid
@Josh, here’s what I’m doing for now, which I’m happy with so far.
Development
I find text files convenient in dev, and don’t want to have to export env vars every time I run the app locally.
config/dev.secret.exscontains dev secrets that shouldn’t be in version control. (secret_key_basekeys could be moved into this file, but I’ve left mine indev.exsfor now as it’s only for signing and encrypting in dev while testing.).gitignorecontains**/*.secret.exsso that ‘secret’ files are kept out of Git version control.Production
I use Mix releases and use environment variables via systemd, and so keep the
System.get_env(ENV_VAR)calls.Important to note is that there’s a new recommended way of handling run time (as opposed to compile time) config in Elixir >= 1.9: the Config module. The whole page is worth reading, but here’s the upshot:
In Phoenix, rename
prod.secret.exsto the special filenamereleases.exs.Then, the environment variables read in this file are read at run time on the server, and not when building (perhaps locally).