Here you are done with your project and you are ready to show it to friends and family but hey they’re not developers like you are, they don’t have a local environment setup and they will probably have no idea on how to clone your repository. Obviously the best thing to do is to deploy it so they can just a website that they can use and voila experience your app.
One of the most famous cloud based platforms that developers use is Heroku. So here’s how you can deploy your project easily:
You will only do Steps 1 & 2 if this is your first time using Heroku. Now let’s move on to deploying your app. There are two ways you can do this:
OPTION # 1 - Using Heroku in your browser
A. On the top right corner, click the button NEW and choose Create new app. Fill out the form with the name of your app. When you have successfully created an app on Heroku, it’s time to connect it to the app you made in your local environment.
C. Then run the following commands:
git init heroku git:remote -a <NAME OF THE APP YOU CREATED ON HEROKU> git add . git commit -am “<commit message>” git push heroku master
If you already have an existing repository and does not have any changes, you can just simply run
heroku git:remote -a <NAME OF THE APP YOU CREATED ON HEROKU> and then
git push heroku master.
OPTION # 2 - Using the Command Line
A. On the root directory of your app, Run
B. To create the app on Heroku, run
heroku create <NAME OF YOUR APP>
C. To check if you have successfully created a remote repository on heroku run
git config --list | grep heroku. If it is confirmed then you can now push your app to heroku for deployment by running
git push heroku master.
D. When your deployment is successful, do not forget to migrate your database and seed file if you have any:
heroku run rake db:migrate heroku run rake db:seed
Do not also forget to connect the Github repository when you deploy. So if in case you there's something to want to refactor or update, it will be automatically pushed the changes to your deployed site.
heroku open to check out your app live!!!
If you are like me who’s a big fan of trial and error approach and needs to delete the app you created on heroku by going to the app on your heroku profile, then settings. At the bottom of the page you’ll see a button that will ask you about deleting your app on heroku.
Next week, we'll cover how to deploy your Rails backend to Heroku and your React frontend to Netlify.
Please read Heroku's documentation for more information.