Oliver

Oliver

How to use preinstalled Erlang on target with releases?

So, I have an elixir application that originally came bundled with its own ERTS (in a release) to be run on a specific server.

The original setup was:

  • build server: Docker image in CI, elixir 1.14.4, OTP 25.3 (x86_x64 architecture, Rocky Linux)
  • included ERTS: Built without some libs (like ncurses not present on target server), but same OTP 25.3
  • target server: it is deployed also on a x86_64 architecture but is Ubuntu LTS

This all worked fine until one day the Docker image (which is used by all our build activities, not just the ones related to elixir) started using GLIBC 2.34 and the target server it is deployed to remained at 2.31. Now the ERTS when deployed could no longer find a compatible GLIBC and our release could no longer be started.

So I wanted to solve this by installing Erlang on the target server and no longer bundling ERTS with the release.
include_erts: false,

We verified that Erlang 25.3.2.2 was installed on target server under /lib/erlang, playing around with the erl shell. It seemed to work fine.

But when we unpack the release and do bin/name_of_release start we get this:

{"init terminating in do_boot",{load_failed,[logger_simple_h,supervisor,proc_lib,lists,logger_backend,logger,logger_server,kernel,filename,gen_server,gen,file_server,erl_parse,file_io_server,file,ets,erl_lint,logger_config,erl_eval,application,code_server,code,application_controller,error_handler,heart,logger_filters,gen_event,error_logger,application_master]}}

Basically the whole Erlang libs are missing. It can find erl from PATH just fine, but somehow none of the required OTP.

I tried supplying OTPROOT and ERL_LIBS on the command line while running the script, but to no avail.

It’s built for V13.2 (on Docker) and on target it has V13.2.2.5, same CPU architecture.

Any ideas what’s going on?

Thank you. :slightly_smiling_face:

Most Liked

LostKobrakai

LostKobrakai

If you’re using docker anyways, why not use a docker image matching your target server to build the release?

Oliver

Oliver

This is the solution my coworker Slawomir Skrzyniarz came up with. It bundles the needed dynamic libraries and patches the executables of the ERTS accordingly to use them. (We’re compiling and deploying on the same architecture, after all.)

We then simply bundle that up in a tarball at the end and unpack it in the right directory on deployment target.

# the base directory here is the path of the release
# as passed to us when registering a function under
# :releases and :steps
mkdir -p lib64
cp -v \
        /usr/lib64/ld-linux-x86-64.so.2 \
        /usr/lib64/libBrokenLocale.so.1 \
        /usr/lib64/libSegFault.so \
        /usr/lib64/libanl.so.1 \
        /usr/lib64/libc.so.6 \
        /usr/lib64/libc_malloc_debug.so.0 \
        /usr/lib64/libdl.so.2 \
        /usr/lib64/libm.so.6 \
        /usr/lib64/libmvec.so.1 \
        /usr/lib64/libnss_compat.so.2 \
        /usr/lib64/libnss_dns.so.2 \
        /usr/lib64/libnss_files.so.2 \
        /usr/lib64/libpthread.so.0 \
        /usr/lib64/libresolv.so.2 \
        /usr/lib64/librt.so.1 \
        /usr/lib64/libthread_db.so.1 \
        /usr/lib64/libtinfo.so.6 \
        /usr/lib64/libutil.so.1 \
        /usr/lib64/libz.so.1 \
        /usr/lib64/libsctp.so.1 \
        /usr/local/gcc-12.2.0/lib64/libgcc_s.so.1 \
        /usr/local/gcc-12.2.0/lib64/libstdc++.so.6 \
        lib64
find bin/ erts-13.2/ -type f -executable -exec patchelf --set-interpreter <absolute installation path on deployment target>/lib64/ld-linux-x86-64.so.2 {} \\; 2>/dev/null
find bin/ erts-13.2/ -type f -executable -exec patchelf --set-rpath <absolute installation path on deployment target>/lib64 {} \\; 2>/dev/null

Where Next?

Popular in Questions Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement