Skip to content

Instantly share code, notes, and snippets.

@giusepped
Last active January 9, 2018 20:26
Show Gist options
  • Select an option

  • Save giusepped/a7196e3ec7b0946b9121 to your computer and use it in GitHub Desktop.

Select an option

Save giusepped/a7196e3ec7b0946b9121 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, require your server and tell it to run your server:
require_relative 'app.rb'

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

    ALSO index.html needs to be in public folder

  • Now inside your app.rb, update your '/' root to render your html page

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 examplename

  • 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 examplename

@Mattia46
Copy link

Mattia46 commented Dec 3, 2015

Ciao Giuseppe,
grazie mille della guida. Molto utile.
L'unica cosa che aggiungerei sono il login in Heroku e di aggiungere il 'do' nel secondo get '/' dell'app.rb

Complimenti ;-)

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