What is the best way to package Elixir CLI application?

Viewed 605

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)

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/

Bakeware generates a single executable file.

They have added a CLI app example here.

Related