wmnnd

wmnnd

The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries from Distillery Releases?

After all, Releases already bundle all Elixir/Erlang dependencies, so they seem like an ideal starting point.

I suppose, one could come up with an elaborate solution that would implement a custom boot process for the BEAM VM and somehow load all required BEAM files into it.
But why not create a “dumb” binary that is bundled with the release data (think self-extracting archive). It could dump its contents into a temporary folder and runs the app from there. A slightly more elaborate approach would be to use a user-space filesystem (FUSE on Linux) like AppImage does.

Combined with adequate compression, this could produce binaries of around 10 MB.

What do you think?

Showing Posts 1 to 10

NobbZ

NobbZ

As far as I know, it is already possible to create self-contained releases. They contain the runtime as well as erlang itself and therefore do not need anything installed if they are pure BEAM.

If they use NIFs they need the libraries installed.

If they open other programs, the other programs need to be installed.

Since the erlang runtime alone is already huge, I do not think this would make any sense to drive any further.

wmnnd

wmnnd OP

Of course can can create Releases that include ERTS, but you can’t put them in a single executable binary, can you?

I disagree. A compressed Elixir release including ERTS can be around 10 MB; looking at some CLI tools written in Go, they are definitely smaller (compressed at ~6 MB), but not by orders of magnitude

michalmuskala

michalmuskala

Yes, I believe this to be doable. With some changes to erts itself, it’s probably doable to just compile into a single binary and embed the modules inside of it - it already embeds the code for the “core” modules like erlang or init, etc. The primary reason why this is not happening is probably just because nobody did it yet.

OvermindDL1

OvermindDL1

I remember an erlang fork/tool thing way way back in the day that packaged everything up in a tar file that the erlang executable could ‘run’, no doubt you could pack those together too (this was why using the priv_dir call was important instead of hardcoding the path!).

sribe

sribe

There is currently no tool that will package an entire Erlang app & ERTS runtime into a single executable. Within the past 6 months there was a pretty extensive discussion on the Erlang mailing list about doing this: totally doable, probably not quite as easy as some might expect, just hasn’t been enough demand for it.

ODL: the only thing I know of packed up all the erlang BEAM files and a bit of code to run them, but not ERTS–are you thinking of something different that also packed ERTS into it?

wmnnd

wmnnd OP

Here is the most primitive version of a static “binary” I could come up with: A shell script that extracts its contents to tmpfs. I present to you:
A fully self-contained Elixir app with just 11.8 MB: => clock.sh

It’s compiled on a recent Ubuntu, so if you’re running any recent Linux distribution, it should work.

You can run it like this:

chmod +x clock.sh
./clock.sh

… and you’ll get the normal Distillery prompt. If you want to start the application, do ./clock.sh foreground
Here is the wrapper script: elixir-simple-dist.sh · GitHub

NobbZ

NobbZ

I accept this challenge and will try to run it in a naked chroot later the day.

OvermindDL1

OvermindDL1

It packed ERTS as well, and it was a definite hack but it ‘worked’. Mind that this was back in like 2001 or so…

shanesveller

shanesveller

Not exactly what OP is asking about, but for any passerby who want to glance at something they could already use today, Distillery supports self-extracting archives including a variant that cleans up after itself. I don’t believe the latter reaches for a tmpfs like @wmnnd has above, though.

https://hexdocs.pm/distillery/Mix.Tasks.Release.html#module-examples

Build an executable release

mix release --executable

Build an executable release which will cleanup after itself after it runs

mix release --executable --transient

NobbZ

NobbZ

Its a pity, but I have to postpone.

I just realised that I’m totally low on diskspace and I have to figure what can get deleted before doing anything else…

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91898 914
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews