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

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
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
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
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
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement