• Stars
    star
    810
  • Rank 56,306 (Top 2 %)
  • Language
    Shell
  • License
    MIT License
  • Created almost 11 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Heroku Buildpack for Elixir with nitro boost

Heroku Buildpack for Elixir

Features

  • 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

Version support

Note: you should choose an Elixir and Erlang version that are compatible with one another.

Cloud Native Support

This buildpack is not guaranteed to be Cloud Native compatible. The elixir-buildpack/cloud-native-buildpack is a buildpack that is actively under development and is designed specifically to follow the Cloud Native Buildpack conventions.

Usage

Create a Heroku app with this buildpack

heroku create --buildpack hashnuke/elixir

Set the buildpack for an existing Heroku app

heroku buildpacks:set hashnuke/elixir

Use the edge version of buildpack

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

When you decide to use the published or the edge version of the buildpack you should be aware that, although we attempt to maintain the buildpack for as many old Elixir and Erlang releases as possible, it is sometimes difficult since there's a matrix of 3 variables involved: 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 a specific version of buildpack.

Use a specific version of buildpack

The methods above always use the latest version of the buildpack code. To use a specific version of the buildpack, choose a commit from the commits page. The commit SHA forms part of your buildpack url.

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

It is recommended to use a buildpack url with a commit SHA on production apps. This prevents the unpleasant moment when your Heroku build fails because the buildpack you use just got updated with a breaking change. Having buildpacks pinned to a specific version is like having your Hex packages pinned to a specific version in mix.lock.

Using Heroku CI

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 to mix compile --force --warnings-as-errors.

Elixir Releases

This buildpack can optionally build an Elixir release. The release build will be run after hook_post_compile.

WARNING: If you need to do further compilation using another buildpack, such as the Phoenix static buildpack, you probably don't want to use this option. See the Elixir release buildpack instead.

To build and use a release for an app called foo compiled with MIX_ENV=prod:

  1. Make sure elixir_version in elixir_buildpack.config is at least 1.9
  2. Add release=true to elixir_buildpack.config
  3. Use web: _build/prod/rel/foo/bin/foo start in your Procfile

NOTE: This requires the master version of the buildpack (or a commit later than 7d369c)

Configuration

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"

Migrating from previous build pack

the following has been deprecated and should be removed from elixir_buildpack.config:

# Export heroku config vars
config_vars_to_export=(DATABASE_URL)

Specifying Elixir version

  • 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)

Specifying Erlang version

  • You can specify an Erlang release version like below
erlang_version=18.2.1

Specifying config vars to export at compile time

  • To set a config var on your heroku node you can exec from the shell:
heroku config:set MY_VAR=the_value

Other notes

  • Add your own Procfile to your application, else the default web task mix 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/or hook_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.

Development

Testing

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

Credits

Β© Akash Manohar under The MIT License. Feel free to do whatever you want with it.

More Repositories

1

hound

Elixir library for writing integration tests and browser automation
Elixir
1,362
star
2

mogo-chat

Beautiful team chat app written in Elixir & Ember.js
JavaScript
740
star
3

ansible-elixir-stack

Ansible role to setup server with Elixir & Postgres to deploy apps
Python
295
star
4

arduino

A ruby library to talk to Arduino without having to burn programs repeatedly to the board
Ruby
248
star
5

Python-Arduino-Prototyping-API

Helps you to quickly prototype Arduino programs, without having to repeatedly load the program to the Arduino board
Python
148
star
6

mailgun

mailgun library for ruby
Ruby
118
star
7

rotor

Super-simple build system for Elixir
Elixir
83
star
8

mail-to-json

A MailGun.com clone in under 300 lines of Elixir
Elixir
45
star
9

elixir-users

Elixir users and meetups on a map
Ruby
39
star
10

heroku-buildpack-elixir-otp-builds

Erlang OTP build scripts for the Heroku Elixir Buildpack
Shell
37
star
11

coffee_rotor

Rotor plugin to compile CoffeeScript files
Elixir
17
star
12

realm

Database-independent model layer for Elixir with validations
Elixir
11
star
13

riak_pool

Provides pooled Riak connections for Elixir apps. Re-connects automatically upon disconnection.
Elixir
9
star
14

j

a simple command-line task manager written in ruby
Ruby
7
star
15

pixelart-editor

a pixel art editor using HTML DIVs for my HackerSchool application
CoffeeScript
6
star
16

ecto-riak-adapter

Elixir
6
star
17

wordpress-deploy

πŸ” Secure and πŸ€‘ budget-friendly Wordpress setup for your digital garden 🏑
PHP
6
star
18

billmebob

a simple rails3 invoice app
Ruby
5
star
19

elixir-examples

Elixir samples
Elixir
5
star
20

stylish

Erlang library to compile SCSS files
Erlang
5
star
21

github-create

a tool to help create github repos for projects directly from terminal
Ruby
4
star
22

ennio

Elixir
4
star
23

dot-files

all my dot files belong here
Vim Script
4
star
24

Prick

Prick.js lightweight web framework for node,js. Apologies for the bad name. I named it without knowing the other meaning of `Prick`
JavaScript
4
star
25

heroku-buildpack-elixir-test

Sample app to test and play with the Heroku Elixir Buildpack
Elixir
3
star
26

Dump-app

SMS dashboard for events
Ruby
3
star
27

Java-Arduino-Prototyping-API

Java Arduino API to prototype arduino based apps in java
Java
3
star
28

phoenix-deployment-notes

Dockerfile
2
star
29

Rtree.js

Implementation of RTree in javascript. Specific to 2D structures
JavaScript
2
star
30

EnnioLisp

A Scheme interpreter in Ruby
Ruby
2
star
31

VoicedOpen

support ticketing application that supports both Bushido and non-Bushido platforms
JavaScript
2
star
32

firebrick

Elixir
2
star
33

jump-ship

JavaScript
2
star
34

hackbadge

Hackathon stats, with drama and a climax
Ruby
2
star
35

duby-workouts

Sample Android applications using Duby - a work in progress
Java
2
star
36

Pong-In-Polycode

Pong game in Polycode - work in progress
Lua
2
star
37

rad-pike

Ruby
1
star
38

job_trends

Elixir
1
star
39

power-house

Elixir
1
star
40

rails_templates

Ruby
1
star
41

hackonday

site for hackonday
Ruby
1
star
42

get_mogo_chat

Landing page website for MogoChat
Elixir
1
star
43

quicktodo

a todo list app in rails.
Ruby
1
star
44

tic-tac-toe-coffeescript

Tic Tac Toe in coffeescript
JavaScript
1
star
45

rosalind

Elixir
1
star
46

kogo

Ruby
1
star
47

SICP-excercises

SICP excercises. Says it all
Racket
1
star
48

dot-emacs

my .emacs.d dir :)
Emacs Lisp
1
star
49

ShoutJam

source code for an SMS service I operated in Feb-2009
Python
1
star
50

take_a_look

A try a writing a simple ruby debugger
Ruby
1
star
51

HashNuke

1
star
52

airport_ride

airport_ride app
Ruby
1
star
53

stpvm

stpvm
JavaScript
1
star
54

elixir-for-breakfast

Elixir
1
star
55

hello-stage

Elixir
1
star
56

darkroom-mode

git mirror for https://bitbucket.org/phromo/darkroom-mode/ Distraction-free emacs writing mode
Emacs Lisp
1
star
57

brunch-bower-babel-starter

JavaScript
1
star
58

wire

Elixir websockets server for browser-based games
Elixir
1
star
59

htdp-solutions

My solutions to the exercises in the book "How To Design Programs"
Scheme
1
star
60

graphql-tryouts

GraphQL tryouts with Rails & Python apps along with schema-stitching
Ruby
1
star
61

meteorites-data-scripts

Scripts to add country info for meteorites dataset, using Geonames API
Ruby
1
star
62

hello_plug_sessions

sample app to play with plug sessions. configured with ets session store
Elixir
1
star