GithubHelp home page GithubHelp logo

shakrmedia / heroku-buildpack-elixir Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashnuke/heroku-buildpack-elixir

0.0 3.0 0.0 345 KB

Heroku Buildpack for Elixir with nitro boost

License: MIT License

Shell 100.00%

heroku-buildpack-elixir's Introduction

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.

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.

heroku-buildpack-elixir's People

Contributors

anulman avatar axelson avatar burgestrand avatar ch4s3 avatar chrismcg avatar crowdhailer avatar ericmj avatar hashnuke avatar jayjun avatar jesseshieh avatar ma2gedev avatar matthijsgroen avatar mikker avatar msz avatar mxhold avatar myobie avatar niku avatar novaugust avatar oldhammade avatar optikfluffel avatar pbm avatar seantanly avatar seivan avatar simonewebdesign avatar sinetris avatar szymon-jez avatar techgaun avatar trenpixster avatar tyler-eon avatar ventsislaf avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.