BarelyFunctional

BarelyFunctional

Best way to deploy from Mac to Digital Ocean Droplet?

It appears edeliver and distillery are the preferred way to do deployments, but my understanding is that the production server OS has to be the same as the dev environment OS. Is that right?

I want to deploy to a freebsd droplet on digitalocean from my mac.

Is there a preferred way to do this without using docker (I’m not a fan of it)?

Most Liked

bitwalker

bitwalker

Leader

I’m not sure I agree that it’s an impediment - Erlang/Elixir are similar to any other language where you may have native dependencies which need to be compiled on the target architecture/OS, golang is a great example of a language where it’s super easy to deploy generally, but you still need to cross compile, and if you have native dependencies, you have to do some extra work to setup a build environment to automate deployments. Using something like Docker just for builds can save you an awful lot of pain, and has the benefit that it can be entirely automated. Vagrant is another option, and is very widely used for that reason (as well as others), but I tend to avoid it because it’s so much heavier than Docker for just doing builds.

If you are not consuming any native dependencies, things are easier, just don’t include ERTS and as long as your target machine has the same version of Erlang, you are good to go. You can go a step further and do a one-time export of an ERTS compiled on your target (or in a matching Docker/Vagrant setup), and then just configure Distillery to include that ERTS instead of your build machine’s ERTS. It’s extra up front effort, but can save you a ton of time if you are deploying without a build server or some kind of automation in the mix.

However if you do depend on native dependencies, and it’s very common to have at least one NIF floating around (in my experience) - then you are back to doing your builds on a dedicated server or in a container/VM which matches the production environment. In my opinion, tackling this upfront is the way to go, because you can change your application drastically but keep your deployment setup more or less the same the whole time. It’s much easier to automate as well, and tools like edeliver can take most of the work out of the automation bit.

I think the reason nobody has created the “end all be all” tool to abstract away all the Docker bits is simply that due to the nature of most applications, you will have native dependencies which dynamically link against specific system libraries which your build/prod machine must have installed - so then whatever is building your release needs to have those things too, not to mention you are probably targeting a specific OS and version of that OS - it’s just plain easier to throw the bits together yourself. As an example of what I mean, I threw this together awhile back as an example of how to automate the creation of Docker images containing just a release (it builds the release in a “dev” container with all the bells and whistles, and then passes it into a “prod” container with only the bare necessities). It’s similar to what I put together for our projects at work, and it relies on nothing more than the shell, make, and Docker. You could tweak it to just build the release in Docker and export it so you can manually deploy it, or hook that bit into some other piece of automation you have - the point is that “painless” deployment is going to require some degree of elbow grease up front (IMO). Even environments like Node, Python, Ruby, etc. still have to deal with native dependencies from time to time, and you end up doing more or less the same thing we’re doing here.

There are still improvements to working with releases in Elixir being made, and I know I plan to continue doing so until there isn’t any work left I can do - but I also think that where we are at now is actually really good. Setting up and deploying a project via releases can be done with very minimal effort - the caveat is that you need to understand how to do that, and I think that’s where a lot of work remains to be done. In my experience, the vast majority of problems people have when transitioning to releases is due to thinking they can add Distillery to their deps, run mix release and be done with it - it’s not much more complicated than that, but it’s not that easy. I unfortunately haven’t been able to do a good enough job with either documentation or UX of the tooling to help guide people down the “happy path”, but it’s absolutely an area I would love help with.

wmnnd

wmnnd

The target os doesn’t necessarily have to be the same as the one in your dev environment.

While Distillery does include your system’s Erlang binaries in the release by default, you can also tell it not to include them or include an ERTS of a different architecture/binary type instead.
If you don’t include ERTS, you simply need Erlang on the target system.

Check out Distillery’s Walkthrough guide for more details on this:
https://hexdocs.pm/distillery/walkthrough.html#deploying-your-release

outlog

outlog

look at A Beginner's Guide To Deployment with Edeliver and Distillery - it’s on ubuntu, so minor adjustments might be needed…

BrightEyesDavid

BrightEyesDavid

Having Erlang installed on the server and using releases without ERTS is the approach I’m now taking as I didn’t want to have to worry about which OS/version I build releases in, even though I’m usually on Linux. (I’m also not keen on using Docker when I don’t have to.)

I used asdf to install Erlang on the server, and as I’m using systemd I found I had to add asdf’s shims directory to $PATH in the app’s service/unit file:

ExecStart=/bin/bash -c 'PATH=/home/appuser/.asdf/shims:$PATH exec /home/appuser/app/bin/my_app start'

BarelyFunctional

BarelyFunctional

Thanks, this is the approach I was thinking of although it’s meant to be less secure as it opens up use of erlang on the server if it’s compromised, but I think there are benefits to having it installed too, and it must be possible to lock its useage down.

I could easily be wrong, but until developing and releasing from a mac is easy, sans docker, I think releasing will remain an impediment to the growth of elixir/phoenix, simply because so many developers use macs.

But the same can be said for developing on windows and releasing to a linux/unix server on DO or whatever cloud - it has to be easier for elixir/phoenix to go mainstream without use of docker.

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
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
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
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

aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
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
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement