Perhaps, like I was, you are now saddled with the task of deploying a copy of ReactionCommerce app and it isn’t going so well or it is taking quite a bit of time like it was for me; I’ve literally got your back. Figured I should make the journey smoother for others…….So here goes nothing.
This will be a step by step guide on Heroku deployment for Reaction Commerce.
Heroku Account Preliminary Setup
- Sign up for an Heroku account if you do not already have one.
- Install the suitable Heroku Toolbelt on your Operating System. You will need this if you intend or prefer to deploy from your terminal.
Reaction Preliminary Setup
Install a copy of reaction commerce with;
git clone https://github.com/reactioncommerce/reaction.git or your forked repo
git checkout master
There are two methods of deployment below; one from the Terminal and the other from the Live Heroku Site. The latter’s instruction are appended to the ‘alternative’ in the setup explanations below. I would suggest picking one deployment method and completely following through on it.
Shall we begin?
From your Terminal
1. Enter your credentials; if you are not already logged in with;
2. Create your app
heroku create desired-app-name
*Creates the app and simultaneously creates and links to a remote heroku branch.
3. View the environment variables (Config Vars) associated with the app you have created.
heroku config --app app-name
At the point; you will not have any variables set. You can use this to check your environment variables after setting them in some of the steps below.
Alternatively for 1 through 3
- Create your app directly from the Live Heroku Site
4. Add a ROOT_URL environment variable
heroku config:set ROOT_URL=http://app-name.herokuapp.com
5. Add a Mongolab instance (there is a free version)
heroku addons:create mongolab
*This automatically creates a variable MONGODB_URI and sets the value to the MongoDb connection string in the “Config Vars”.
You might also be required to verify your account with a credit/debit card in order to add this. You will not be charged for normal usage. See Heroku’s billing policy. However, if you enable review apps; you will likely get charged some token.
6. Add a Build-pack that’ll let Meteor integrate properly with Heroku
heroku buildpacks:set https://github.com/swrdfish/meteor-buildpack-horse.githeroku config:set BUILDPACK_PRELAUNCH_METEOR=1
Alternatively for 4 through 6
- From the Live Heroku site, Access your app -> Settings -> Reveal Config Vars -> set ROOT_URL equal to http://app-name.herokuapp.com
- From the Live Heroku Site, Access your app -> Resources -> Add-Ons -> Add ‘Mlab MongoDB’.
- From the Live Heroku Site, Access your app -> Settings -> Buildpacks -> Paste “https://github.com/swrdfish/meteor-buildpack-horse.git"
- From the Live Heroku site, Access your app -> Settings -> Reveal Config Vars -> set BUILDPACK_PRELAUNCH_METEOR equal to 1.
7. Add Papertrail Add-On to view detailed logs
heroku addons:create papertrail
*This is particularly useful to help obtain your default admin-user login credentials which is posted only once on the first complete successful build.
From the Live Heroku Site, Access your app -> Resources -> Add-Ons -> Add ‘Papertrail’. Then, click the Papertrail Icon on the Add-ons section to take you to your Papertrail dashboard.
8. Add a remote heroku branch;
git remote add heroku https://git.heroku.com/app-name.git
*Not necessary if you created your app from your terminal and in your local repository.
9. Build your app by pushing your repo contents to Heroku
git push heroku master
However, if you are not deploying from your master branch use:
git push heroku your-branch-name:master
*This push triggers Heroku to build your app with all previously defined parameters.
Alternatively for 9
- From the Live Heroku site, Access your app -> Deploy -> Connect to Github -> Add the repository you intend to deploy.
Push Rejected Error
at Array.forEach (native)
at Array.forEach (native)
(packages/minifyStdJS_plugin.js:50:9)! Push rejected, failed to compile Node.js app.
! Push failed
If you encounter the above error during your build process;
- Locate and change the Minifier package in your repository in .meteor/packages to “abernix:standard-minifier-js” or any other minifier that works for you. :)
Whewww!!! At this Point your Build should be passing.
If Your App, is however not getting served(i.e you are getting an application error when you try to open your deployed app), perform below steps;
- Check the state of your working dynos
If it is Zero, scale up your dynos with;
heroku ps:scale web=1
- Clear Repo’s Buildpack Cache with;
heroku config:set BUILDPACK_CLEAR_CACHE=http://app-name.herokuapp.com
- Install Heroku-repo plugin and clear your cache
heroku plugins:install heroku-repo
heroku repo:purge_cache -a app-name
You will then need to rebuild your app by making another push to heroku.
If you are still getting errors after the latest build, empty your remote heroku repository with;
heroku repo:reset -a app-name
And push repo contents again.
If you have tried this setup and it doesn’t work, needed some slight modifications to make it work or you figured a better way of doing it; kindly drop a comment. Muchos Gracias.
PS: This guide is confirmed to still be working as of 15-November-2017.