Skip to content

Instantly share code, notes, and snippets.

@brightball
Last active June 7, 2021 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brightball/32ecb94242cd2ad93033629bea719bce to your computer and use it in GitHub Desktop.
Save brightball/32ecb94242cd2ad93033629bea719bce to your computer and use it in GitHub Desktop.
Erlang Buildpack
#!/bin/bash
# Install a custom Erlang version, https://www.erlang.org/
#
# Add at least the following environment variables to your project configuration
# (otherwise the defaults below will be used).
# * ERLANG_VERSION
#
# Uses https://github.com/elixir-buildpack/heroku-otp/releases
#
# Include in your builds via
# source /dev/stdin <<< "$(curl -sSL https://gist.githubusercontent.com/brightball/32ecb94242cd2ad93033629bea719bce/raw/c677b4f676901ee9b8070ac24f78244782aeea8e/erlang_buildpack.sh)"
ERLANG_VERSION=${ERLANG_VERSION:="18.3"}
ERLANG_PATH=${ERLANG_PATH:=$HOME/erlang}
CACHED_DOWNLOAD="${HOME}/cache/erlang-OTP-${ERLANG_VERSION}.tar.gz"
# no set -e because this file is sourced and with the option set a failing command
# would cause an infrastructur error message on Codeship.
mkdir -p "${ERLANG_PATH}"
ERLANG_PATH=$(realpath "${ERLANG_PATH}")
wget --continue --output-document "${CACHED_DOWNLOAD}" "https://github.com/elixir-buildpack/heroku-otp/releases/download/${ERLANG_VERSION}/OTP-${ERLANG_VERSION}.tar.gz"
tar -xaf "${CACHED_DOWNLOAD}" --strip-components=1 --directory "${ERLANG_PATH}"
"${ERLANG_PATH}/Install" -minimal "${ERLANG_PATH}"
export PATH="${ERLANG_PATH}/bin:${PATH}"
# check the correct version is yused
erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), erlang:display(erlang:binary_to_list(Version)), halt().' -noshell | grep "${ERLANG_VERSION}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment