8

Has anyone deployed an ember-cli + rails app in Heroku like this one? https://github.com/bostonember/website If yes, how did/do you deploy?

I know that ember-cli produces all the necessary code in the dist/ dir, which should be placed (copied) under rails' public/ directory but I am not sure how and when to do that given that Heroku does not allow any write access in its filesystem. So if anyone has already done that, let me know :)

The reason that I chose ember-cli instead of the ember-rails gem is that I don't want to be dependent on any rails' gem developer. I think ember-cli is a good option as long as I can deploy efficiently in heroku :D

vasilakisfil
  • 2,279
  • 4
  • 24
  • 31

3 Answers3

12

Dockyard worked through an example of this during a Boston Ember meetup. Here's the video.

They posted the code online, the important part being the deploy task of the rakefile:

task :deploy do
  sh 'git checkout production'
  sh 'git merge rails-served-html -m "Merging master for deployment"'
  sh 'rm -rf backend/public/assets'
  sh 'cd frontend && BROCCOLI_ENV=production broccoli build ../backend/public/assets && cd ..'

  unless `git status` =~ /nothing to commit, working directory clean/
    sh 'git add -A'
    sh 'git commit -m "Asset compilation for deployment"'
  end

  sh 'git subtree push -P backend heroku master'

  sh 'git checkout -'
end

Essentially, you copy the dist from ember-cli directly into Rails public folder, then deploy the rails subfolder as a rails app to Heroku using subtree. I've done this myself, and it works well.

Note that the approach in the "Lightening fast deployments" blog post @eXa linked to is ultimately better, since you can change your Ember app without touching or redploying your Rails app.

Sam Selikoff
  • 12,366
  • 13
  • 58
  • 104
  • since you have done this and it worked for you. Do you mind checking why thesame approach is not working for me: http://stackoverflow.com/questions/27209549/ember-cli-deployment-with-rails-on-heroku. thanks – brg Nov 30 '14 at 19:29
4

I'm planning on doing it and I found this:

http://blog.abuiles.com/blog/2014/07/08/lightning-fast-deployments-with-rails/

eXa
  • 618
  • 8
  • 18
  • Hi! Thanks for your answer. I had seen that. However it requires an S3 storage (from which you retrieve your emberjs minified files). I want to push a change up to heroku as soon as I change and commit something to either in rails or ember side. – vasilakisfil Aug 18 '14 at 08:13
  • 3
    Then you could try his first idea: http://blog.abuiles.com/blog/2014/05/21/deploying-ember-cli-and-rails-to-heroku/ – eXa Aug 18 '14 at 09:37
0

https://github.com/tonycoco/heroku-buildpack-ember-cli for your Ember CLI application, and the standard Rails app deploy for the Rails app.

tonycoco
  • 531
  • 7
  • 9
  • I really like your buildpack @tonycoco, but wouldn't this mean running two dynos? Potentially not a bad thing for controlling scalability, but also introduces cost. – Zac Charles Feb 04 '16 at 21:56