vschroeder

vschroeder

Recommended directory to save other files

Hello there, I tried to find an answer for this question but couldn’t find it anywhere, so here it goes!

We have a project composed by some docker images, one of them containing an Elixir application inside. During development, Mix and all the test tooling is made available for the developer. In production, a minimal image is deployed containing just the release (BTW, releases are a killer feature of Elixir/Erlang, I love it!)

Now we have dependency on a file (which happens to be a certificate) that has to be mounted during development (the certificate gets always rotated, for testing purposes) and has to made available to the release in production, either shipped with the container image or mounted by another mechanism at a known and predefined (or configurable) location.

So, the question: is there any recommended way to make this kind of static file-based asset available to the Elixir (or Erlang) runtime? Where should static assets be placed? I’m aware that I can put it pretty much anywhere I want, but is there any good practice to be followed, among the other directories like lib, deps, etc?

Thanks in advance!

Most Liked

Nicd

Nicd

Yep use priv, it’s built into the release by default. Then you can use :code.priv_dir(:your_app) or Application.app_dir(:your_app, "priv") to get its path, which will work in both development and release. Of course, it won’t help if you want your file to be placed after you build the release (in which case you could place it in the directory manually but you could put it anywhere else in the filesystem too and it’s up to you).

ityonemo

ityonemo

I typically use priv/assets. Erlang comes with :application.priv_dir/1 I think? (I’m on my phone so can’t check) which will accurately track it through releases.

vschroeder

vschroeder

Thanks for all the suggestions. This was waaaay more useful than I was expecting! Both solutions (priv directory and release Overlays) sound really solid. I’ll try them both and follow up this thread with what worked the best.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New

We're in Beta

About us Mission Statement