Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save christopheralcock/0d52c0ab37827e2a5f79 to your computer and use it in GitHub Desktop.

Select an option

Save christopheralcock/0d52c0ab37827e2a5f79 to your computer and use it in GitHub Desktop.
Deploying your angular/sinatra app on heroku

DEPLOYING YOUR ANGULAR/SINATRA APP ON HEROKU

  • $ mkdir public create a public folder

  • $ mv bower_components public/bower_components (don't forget to change the gitignore file!!) you need to move your bower components to the public

  • folder and also any stylesheets or anything you will want to require in your http.

  • Create Gemfile

source 'https://rubygems.org'

gem 'sinatra'
  • $ bundle
  • $ touch app.rb this is going to be your sinatra server
require 'sinatra'

get '/' do

end
  • $ touch config.ru create your config.ru file and insert the following:
require_relative 'app.rb'

run Sinatra::Application
  • all the script src remain the same BUT don't forget to also move js inside Public and EVERYTHING that you might want to require inside your index.html NEEDS to be inside the public folder (don't forget to update the gitignore)

    ALSO index.html needs to be in public folder

  • Now inside your app.rb, update your '/' root

get '/'
  send_file 'public/index.html'
end
  • Don't forget to change the karma.conf.js when it requires the bower and the js files (tests should now be passing)

  • Now create your heroku app $ heroku create --app appname

  • The following line is needed so that your heroku app will use bower: $ heroku config:add "BUILDPACK_URL=git://github.com/qnyp/heroku-buildpack-ruby-bower.git#run-bower" (NB the quotes are for zsh, you do not need them if you use bash)

  • $ touch .bowerrc and add the following line: { "directory": "public/bower_components" } (this is because this folder is in your .gitignore file)

  • $ git add . $ git commit -m 'ready to push t0 heroku' $ git push heroku master $ heroku open

NB to destroy a heroku app heroku apps:destroy --app immense-springs-1785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment