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
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
Other Trending Topics
A new screencast on live LiveView updates with PubSub, the Oban Web dashboard, and smarter retries. Part 2 of 2. Screencast + full walkth...
New
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










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).