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.

egze

egze

There are also Overlays for mix release. Maybe it can also help.

https://hexdocs.pm/mix/Mix.Tasks.Release.html#module-overlays

Where Next?

Popular in Questions Top

Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
gazoon
I want to know absolute current module path. In python i could do that: os.path.abspath(__file__) Does elixir have anything similar?
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
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
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

We're in Beta

About us Mission Statement