Docker image with Erlang, Elixir, and NodeJS on CentOS for cross-building Elixir/Phoenix apps as OTP releases.
Uses CentOS official base image and official binary
builds of Erlang, Elixir, and NodeJS.
Versions:
- CentOS:
7.6
(x86-64) - same as RHEL 7.6
- Erlang:
22.0.4
- Elixir:
1.9.0
- NodeJS:
10.16.0
Warning: Do not use this image to deploy the app as the size is quite large at ~598MB
Github | Docker Hub
For an example build file that cross-builds a Phoenix app, refer to phoenix/build-release.sh file.
This file should be placed at the root of the Elixir/Phoenix project and:
# Run the build script inside a container running this image
# Note: On Windows replace $(pwd) with the actual path
docker run -v $(pwd):/home --rm -it akalan/elixir-centos /home/build-release.sh
# Run the generated release inside the same container
docker run -v $(pwd):/home --rm -it akalan/elixir-centos /home/_build/prod/rel/appname/bin/appname
The release is tarred and zipped to releases/appname-version-utc_time_stamp.tar.gz
1 Like
Quick feedback
General Docker
- Check the checksum of any downloaded files
- Clean up cache - e.g.
yum update
will create caches, so remove all caches in the same RUN
- probably it explains the size of the image
- Leverage layers to maximize caching
- e.g. changing Elixir version should not invalid layers for erlang
Erlang/Elixir
- Seems like there is no official repo; then you can just easily build it with src from https://github.com/erlang/otp/releases
- Precompiled elixir from github release is compiled for the oldest supported OTP, which means you may not leverage the new OTP features
- compile Elixir with the latest OTP, or
- download precompiled elixir from
https://repo.hex.pm/builds/elixir/v${ELIXIR_VERSION}.zip
(it’s from https://github.com/hexpm/bob )
- erlang 20.0.4 had a bad bug (ERL-986) - so use the latest version (at least 22.0.5)
At work, we use Red Hat Universal Base Image - so I created dockerfile for Erlang and Elixir from ubi7 (Red Hat Universal Base Image 7) - check out https://gitlab.com/chulkilee/docker-images/
2 Likes