rawkode
Preparing for Production
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 ![]()
Most Liked
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:
- In application
startcallback, prior to starting the top-level supervisor, I fetch secrets from wherever. - I merge secrets into proper places in app env (e.g. repo or endpoint config).
- I start the supervision tree.
dantswain
Hi, I’m one of the maintainers of KafkaEx. There’s a lot of good feedback here. I agree that the way worker connections are supervised by default could be better - it’s a piece of the design I inherited with the project. If I understand correctly, that decision was originally made to make it “easy” to start an application and connect to Kafka. I use KafkaEx in production and have had to deal with these complications myself as well.
Unfortunately, we are now in a situation where there are lots of ideas how to make the API better but there are people already using it, so we need to be careful not to break it for them. I’ve considered pushing for an API re-design with a major version change (we are still < 1.0), but we also have several key Kafka features that still need to be implemented that are more urgently needed. We welcome any help we can get!
We do provide the flexibility to disable the default worker and to start workers under your own supervision tree. As was mentioned, however, this is a bit cumbersome and confusion-prone. Anyone who has trouble with KafkaEx is welcome to hop on to the Elixir-lang slack and ask in the #kafkaex channel - we try very hard to be available.
OvermindDL1
It should just not start then, it should supply a supervisor that you would add to your own supervision tree with whatever options you want to give it.
It should not be an ‘application’ type library unless it is truly standalone, otherwise it should be a supervised type library.
Last Post!
rawkode
What I have here, https://github.com/GT8Online/weave, is now working for me in my production system.
It’s still very early, but thanks for all your help.
Popular in Questions
Other popular topics
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
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









