Hanami: SERVE_STATIC_ASSETS for production

Created on 19 Apr 2016  Â·  4Comments  Â·  Source: hanami/hanami

Right now, SERVE_STATIC_ASSETS = "true" for development and test, but not production.

This makes sense when deploying to a server like Nginx.

But for Heroku, SERVE_STATIC_ASSETS must be "true".

I ran across this issue when deploying to Heroku (says something like /public/assets.json not found) and so did @jxxcarlson.

The Assets guide 'overview' covers this but it's not clear everyone will read that before deploying to Heroku.

A few options I see, in order of most helpful fixing this problem to least:

  1. Consider changing the default for production to SERVE_STATIC_ASSETS="true", and have the guides instruct users to set it to false if using Nginx, etc.? The Hanami homepage has instructions for how to deploy to Heroku. The upside here is that "it just works" for all hosting environments. The downside is that, for Nginx you don't want your assets going through Ruby.
  2. Is it possible to add a message when deploying a Hanami app to Heroku and SERVE_STATIC_ASSETS="false", alerting them that they need to set SERVE_STATIC_ASSETS to "true"?
  3. At the very least, can we add the specific error message to the Assets 'Overview' guide, to facilitate searching for the error? (or create a 'Deploying' Assets guide)
wontfix

Most helpful comment

I'd like to conduct an informal poll.

Please add a reaction to this post, according to which hosting environment you use for Hanami apps:

:heart: for Heroku
:tada: for non-Heroku
:smile: for both
:confused: for none, yet

It doesn't need to be a 'real app' or have users, just something you have deployed.

Everyone is invited to respond! cc/ @hanami/contributors

All 4 comments

I'd like to conduct an informal poll.

Please add a reaction to this post, according to which hosting environment you use for Hanami apps:

:heart: for Heroku
:tada: for non-Heroku
:smile: for both
:confused: for none, yet

It doesn't need to be a 'real app' or have users, just something you have deployed.

Everyone is invited to respond! cc/ @hanami/contributors

I don't like idea to set SERVE_STATIC_ASSETS to true in production for many reasons:
– Heroku is just one from many. And it is a known limitation by Heroku. Anyway, you have to configure Heroku before deployment. So, what is problem to execute heroku config:set SERVE_STATIC_ASSETS="true"?
– It not breaks existed Hanami projects but can create some problems.
– It's a common practice that assets should be served by a server (NGINX or Apache).

P.S.
As for deployment on Heroku. I have a draft of the article how to deploy on Heroku, and your issue is a real motivation to finish and publish to blog.

@aderyabin All good points!
Perhaps 2) could be implemented by tying into the rake assets:precompile command, since that should only be run from Heroku? (See "Ruby Ecosystem Compatibility" section here: http://hanamirb.org/guides/applications/rake/)

I agree with @aderyabin .

@cllns You raised a good point. Because we feature Heroku deployment on the homepage, what if we add this step over there? Can you please do that?

We can eventually expand with a Deployment section in guides to cover Heroku and other vendors. To be clear, It's NOT to up to us to maintain these deployment instructions. The website it's open for the people working at these companies. If they want to get featured over there, they should maintain the guides.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nattfodd picture nattfodd  Â·  9Comments

vlad-at-work picture vlad-at-work  Â·  7Comments

gerrywastaken picture gerrywastaken  Â·  3Comments

thelastinuit picture thelastinuit  Â·  4Comments

andrew picture andrew  Â·  5Comments