'How should the Procfile of a Ruby on Rails/React Heroku app be made, and how should one handle the Rails portion of a Heroku app?

Per the docs here: https://blog.heroku.com/a-rock-solid-modern-web-stack#step-5-deploy-it-to-heroku, the Procfile should look something like:

web: bundle exec rails s
release: bin/rake db:migrate

This should be the procfile for the heroku app, not the local one that fires off the two servers. I'm confused by bin/rake. None of my attempts to create something like this file have worked, all yielding different errors.

I'm not sure where to start with asking questions, but I'll start with, is bin/rake referring to the local file system or the heroku app file system? If local, shouldn't it be backend_folder/bin/rake?

I've tried all sorts of variations as well. Why is it not locating the Rake file, or telling me it doesn't recognize the bundle command or saying no such file or directory referring to db:migrate?

Am I doing this all wrong by having Rails in a separate folder? I thought it was standard practice to have a backend folder and a frontend folder. If so, how does one handle having to need a Gemfile and Gemfile.lock in the root? Currently I have my two folders set up, but I ended up copying the Gemfile to the root just to get it to work. This can't be ideal. Any pointers?



Solution 1:[1]

Take a look at the structure of the referenced github project: https://github.com/heroku/list-of-ingredients

The rails app is in the root directory and then there is a client directory that contains the react code. It starts with an index.html file that is then referenced in the ApplicationController as the fallback html.

When you create the app in heroku you will notice some documentation on adding the buildpack for both ruby and nodejs. https://github.com/heroku/list-of-ingredients#getting-started. This will make it so that it runs as a Rails application in Heroku but will also compile the JS so it can be referenced by Rails.

You will see that the root also has a package.json file that has the scripts defined that will be used.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dknox20