rawkode
Hey all,
I’m reaching the point of deploying our application to production machines and I’m looking at how I inject secrets into my application.
1st: I see there’s {:system} syntax, but it’s use is scattered.
What’s the best way to inject variables to a build?
2nd: I’m using Docker Swarm, so secrets are provided through files: /run/secret/database_password
At the moment, I’m using a fork (File Loader for Config by rawkode · Pull Request #6 · Nebo15/confex · GitHub). Is there a better way?
Hopefully someone has deployed to Swarm before or has some idea on how best to handle this.
Thanks ![]()
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Other Trending Topics
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
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
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sasajuric
I don’t use Swarm, but your problem seems like a more general case where secrets must be provided when starting the app (as opposed to building the release), and they might need to be derived from various sources, not necessarily OS env. In my cases, I used etcd and custom json files to fetch stuff, so various OS env impros wouldn’t work for me anyway.
The way I deal with this (which doesn’t work for everything, but does for most things, including Phoenix and Ecto), is:
startcallback, prior to starting the top-level supervisor, I fetch secrets from wherever.rawkode
Thanks, @sasajuric. This seems like a good idea.
Would you just leave this blank, or not even defined?
Then in
start, I could doFile.ls |> Enum.each |> merge_configwith a function for each parameter I expect?Useful suggestion, thanks!
sasajuric
I leave these settings undefined. In case you use those settings only in
prod, I suggest defining them indevandtestonly.Well, in
startyou fetch those parameters from wherever they are, and then merge them, yes. AFAIK there’s no “merge env” function, so I do it by reading the top-level setting (sayMyApp.Repo), adding additional info (e.g. password) into it, and putting it back withApplication.put_env.rawkode
Awesome. Thank you very much for your help, it’s appreciated muchly
rawkode
Hi @sasajuric, do you have any examples of doing this? I’ve been trying for a couple of hours now.
get_all_env(app)returns aListof tuples, which is in-turnListofListand I have no idea how to “merge”get_env(app, key)also returns aListand stumps me too.bitwalker
A simple approach:
This will recursively merge two keyword lists, taking the newer value when conflicts occur, except when the value is a keyword list, in which case it merges. This obviously is a bit of an over simplification, but improving it is an exercise left to the reader
sasajuric
Let’s say I want to set a repo password:
If you need to do this for a couple of different top-level settings, its worth making a helper fun which could be used as:
The implementation is left as an exercise
rawkode
Thanks again for everyone’s help! I’m getting close.
My “last” problem, I hope, is that this loading happens after KafkaEx starts, which is now failing due to missing configuration.
So far I’ve got the following:
rawkode
Is it normal for applications to be started before my “primary”?
OvermindDL1
Applications should be loaded in dependent order, so if you depend on it then it will be up before yours. Libraries that are designed to be loaded after yours (should) give you a supervisor to place in to your own supervision tree so you can then do whatever you want to their loading, just like how Phoenix’s Endpoint works.