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 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New

Other Trending Topics Top

marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews