DEPLOYING YOUR ANGULAR/SINATRA APP ON HEROKU
-
$ mkdir publiccreate 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.rbthis is going to be your sinatra server
require 'sinatra'
get '/' do
end$ touch config.rucreate your config.ru file, require your server and tell it to run your server:
require_relative 'app.rb'
run Sinatra::Application
-
all the
script srcreferences 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 .bowerrcand 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
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 ;-)