Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add post compile hook #39

Merged
merged 5 commits into from Jun 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 18 additions & 12 deletions README.md
@@ -1,6 +1,6 @@
# Heroku Buildpack for Elixir

### Features
## Features

* **Easy configuration** with `elixir_buildpack.config` file
* Use **prebuilt Elixir binaries**
Expand All @@ -10,9 +10,10 @@
* Consolidates protocols
* Hex and rebar support
* Caching of Hex packages, Mix dependencies and downloads
* Post compilation hook through `post_compile` configuration


#### Version support info
#### Version support

* Erlang - Prebuilt packages (17.5, 17.4, etc)
* Elixir - Prebuilt releases (1.0.4, 1.0.3, etc) or prebuilt branches (master, stable, etc)
Expand Down Expand Up @@ -53,6 +54,9 @@ always_rebuild=false

# Export heroku config vars
config_vars_to_export=(DATABASE_URL)

# A command to run right after compiling the app
post_compile="pwd"
```


Expand Down Expand Up @@ -100,18 +104,20 @@ config_vars_to_export=(DATABASE_URL MY_VAR)

* 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:

```elixir
defmodule MyApp.Mixfile do
use Mix.Project
```elixir
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]
def project do
[app: :my_app,
version: "0.0.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod]
end
end
end
```
```

* The buildpack will execute the command configured in `post_compile` in the root directory of your application after it has been compiled. This script can be used to build or prepare things for your application, for example compiling assets.


## Credits
Expand Down
3 changes: 2 additions & 1 deletion bin/compile
Expand Up @@ -24,7 +24,6 @@ source ${build_pack_path}/lib/app_funcs.sh

mkdir $(platform_tools_path)


load_config
export_config_vars
export_mix_env
Expand All @@ -47,4 +46,6 @@ copy_hex
compile_app
backup_app
backup_mix

post_compile_hook
write_profile_d_script
11 changes: 11 additions & 0 deletions lib/app_funcs.sh
Expand Up @@ -60,6 +60,17 @@ function compile_app() {
cd - > /dev/null
}

function post_compile_hook() {
cd $build_path

if [ -n "$post_compile" ]; then
output_section "Executing post compile: $post_compile"
$post_compile || exit 1
fi

cd - > /dev/null
}


function write_profile_d_script() {
output_section "Creating .profile.d with env vars"
Expand Down