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

Provide a phoenix-static buildpack #835

Closed
josevalim opened this issue May 1, 2015 · 30 comments
Closed

Provide a phoenix-static buildpack #835

josevalim opened this issue May 1, 2015 · 30 comments

Comments

@josevalim
Copy link
Member

We need a phoenix build pack that is going to compile brunch.io assets on Heroku. The phoenix-static build pack is supposed to play with the existing Elixir buildpack and just add the following steps:

  1. Installation and cache of node.js
  2. Running brunch --production
  3. Running mix phoenix.digest in the appropriate MIX_ENV to copy the files

For now, brunch can be hardcoded, but we can make it configurable in the future to support other build tools.

We would really appreciate help from developers interested in tackling and providing this build pack as a separate project!

@tsloughter
Copy link

A new Heroku CLI feature that should help with this will land today or tomorrow. I'll update when it is.

@josevalim
Copy link
Member Author

Tell us more! 🙊

@lstor
Copy link

lstor commented May 2, 2015

I personally think using a multi-buildpack approach is better. The advantages are among other things:

  • the Elixir community doesn't have to maintain a non-Elixir buildpack
  • it's build-tool agnostic, with a complete node environment
  • it's working already and doesn't require any extra effort

I've been thinking about writing a guide on how to do this, but a sooper quick rundown is:

  1. Use heroku-buildpack-multi as buildpack

    heroku buildpacks:set https://github.com/heroku/heroku-buildpack-multi
    
  2. Add this to .buildpacks

    https://github.com/HashNuke/heroku-buildpack-elixir.git#36f2ff22d0236589256d9044091b950b7cc565d2
    https://github.com/heroku/heroku-buildpack-nodejs.git#v75
    
  3. Add a postinstall hook to package.json

    {
      "...": {
        // Other stuff
      },
      "scripts": {
        "postinstall": "brunch build --production"
      }
    }
  4. Profit!

I'm using this for patback (very WIP project), and it works like a charm.

@tsloughter
Copy link

You'll be able to do it without using that buildpack very soon.

@tsloughter
Copy link

The buildpack stuff has been released if you update your client. They are still working on a devcenter article:

$ heroku buildpacks --help
.....
Additional commands, type "heroku help COMMAND" for more details:

  buildpacks:add BUILDPACK_URL       #  add new app buildpack, inserting into list of buildpacks if neccessary
  buildpacks:clear                   #  clear all buildpacks set on the app
  buildpacks:remove [BUILDPACK_URL]  #  remove a buildpack set on the app
  buildpacks:set BUILDPACK_URL       #  set new app buildpack, overwriting into list of buildpacks if neccessary

@patrickbrown-dev
Copy link
Contributor

Awesome!! 😄 👍

@tsloughter
Copy link

@hayesgm
Copy link
Contributor

hayesgm commented May 31, 2015

As there's a few gotchas (e.g. multiple buildpacks and asset digesting), would it be good to add a "Deploying to Heroku" section to the official Phoenix guides? This would an alternative to creating a phoenix static buildpack.

@ericmj
Copy link
Contributor

ericmj commented May 31, 2015

We don't need a separate buildpack - just a post_compile hook in the existing buildpack, with that it should be fairly straight forward process of setting it up. Either way documenting it in the guides is a good idea.

@lancehalvorsen
Copy link
Member

Revamping the way we handle deployment in the guides is coming up right after the current chunk of work on testing. Right now, we have this tabula rasa for Heroku deployment:
https://github.com/phoenixframework/phoenix_guides/blob/master/deployment/E_heroku.md

As always, PR's are very welcome. :)

@ericmj
Copy link
Contributor

ericmj commented May 31, 2015

@lancehalvorsen I will contribute docs when the buildpack is ready.

@lancehalvorsen
Copy link
Member

@ericmj, for that, you get the @josevalim -style-all-the-hearts-emoji!
❤️ 💚 💙 💛 💜

@gjaldon
Copy link
Contributor

gjaldon commented Jun 14, 2015

Hi all!

Just created a phoenix static buildpack. It has configuration much like elixir buildpack. It caches node, npm modules and bower components and runs brunch build --production and mix phoenix.digest.

I tried it out with several Heroku deploys and it seems to work fine. I also had @ericmj initially review it. I'll address any issues reported as soon as I can.

Feel free to leave any feedback and hope you guys find it satisfactory!

@josevalim
Copy link
Member Author

This is just fantastic! Thank you @gjaldon! ❤️ 💚 💙 💛 💜

@gjaldon
Copy link
Contributor

gjaldon commented Jun 15, 2015

My pleasure! 😄

@sheharyarn
Copy link

@gjaldon Awesome! 😮

@gjaldon
Copy link
Contributor

gjaldon commented Jun 22, 2015

Thanks! :D

On Tue, Jun 23, 2015 at 3:40 AM, Sheharyar Naseer notifications@github.com
wrote:

@gjaldon https://github.com/gjaldon Awesome! [image: 😮]


Reply to this email directly or view it on GitHub
#835 (comment)
.

Gabe Jaldon

@ulrikstrid
Copy link

@gjaldon I think doing something like npm production or something like that would be better if some one want to use gulp/webpack/whatever instead of brunch.

@gjaldon
Copy link
Contributor

gjaldon commented Jul 18, 2015

@ulrikaugustsson you could customize the commands being run for compiling your assets. Check it out here: https://github.com/gjaldon/heroku-buildpack-phoenix-static#compile

@ulrikstrid
Copy link

Okey, sorry! Just thought that a "sane default" would be best but documentation should give the same result. :) 👍

@chrismccord
Copy link
Member

I've tested this out and it worked perfectly. Thank you very much @gjaldon. We have a Heroku guide in place here
https://github.com/phoenixframework/phoenix_guides/blob/master/deployment/E_heroku.md

I think the only thing left to close this one out is to get this up on the site. // @lancehalvorsen @jeregrine

@lancehalvorsen
Copy link
Member

Fabulous! I'm on it.

@lancehalvorsen
Copy link
Member

Heroku Deployment Guide is now live on phoenixframework.org.

Thanks so much @gjaldon for providing the buildpack, and thanks again to @stevedomin for the guide!

@gjaldon
Copy link
Contributor

gjaldon commented Jul 18, 2015

My pleasure, guys! Looking forward to seeing the Heroku guide up on Phoenix Guides. :)

@matthewlehner
Copy link
Contributor

Howdy folks, following along with the Heroku guide and ran into what is probably a small issue with the secret key and crypto key generation on forms, I think for CSRF stuff – detailed this in #1033

The tooling has really come along nicely! Thanks for so much hard work with the guides, and build packs, etc. 😸

@gjaldon
Copy link
Contributor

gjaldon commented Jul 20, 2015

@matthewlehner I just responded to the issue you posted

@stevedomin
Copy link
Contributor

@matthewlehner @gjaldon sorry about that one, was a last minute change based on some reading I had done, forgot to try it

@gjaldon
Copy link
Contributor

gjaldon commented Jul 20, 2015

No prob at all, @stevedomin. I'm just happy you wrote the guide :)

@gjaldon
Copy link
Contributor

gjaldon commented Jul 22, 2015

@chrismccord @josevalim looks like this is good to close

@josevalim
Copy link
Member Author

Indeed! ❤️ 💚 💙 💛 💜

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

No branches or pull requests