Super-easy deploying is what I’m used to with Heroku and my small prototype apps. However, now when I now started to use Ember CLI, deploying wasn’t that easy because the instructions Google found me weren’t that clear. So I decided to write my own contribution.
1) Install Ember CLI, generate your app with eg. "ember new brand-new-app"
2) Add a file called Procfile
to the app folder root and add there one line:
web: npm run start
3) Edit Package.json
and find "scripts": { ... }
block.
Add the Heroku’s port constant to the start script and also add a new “postinstall” attribute to run bower
during the deployment.
"scripts": { "start": "ember serve --port=${PORT}", "build": "ember build", "test": "ember test", "postinstall": "bower install" },
4) Continue editing Package.json
and find the "devDependencies": { ... }
block.
Add bower
to your dependencies (eg. "bower": "1.3.12",
)
Rename the block from “devDependencies” to “dependencies” to change them as dependencies you want to use while deploying.
However, you still have to have the <code>ember-cli</code> package in your devDependencies because that’s how ember detects that the app is an Ember CLI. Otherwise you’ll be told that “You have to be inside an ember-cli project in order to use the serve command”.
In the end the “devDependencies” and “dependencies” blocks look something like this:
"dependencies": { "bower": "1.3.12", "broccoli-asset-rev": "^2.0.0", "broccoli-ember-hbs-template-compiler": "^1.6.1", "connect-restreamer": "^1.0.1", "ember-cli": "0.1.15", "ember-cli-6to5": "^3.0.0", ... }, "devDependencies": { "ember-cli": "0.1.15" }
5) Commit your changes, create a Heroku app and let Heroku do the rest!
git add -A .
git commit -a -m "Heroku settings"
heroku create
git push heroku master
heroku open
Congrats, now you have your app running also on Heroku!
Thanks to Brendan Graetz for the best advice I found, this is basicly just me reformatting his blog. And of course Heroku’s Node.js docs helped too. I was using Ember CLI version 0.1.15.