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. ![]()
Most Liked
LostKobrakai
If you’re using docker anyways, why not use a docker image matching your target server to build the release?
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
Popular in Questions
Other popular topics
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
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









