Virtualization for Phoenix

Hello,

I’m learning Phoenix, and after a few failed projects, I realize the importance of virtualization and version control.

So, right now I’m using Docker with this project:

But, I don’t feel comfortable using it, it has some issues. The question is which way to go next, if I take the time to solve those problems or if there’s another way ?

For version control I’m using " git " .

Which is the best solution for development ? Or, which is the best way (the right image) for Docker with Phoenix.

Thanks!

I really like using Releases (now in core Elixir) with docker-compose. I think it’s generally the easiest way to deploy any application in a single-server scenario :slight_smile:

So my recommendation is to first set up Releases for your app and then dockerize them.

I’ve blogged about it here: https://medium.com/@pentacent/getting-started-with-elixir-docker-982e2a16213c

1 Like

Docker is not virtualisation

I cannot express that more. Containerisation (creating separate process namespaces within one system) is not the same as virtualisation (abstracting hardware for running different OS).


As for me, the Docker and containers aren’t really needed that much in Erlang/Elixir deployments. You can achieve simpler and easier to manage deployment via UNIX VMs (Linux/BDS, doesn’t really matter) with proper usage of init system (runit, OpenRC, systemd, SysV, launchd, whatever). Just build release using mix release and then run it on target machine using proper init file. If you want to have auto scaling or automatic healing, then use AWS ASG or similar solution from your cloud provider, and it will be much easier, with less indirection and (mostly needless) abstraction. Especially with systemd you can achieve almost all of that with proper set of options.

9 Likes

After fiddling around with Docker for development and various other set ups I have personally settled on using asdf-vm for pretty much everything. For the majority of projects that’s good enough. It’s got plugins for node, erlang, elixir, postgresql and many other dev tools or databases.

The way you use it is you get the asdf-vm set up, and the plugins you will need, then you crate .tool-versions file like this one:

elixir 1.10.0
erlang 22.2
nodejs 12.13.1
postgres 11.3
redis 5.0.7

and you run one command: asdf install that gets the above dependencies installed. Whenever you enter the project directory with .tool-versions file like that, the above versions of tools are being picked up by some help of shell shenanigans.

For more complicated projects you may need Docker with something like docker-compose, but for 90% of my work asdf-vm is enough.

4 Likes

As for me, the Docker and containers aren’t really needed that much in Erlang/Elixir deployments. You can achieve simpler and easier to manage deployment via UNIX VMs (Linux/BDS, doesn’t really matter) with proper usage of init system (runit, OpenRC, systemd, SysV, launchd, whatever). Just build release using mix release and then run it on target machine using proper init file. If you want to have auto scaling or automatic healing, then use AWS ASG or similar solution from your cloud provider, and it will be much easier, with less indirection and (mostly needless) abstraction. Especially with systemd you can achieve almost all of that with proper set of options.

Whenever I see this kind of feedback (“You won’t need docker for Elixir - use release”) - then I’d say it shouldn’t matter.

Elixir release is a way to run an instance of your application. It’s built-in and easy to use, I agree, but it’s orthogonal how to actually deploy the application. Whether it runs right on bare-metal, VMs, or inside container… it’s just at the different level.

I believe the “container-native” gives a set of pretty good challenges even not within container world - such as removing root user permissions and privileged ports, avoiding using extra process (epmd…), etc. (I’m not saying the current container way is the right solution)

Honestly, if there is at least one app not in Elixir, different questions should be asked: why should I run a release directly on vm? Do I really need it? :slight_smile:

My team is using Elixir in k8s, and some apps using libcluster to make erlang clusters between containers in k8s.


For original author @mauric

You don’t need to use Docker for local dev. Start with asdf.

You don’t need to use Docker for deployment. If you want, then as @wmnnd said, get familiar with release first and then dockerize it.

  1. Learn how to build and run the app, from fresh code checkout at local dev (Elixir specific)
  2. Learn how to use mix release at local dev (Elixir specific)
  3. Learn how to reproduce the steps in Docker (Docker specific)

Note that even you don’t use docker, you should use mix release anyway (the first two steps)

2 Likes

8 posts were split to a new topic: Off topic posts from Virtualization with Phoenix

But I don’t think anyone was suggesting Kubernetes. Now that would be overkill for most applications :slight_smile:

1 Like

Especially for development, as the original question concerns around local set up

2 Likes