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 Elixir releases support #153

Merged
merged 3 commits into from
Nov 14, 2019
Merged

add Elixir releases support #153

merged 3 commits into from
Nov 14, 2019

Conversation

msz
Copy link
Contributor

@msz msz commented Jul 8, 2019

Elixir 1.9 introduced mix release. This is a huge improvement for Heroku based deployments because the slug can be compiled once and then deployed to different apps with different configs which will be read at runtime.

This PR adds a new option to build the default release on top of the usual compilation process. After the slug is compiled the release can be run by having web: _build/prod/rel/{app_name}/bin/{app_name} start. We at Tallarium already use this setup in all our Elixir Heroku apps.

@tarzan
Copy link

tarzan commented Jul 10, 2019

...because the slug can be compiled once and then deployed to different apps with different configs which will be read at runtime.

Do you have any examples of how to configure this? Does it also work with automatic deployment through github integration (on heroku)?

@msz
Copy link
Contributor Author

msz commented Jul 10, 2019

If your apps are connected in a Heroku pipeline, "Promote to production..." will instantly deploy the staging slug to all production environments without recompilation. This is what I had in mind.

@chrismcg
Copy link
Contributor

I just tried this out, thanks! I ran into a problem with my phoenix app though. The releases are built before the phoenix buildpack generates the asset files so they don't get included. Is there a way to work round this or is something needed in the phoenix buildpack?

@msz
Copy link
Contributor Author

msz commented Sep 22, 2019

I can see three ways to go about this:

  1. Move hook_post_compile to happen before release. This will allow artifacts from any post-compilation tasks (such as building assets) to be bundled into the release. The asset compilation task would have to be custom written and attached to the hook though.
  2. Add an option to generate a release into the Phoenix buildpack as well. It could overwrite the release built by the Elixir buildpack.
  3. Create a third buildpack which just generates a release and is run as the last buildpack.

In fact I think option 1. is better behaviour than the current one. I will move the hook.

@chrismcg
Copy link
Contributor

I had a go at option 3 here https://github.com/chrismcg/elixir-mix-release-buildpack. It works a bit better for me as there's a lot in the phoenix buildback I wouldn't want to have to reproduce.

For those just building API or non phoenix apps I think this PR would still be a good thing to have in the Elixir buildpack so it stays a "one stop shop".

@chrismcg
Copy link
Contributor

chrismcg commented Oct 4, 2019

I've tidied my buildpack up a little, it's at https://github.com/chrismcg/heroku-buildpack-elixir-mix-release now.

@jesseshieh
Copy link
Collaborator

@msz this looks like an improvement to me. Do you think you can add a section in the README to describe this option a bit more and explain that it's probably not to be used if you also use the phoenix static buildpack and in that case to use @chrismcg's third buildpack instead?

@msz
Copy link
Contributor Author

msz commented Nov 13, 2019

Done!

@jesseshieh jesseshieh merged commit 95187a9 into HashNuke:master Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants