soup

soup

Any reason to use mix release/distillery with Docker, over mix phx.server?

As I understand it, mix release gives me:

  • a transportable release package (at least among the same OS).
  • the ability to hot-reload production releases.

Is there any advantage to using it compared to MIX_ENV=prod mix phx.server, if you’re deploying with Docker?

Why would I want to combine both?

Docker:

  • already gives you a (even more?) transportable package, and you’re stuffing the release inside this anyway.
  • can’t really support hot-reloading in a container (at least, not in a way that doesn’t throw out why you’re using docker in the first place).

I guess it maybe protects you from having code changed in the image, recompiled and executed, either nefariously or by accident?

I assume there isn’t any real performance difference, outside of maybe a fractionally faster initial load (because it’s already compiled into beam code?)

I could understand “it gives me a nice clean directory structure and feels nice” as being reason enough, or maybe “it lets me be prepared for non-docker deploys if I ever want to”?

Most Liked

dom

dom

The doc covers it well: Why releases?

I really like being able to attach iex to the running app and use tools like recon or observer_cli, personally.

soup

soup

Yeah I missed the mix docs :anguished: , actually this is probably the biggest thing:

Self-contained. A release does not require the source code to be included in your production artifacts. All of the code is precompiled and packaged. Releases do not even require Erlang or Elixir in your servers, as it includes the Erlang VM and its runtime by default. Furthermore, both Erlang and Elixir standard libraries are stripped to bring only the parts you are actually using.

Meaning your docker image can be even slimmer. Explains why some of the guides I was looking at use a “non-elixir” image after the build stage.

evadne

evadne

Hi

If you run containerised systems, you do not hot load. Instead you spin up new containers and switch traffic over. Hot loading is for hosts that must stay up without moving traffic but nowadays that is usually the role of the load balancer.

Releases can still be hot loaded if built with Distillery AFAIK. But it is not easy. https://hexdocs.pm/distillery/upgrades-and-downgrades

One more benefit of releases is that you can have artefacts that are independent from the source. Maybe your source contains C code or some other external stuff that needs to be built. After the release is done you can copy it to another machine without bringing the C compiler and development headers with you. This minimises the exposed surface.

Lastly remember to run Docker containers, the images must be loaded to hosts and a smaller image will load faster. This means a rolling deployment that uses a smaller image completes quicker.

Currently I use a slim Debian image as the baseline, install Erlang from either ESL packages or GitHub, and Elixir from either source or precompiled archives from GitHub. Therefore the same Dockerfile can be configured to either build the system based on a stable set of runtimes or the latest versions of everything.

Where Next?

Popular in Discussions Top

Jayshua
I recently came across the javascript library htmx. It reminded me a lot of liveview so I thought the community here might be interested....
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
Qqwy
I would like to spark a discussion about the static access operator: .. For whom does not know: it is used in Elixir to access fields of...
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
Owens
Hello all, I am developing a new mobile app with Flutter frontend and Phoenix backend. The mobile app has real-time task management and c...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Other popular topics Top

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
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
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
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127089 1222
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement