Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to package Elixir CLI application?

Suppose I have a CLI application with subcommands and arguments (like application foo --bar baz). How can I package it for distribution without requiring user to install Erlang?

I know there's mix escript Mix task, but it builds a binary that requires Erlang to be installed, also Mix reference states that escripts should be used only for development purposes. mix release, however, produces redundant shell scripts that I don't want to see in dist.

So, is there a way to make a standalone distributable of an Elixir CLI application?

P. S. This is actually my first experience with Elixir (and the whole Erlang ecosystem)

like image 334
k.meinkopf Avatar asked Feb 16 '21 23:02

k.meinkopf


2 Answers

Elixir applications can be packaged as Erlang releases, see also here. These can include Erlang VM. Elixir since 1.9 supports building releases without extra tooling, using included mix task mix release - please check the documentation for greasy details: https://hexdocs.pm/mix/Mix.Tasks.Release.html

You might benefit from a quick look at this blog post for inspiration and conceptual overview, noticing that for simple CLI app it is much simpler: https://www.cogini.com/blog/best-practices-for-deploying-elixir-apps/

like image 57
FooF Avatar answered Sep 28 '22 04:09

FooF


Bakeware generates a single executable file.

They have added a CLI app example here.

like image 21
Abhilash Chelankara Avatar answered Sep 28 '22 06:09

Abhilash Chelankara