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?
Trending in Discussions
Other Trending Topics
Chat & Discussions>Discussions
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #ai
- #iex
- #graphql
- #elixirconf-us
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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
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
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
erlangorinit, etc. The primary reason why this is not happening is probably just because nobody did it yet.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
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
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:
… and you’ll get the normal Distillery prompt. If you want to start the application, do
./clock.sh foregroundHere is the wrapper script: elixir-simple-dist.sh · GitHub
NobbZ
I accept this challenge and will try to run it in a naked chroot later the day.
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
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
tmpfslike @wmnnd has above, though.https://hexdocs.pm/distillery/Mix.Tasks.Release.html#module-examples
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…