distillery, under the hood

Hi
Can anyone explain what does distillery do under the hood? What are the advantages of it?
i couldn’t find much using google.
thanks

Hello there !

I advise you have a look at the official documentation:

I recommend the Getting Started Guide:

Why use distillery?

Distillery is on the base level, a bunch of scripts that encompass the most common tasks people come across when deploying an app. Building releases, support for Umbrella projects and extensive documentation to deploy your app on AWS, GCP or whatever you pick all make distillery a worthwhile investment (don’t forget about support for Docker as well!)

How does it work?

As I said before, it mainly is a bunch of mix tasks that you invoke via CLI. As for your builds, they all end up in the _build folder and are organized by environment and version. A good book on the matter is “Elixir in Action”, which has a chapter devoted to releases in Elixir using distillery, but if you don’t feel like investing too much I recommend the email courses by @zkessin

Make a post and send an e-mail, I am sure he can give you some pointers.

Still, the best source of info I found when it comes on how you can make distillery work, is the configurations section:

https://hexdocs.pm/distillery/config/distillery.html

Hope it helps!

1 Like

I read those but they don’t really answer my questions.
1- Does distillery bundle an instance of beam with your code so that you won’t need to install erlang on the target system?
2- And will you be able to manage your deployment using e.g. systemd?

  1. Yes, yes it does :smiley: That’s the whole point of distillery - not having to install anything on the target machine. You will however have to compile your project in a machine with the same specs as the target machine so the executable can run on it.
  2. As far as I know, there is nothing preventing you from using systemd. You will however need customized scripts for that (such as adding your app to systemd so you can latter on monitor it and so on).
2 Likes
  1. It can, and most people configure that way IME. include_erts is the configuration directive that controls this. You do need to build the release on a system using a compatible kernel and CPU architecture compared to your deployment target, though.

  2. Sure, there’s even some docs for that specifically!

4 Likes

Even if you don’t use my PIDFile library (Distillery/BEAM has built in pid functionality now though I’ve not yet tested to see how it works), that thread has instructions on how to use it with systemd as a proper template service file instead of pre-baked with system-specific values like the systemd distillery docs show. :slight_smile:

2 Likes

Yes, it can. And will by default, but you can also suppress the inclusion if you like (for example if the destination machine already has Erlang and Elixir installed). As you are reading the documentation keep an eye for mentions of the ERTS (Erlang Run-Time System?). That is pretty much just what it says in the name.

Yes. You can set up a systemd service to run your application. Distillery itself doesn’t really have much to do with that process though. You will have to create and install the service definition yourself. Distillery will give you an entry point with the ability to run the application in the Foreground, or as a Daemon depending on how you want to set up the service. IIRC when I did that I set it up to run as a Foreground application which let systemd capture stdout/stderr for logging purposes (as opposed to setting up logging separately). YMMV.

2 Likes

Is there any difference if its a phoenix app? or if there’s going to be connections to nodes on other machines?

Not really. A Phoenix deploy is just an Elixir deploy with certain libraries installed as dependencies.

Connecting to other nodes and machines is largely a question of making sure the right ports are open and that the Erlang system can listen on those ports. I’m afraid I am not familiar enough with systemd to remember if it plays a role in who is allowed to listen on what ports.

Setting up a distillery release does involve identifying the Erlang Node Cookie - the shared secret that is used to determine if outside forces are allowed to mesh with your node though.

2 Likes

So I guess I have some experiments to do.
Thanks guys