Deploy To Heroku
There are a number of issues and additional items that need to been done when deploying to Heroku (or other production environments.) Even if not deploying to Heroku these steps will cover most of the gotchas that you will encounter.
If you do find any problems please log an issue, or better yet do a pull request on this page.
- 1.You need to use postgresql rather than sqlite or mysql. You can find instructions on how to do this online, or better yet when you create your rails app, create it from the beginning with postgresql: https://www.digitalocean.com/community/tutorials/how-to-set-up-ruby-on-rails-with-postgres
app/models/application_record.rbThis is no longer needed due to a recent rails fix, and confuses Heroku.
- 3.Use harmonly uglifier. In config/environments/production.rb you need to change this line from:
config.assets.js_compressor = :uglifierto
config.assets.js_compressor = Uglifier.new(harmony: true)
- 4.Insure webpacker:compile occurs before assets:precompile: at the end of the
Rakefile(in the root directory) add this line:
- 5.Setup your database Make sure you run
Heroku run rake db:migrate
- 6.Update your production policies By default the Hyperstack installer will leave your Policies wide open but not in production. For a production app you will want to add restrictive Policies to protect your data. If you just want to get things working on Heroku you can remove the guard from the end of the
stylesheet_pack_tags: Hyperstack does not automatically pull in the
.csspacks. Instead you have to add one or both these lines to your layouts, if you are requiring css assets in the pack files:
<%= stylesheet_pack_tag 'client_only' %>If you are requiring css libraries in the
client_only.jspack file and
<%= stylesheet_pack_tag 'client_and_server' %>If you are requiring css libraries in the
- 8.Setup ActionCable (see full instructions for details) provision Redis on Heroku
Heroku addons:add redistogothen get the Heroku url:
Heroku config --app action-cable-example | grep REDISTOGO_URLuse the url in config/cable.yml (in the production section) in config/environments/production.rb add these two lines:
config.web_socket_server_url = "wss://your-app.Herokuapp.com/cable"
config.action_cable.allowed_request_origins = ['https://your-app.Herokuapp.com', 'http://action-your-app.Herokuapp.com']
After updating anything in the hyperstack initializer you will need to force Heroku to clear the cache:
First install the Heroku-repo plugin (on your console)
$ Heroku plugins:install Heroku-repo
and then to clear the cache do:
$ Heroku repo:purge_cache -a appname
$ git commit --allow-empty -m "Purge cache"
$ git push Heroku master