This repository has been archived.
📚 Archived Status: This repository is no longer actively maintained or updated. It is being preserved for historical reference or potential future use. Issues, pull requests, and contributions are no longer accepted.
- Easy configuration with
elixir_buildpack.config
file - Use prebuilt Elixir binaries
- Allows configuring Erlang
- If your app doesn't have a Procfile, default web task
mix run --no-halt
will be run. - Consolidates protocols
- Hex and rebar support
- Caching of Hex packages, Mix dependencies and downloads
- Compilation procedure hooks through
hook_pre_compile
,hook_compile
,hook_post_compile
configuration
- Erlang - Prebuilt packages (17.5, 17.4, etc)
- The full list of prebuilt packages can be found here: https://github.com/HashNuke/heroku-buildpack-elixir-otp-builds/blob/master/otp-versions
- Note: if a version you want is missing then you can create a PR that adds it
- Elixir - Prebuilt releases (1.0.4, 1.0.3, etc) or prebuilt branches (master, v1.7, etc)
- The full list of releases can be found here: https://github.com/elixir-lang/elixir/releases
- The full list of branches can be found here: https://github.com/elixir-lang/elixir/branches
Note: you should choose an Elixir and Erlang version that are compatible with one another.
heroku create --buildpack hashnuke/elixir
heroku buildpacks:set hashnuke/elixir
The hashnuke/elixir
buildpack contains the latest published version of
the buildpack, but you can use the edge version (i.e. the source code in this repo) by running:
heroku buildpacks:set https://github.com/HashNuke/heroku-buildpack-elixir.git
The above method always uses the latest version of the buildpack code. To use a specific older version of the buildpack, see notes below.
This buildpack supports Heroku CI.
- To enable viewing test runs on Heroku, add tapex to your project.
- To detect compilation warnings use the
hook_compile
configuration option set tomix compile --force --warnings-as-errors
.
Create a elixir_buildpack.config
file in your app's root dir. The file's syntax is bash.
If you don't specify a config option, then the default option from the buildpack's elixir_buildpack.config
file will be used.
Here's a full config file with all available options:
# Erlang version
erlang_version=18.2.1
# Elixir version
elixir_version=1.2.0
# Always rebuild from scratch on every deploy?
always_rebuild=false
# Create a release using `mix release`? (requires Elixir 1.9)
release=true
# A command to run right before fetching dependencies
hook_pre_fetch_dependencies="pwd"
# A command to run right before compiling the app (after elixir, .etc)
hook_pre_compile="pwd"
hook_compile="mix compile --force --warnings-as-errors"
# A command to run right after compiling the app
hook_post_compile="pwd"
# Set the path the app is run from
runtime_path=/app
# Enable or disable additional test arguments
test_args="--cover"
the following has been deprecated and should be removed from elixir_buildpack.config
:
# Export heroku config vars
config_vars_to_export=(DATABASE_URL)
- Use prebuilt Elixir release
elixir_version=1.2.0
- Use prebuilt Elixir branch, the branch specifier ensures that it will be downloaded every time
elixir_version=(branch master)
- You can specify an Erlang release version like below
erlang_version=18.2.1
- To set a config var on your heroku node you can exec from the shell:
heroku config:set MY_VAR=the_value
-
Add your own
Procfile
to your application, else the default web taskmix run --no-halt
will be used. -
Your application should build embedded and start permanent. Build embedded will consolidate protocols for a performance boost, start permanent will ensure that Heroku restarts your application if it crashes. See below for an example of how to use these features in your Mix project:
defmodule MyApp.Mixfile do use Mix.Project def project do [app: :my_app, version: "0.0.1", build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod] end end
-
The buildpack will execute the commands configured in
hook_pre_compile
and/orhook_post_compile
in the root directory of your application before/after it has been compiled (respectively). These scripts can be used to build or prepare things for your application, for example compiling assets. -
The buildpack will execute the commands configured in
hook_pre_fetch_dependencies
in the root directory of your application before it fetches the application dependencies. This script can be used to clean certain dependencies before fetching new ones.
Using the above methods always uses the latest version of the buildpack. We attempt to maintain the buildpack for as many old Elixir and Erlang releases as possible. But sometimes it does get hard since there's a matrix of 3 variables involved here (Erlang version, Elixir version and Heroku stack). If your application cannot be updated for some reason and requires an older version of the buildpack then use the commits page to pick a commit to use. Use the buildpack url with the commit SHA.
For example, if you pick the commit "883f33e10879b4b8b030753c13aa3d0dda82e1e7", then the buildpack url for your app would be:
https://github.com/HashNuke/heroku-buildpack-elixir.git#883f33e10879b4b8b030753c13aa3d0dda82e1e7
Consider all versions (e.g. commits, tags) older than master as not recommended for use and not supported any further.
- Build scripts to build erlang are at https://github.com/HashNuke/heroku-buildpack-elixir-otp-builds
- Sample app to test is available at https://github.com/HashNuke/heroku-buildpack-elixir-test
To run tests
git clone https://github.com/HashNuke/heroku-buildpack-elixir
export BUILDPACK="$(pwd)/heroku-buildpack-elixir"
git clone https://github.com/jesseshieh/heroku-buildpack-testrunner
git clone https://github.com/jesseshieh/shunit2
export SHUNIT_HOME="$(pwd)/shunit2"
cd heroku-buildpack-testrunner
bin/run $BUILDPACK
See more info at https://github.com/jesseshieh/heroku-buildpack-testrunner/blob/master/README.md
© Akash Manohar under The MIT License. Feel free to do whatever you want with it.