This has got to be one of the most thoroughly researched and comprehensive Screencast produced by Ryan and he shines.
Nico Ritsche has a great point though. As one lone developer working on a big project (relatively speaking of course), I can simply rely on Heorku to do all my sys admin work and focus on the development. The Developer's docs are also of a high quality and very helpful.
There are 2/3 differents concept in your comment :
CSS precompilers, like SASS or LESS, which add scaffolding, variables and mixins
mixins libraries that simplifies some tasks like CSS3 vendor prefixes, like Bourbon or Compass
frameworks that offer a base structure to your project, a "bootstrap"
Twitter Bootstrap for example uses Less by default, but there are fork that works with Sass.
Blueprint is also available as a Compass module : if you import compass/sass, you get a whole lot of mixin to generate blueprint css that suits your need. You can also make a fluid grid layout with these, just like with Twitter Bootstrap.
I love Sass/Compass, and I am currently trying Twitter Bootstrap on a project.
I would double check that /home/deployer/projects/blog is actually a git repo like the error says.
When creating the repo on the server I usually name the directory #{app_name}.git for clarity, then you need git init --bare to make sure the there is no working directory just the repo.
For some reason I'm getting this while doing a cold deploy, deploy:setup succeeds however, the repo is on the same server. Tried referencing it through the full ssh url or by giving a local absolute url, no avail.
shell
$ cap deploy:cold
* executing `deploy:cold'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote /home/deployer/projects/blog master"
fatal: '/home/deployer/projects/blog' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deployer/apps/blog/releases/20120322194319; true"
servers: ["192.168.1.49"]
[192.168.1.49] executing command
[192.168.1.49] sh -c 'rm -rf /home/deployer/apps/blog/releases/20120322194319; true'
command finished in 186ms
Command git ls-remote /home/deployer/projects/blog master returned status code pid 9997 exit 128
You have to understand the rationale behind each of these tools in order to understand if some of them can fit your needs.
Right now Compass gives you the ability to start from the ground up whereas Twitter Bootstrap is an excellent head start for rapid prototyping.
As Ryan pointed out, Bourbon provides a subset of Compass features.
Finally, Blueprint is a grid system that can be applied on top of Compass, but I suggest you to take a look at Susy instead if you need one.
Linode is less secure by default until you do some configuration changes when you get the box -- it comes very unsecure -- Ryan didn't go into it in the screencast (probably for the purposes of time) but you should lock down your VPS root access and only really sudo up to it from another user. Changing your SSH port and turning off password authentication can help too. Also setting up a firewall (even just ufw) will help lock it further down. You may also want to add some blacklisting software to handle multiple login attempts.
As for Heroku it's a great solution that makes scaling very very easy. The only problem I've had with it is you tend to have to bend off backwards at times to get things working (asset pipeline issues among other things) and you will bump into issues with some gems needing to be configured differently. It's also much pricier relative to using a solution such as Linode.
It does have free plans, however, so you should really try it out and see if you like the workflow. You pretty much make a local git repository for it (or just add another remote host to an existing) and push to it. It handles bundling, getting the server up and running, etc. You can even set environmental variables directly from the command prompt for the server using: heroku config:add KEY_NAME=value
Short answer: Heroku handles all that configuration for you since you don't get root access.
Personally I'm confused about all these CSS "frameworks"/tools, everyone has something useful, Compass is good for the sprite facility and the CSS3 functions to generate all the browser-specific rules, Bourbon has a similar functionality, there is also Blueprint and Twitter Bootstrap (it's fashion these days as David already said). A thing I like of Bootstrap is the way it can help your site to adapt to mobile devices (try to visit its website and resize the browser window).
...some of these features can help for sure but my mind is exploding with all these choices...
Ryan, Thanks a million (yet again) I've used this method in a few apps it really adds a useful and dynamic feature.
I'm using it in one case to allow users to sort names. It's working fine but I'd like to add a bit more to it in that I'd like to style the Number 1 name differently. This is easy for me to do on page refresh but it'd be smashing if the Name in question got styled dynamically as it was dragged to the top of the list by the user i.e. without the user pressing F5 or CMD+R, depending on your religon!
Most rails applications have more dependencies, like a sphinx server for example. How would you go about launching these (e.g. in case of a server restart)?
Can something like Foreman be used for this task?
I've used three different VPS solutions and each are pretty good. They all provide different features for their price points as well.
ChicagoVPS - They offer a few solutions which are reasonably priced. OS options are somewhat limited. I'm pretty sure you're locked into CentOS 5.
ChunkHost - ChunkHost is slightly more expensive, but offers more options. OS options available are: Ubuntu (8.04 LTS, 10.04 LTS, 10.10), Debian (lenny, squeeze), and CentOS (5, 6). They're offering a free VPS for a limited time as a "beta test." Good for testing.
Linode - Linode is my ol' standard. I've used them for years and have never been disappointed. They offer several solutions and have quite a few features that the others don't have. They also offer flexibility with your Linode (add more storage or an extra IP instantly). OS options available are pretty much anything you can think of. Each option available also comes in a 64-bit flavor if that's your preference (or requirement).
I'm just glad the term "bootstrap" was not included anywhere in this video. Seems that's become such a buzz word as of late. Great episode Ryan! As Trung said, the sprite aspect is pretty slick.
Hey Ryan, at the end when talking about Compass Reset and Normalize you mentioned that trying to make all browsers consistent isn't necessarily required for every website.
I agree with you that it's not necessary to have your site look exactly the same, down to the pixel, across browsers. I've had to convince designers that trying to achieve that is a waste of time. But still, do you ever find yourself sometimes wishing your spacing were a little more consistent on different browsers because you didn't always start by normalizing the CSS? And then wasting some time fixing up the differences introduced by normalizing later?
Keep up the good work. The pro episode you mentioned about deploying, nginx, Unicorn, etc. looks like it could be really useful.
Great screencast, Ryan! I'm comfortable setting servers and, over time, I have created my own system to it but I'm always learning and some of your techniques might be added to my workflow… :)
Question: I always add an nginx conf file for the domain I'm hosting. You simply deleted the default. How does deleting a default automatically make it load the application from the deployer's home directory? Magic sauce there? :)
I keep pushing this farther. I have the multiple token fields on one page working now.
Now I'm trying to come up with a way to set additional data. For example, when I set a unit token, I also want to set a boolean true. And when I remove the unit - I want to set that boolean to false.
I see there are some callbacks that can be used - but I'm uncertain how I can impact my database from there.
I WISH I knew about this when I wrote my first API. I overrode to_json in all my models and WOW this would be so much better. Thanks for the awesome screencast.
Sindre, I followed Ryan's advice: renamed app.css to app.css.scss, @import'ed bourbon and all other .css.scss files, and stripped out the Sprockets stuff from app.css.
All works great in Dev. When I deploy (to heroku cedar) I get an 'unrecognized mixin' in any file that calls a mixin other than app.css.scss (where I have the @import bourbon line). The only thing that solves it is doing another @import bourbon in every files that calls a mix-in. Why do i have to duplicate that import call?
+1
This has got to be one of the most thoroughly researched and comprehensive Screencast produced by Ryan and he shines.
Nico Ritsche has a great point though. As one lone developer working on a big project (relatively speaking of course), I can simply rely on Heorku to do all my sys admin work and focus on the development. The Developer's docs are also of a high quality and very helpful.
Perhaps Ryan can do one screencast on Heroku?
So for my use case would you recommend a VPS over something like Heroku or EngineYard?
I prefer Heroku, so I can focus on development not setting up and maintaining servers. ;-)
Thanks JP - I was using this:
RAILS_ENV=production bundle exec rails c
but your is much easier to type :)
In the rails app directory should be able to run
To access a ruby console on the production db
Thanks for the information, will definitely look into the linode security tips!
Once you're ssh'd in you should just be able run irb at the command prompt.
There are 2/3 differents concept in your comment :
Twitter Bootstrap for example uses Less by default, but there are fork that works with Sass.
Blueprint is also available as a Compass module : if you import compass/sass, you get a whole lot of mixin to generate blueprint css that suits your need. You can also make a fluid grid layout with these, just like with Twitter Bootstrap.
I love Sass/Compass, and I am currently trying Twitter Bootstrap on a project.
Anybody know how to fire up the ruby console in the linode?
Hey Guys,
Ryan helped me figure this out...I was having issues installing mysql, so I had to manually install the gem:
apt-get install libmysqlclient-dev
then I changed the mysql socket in database.yml to:
/var/run/mysqld/mysqld.sock
Hope that helps anybody who runs into this issue.
Excellent!! as usual...
Would like contribute a little tweek to this with installing gems on production.
create a gemrc (touch ~/.gemrc)
and then copy paste this to avoid fetching the gem docs on install, update and sources, plus some other defualts i use.
With #334, I figured out, that I have used the »compass« and not the »compass-rails« gem...
So far, the
@import 'icons/*.png'
had always failed... Now I know better ;-)Im getting this error with deploy:cold..any ideas?
failed: "sh -c 'cd /home/deployer/apps/burden_farming/releases/20120322200251 && bundle install --gemfile /home/deployer/apps/burden_farming/releases/20120322200251/Gemfile --path /home/deployer/apps/burden_farming/shared/bundle --deployment --quiet --without development test'" on 74.207.240.214
I would double check that /home/deployer/projects/blog is actually a git repo like the error says.
When creating the repo on the server I usually name the directory #{app_name}.git for clarity, then you need
git init --bare
to make sure the there is no working directory just the repo.The key is to use foreman to export the proper config for your server http://ddollar.github.com/foreman/#UPSTART-EXPORT
For some reason I'm getting this while doing a cold deploy, deploy:setup succeeds however, the repo is on the same server. Tried referencing it through the full ssh url or by giving a local absolute url, no avail.
You have to understand the rationale behind each of these tools in order to understand if some of them can fit your needs.
Right now Compass gives you the ability to start from the ground up whereas Twitter Bootstrap is an excellent head start for rapid prototyping.
As Ryan pointed out, Bourbon provides a subset of Compass features.
Finally, Blueprint is a grid system that can be applied on top of Compass, but I suggest you to take a look at Susy instead if you need one.
Linode is less secure by default until you do some configuration changes when you get the box -- it comes very unsecure -- Ryan didn't go into it in the screencast (probably for the purposes of time) but you should lock down your VPS root access and only really sudo up to it from another user. Changing your SSH port and turning off password authentication can help too. Also setting up a firewall (even just ufw) will help lock it further down. You may also want to add some blacklisting software to handle multiple login attempts.
http://library.linode.com/security/basics
I'd follow those steps when setting up.
As for Heroku it's a great solution that makes scaling very very easy. The only problem I've had with it is you tend to have to bend off backwards at times to get things working (asset pipeline issues among other things) and you will bump into issues with some gems needing to be configured differently. It's also much pricier relative to using a solution such as Linode.
It does have free plans, however, so you should really try it out and see if you like the workflow. You pretty much make a local git repository for it (or just add another remote host to an existing) and push to it. It handles bundling, getting the server up and running, etc. You can even set environmental variables directly from the command prompt for the server using: heroku config:add KEY_NAME=value
Short answer: Heroku handles all that configuration for you since you don't get root access.
Personally I'm confused about all these CSS "frameworks"/tools, everyone has something useful, Compass is good for the sprite facility and the CSS3 functions to generate all the browser-specific rules, Bourbon has a similar functionality, there is also Blueprint and Twitter Bootstrap (it's fashion these days as David already said). A thing I like of Bootstrap is the way it can help your site to adapt to mobile devices (try to visit its website and resize the browser window).
...some of these features can help for sure but my mind is exploding with all these choices...
What are some security concerns for VPS (linode) vs managed solution (heroku)?
I've been using Slicehost for a few years
this articles helped me a lot: articles.slicehost.com
I've never commented here before, but felt like this episode was worth the comment.
Fantastic. I wish this had been done weeks ago prior to my deployment headaches.
Lastly, I've been a fan of the railsready script found here: https://github.com/joshfng/railsready
If Linode is your thing another quick way to setup a VPS is to use a StackScript.
http://www.linode.com/stackscripts/view/?StackScriptID=1291
Includes:
*Rails 3
*Ruby 1.9.2
*Nginx with Passenger
*MySQL
*git
*Updates rubygems
*Install rails 3
*Install mysql gem
*Add deploy user
Nice work again Ryan but would love a full cast on deployment.
Ryan, Thanks a million (yet again) I've used this method in a few apps it really adds a useful and dynamic feature.
I'm using it in one case to allow users to sort names. It's working fine but I'd like to add a bit more to it in that I'd like to style the Number 1 name differently. This is easy for me to do on page refresh but it'd be smashing if the Name in question got styled dynamically as it was dragged to the top of the list by the user i.e. without the user pressing F5 or CMD+R, depending on your religon!
+1 for this. I've found it's sometimes tough remembering when to restart the server. Helped me out quite a bit.
As an aside, I feel it's absolutely important when creating any sorts of instructions for people that no steps be left out.
(Always assume the lowest level of experience.)
Most rails applications have more dependencies, like a sphinx server for example. How would you go about launching these (e.g. in case of a server restart)?
Can something like Foreman be used for this task?
I've used three different VPS solutions and each are pretty good. They all provide different features for their price points as well.
ChicagoVPS - They offer a few solutions which are reasonably priced. OS options are somewhat limited. I'm pretty sure you're locked into CentOS 5.
ChunkHost - ChunkHost is slightly more expensive, but offers more options. OS options available are: Ubuntu (8.04 LTS, 10.04 LTS, 10.10), Debian (lenny, squeeze), and CentOS (5, 6). They're offering a free VPS for a limited time as a "beta test." Good for testing.
Linode - Linode is my ol' standard. I've used them for years and have never been disappointed. They offer several solutions and have quite a few features that the others don't have. They also offer flexibility with your Linode (add more storage or an extra IP instantly). OS options available are pretty much anything you can think of. Each option available also comes in a 64-bit flavor if that's your preference (or requirement).
I'm just glad the term "bootstrap" was not included anywhere in this video. Seems that's become such a buzz word as of late. Great episode Ryan! As Trung said, the sprite aspect is pretty slick.
Thanks Ryan, the sprite trick is very handy.
tail -f log/development.log
You just have to put the following lines at the top of your features/support/env.rb:
require 'simplecov'
SimpleCov.start 'rails'
Okay, so I'm developing a web app that's going to have around 600 users - creating about 1500 records a day.
After watching this I'm tempted to check out a VPS, but I've only got experience deploying with Heroku ( <- total n00b ).
For my use case, would you recommend a VPS (such as Linode) or Heroku?
+1
Superb cast.
For older Rails version:
---- View
Thanks! Really useful. Didn't know about it.
That's easy command, and can be found on OS X by homebrew as well
brew install ssh-copy-id
Yep, you just need to do things a little differently when initially ssh'ing/setting up your keys
I wonder if this could apply to services like EC2.
in Linux,instead of using:
cat ~/.ssh/id_rsa.pub | ssh user@host 'cat >> ~/.ssh/authorized_keys'
i prefer to use:
ssh-copy-id user@host
Thanks Ryan, this is superb.
Reassuring to see that it's pretty similar to what I bodged together after watching your Vagrant/Unicorn screencasts https://gist.github.com/1985879
AWESOME! Gotta get that going on my systems… :o <3
Thanks man :)
The capistrano recipe symlinks it to
/etc/nginx/sites-enabled/
Hey Ryan, at the end when talking about Compass Reset and Normalize you mentioned that trying to make all browsers consistent isn't necessarily required for every website.
I agree with you that it's not necessary to have your site look exactly the same, down to the pixel, across browsers. I've had to convince designers that trying to achieve that is a waste of time. But still, do you ever find yourself sometimes wishing your spacing were a little more consistent on different browsers because you didn't always start by normalizing the CSS? And then wasting some time fixing up the differences introduced by normalizing later?
Keep up the good work. The pro episode you mentioned about deploying, nginx, Unicorn, etc. looks like it could be really useful.
Great screencast, Ryan! I'm comfortable setting servers and, over time, I have created my own system to it but I'm always learning and some of your techniques might be added to my workflow… :)
Question: I always add an nginx conf file for the domain I'm hosting. You simply deleted the default. How does deleting a default automatically make it load the application from the deployer's home directory? Magic sauce there? :)
I keep pushing this farther. I have the multiple token fields on one page working now.
Now I'm trying to come up with a way to set additional data. For example, when I set a unit token, I also want to set a boolean true. And when I remove the unit - I want to set that boolean to false.
I see there are some callbacks that can be used - but I'm uncertain how I can impact my database from there.
Anyone do this sort of thing?
this is a good read on the subject, thanks for posting!
I WISH I knew about this when I wrote my first API. I overrode to_json in all my models and WOW this would be so much better. Thanks for the awesome screencast.
Simple and useful.
Only feedback is that the products/index.js.erb in show notes is missing the sleep call.
Sindre, I followed Ryan's advice: renamed app.css to app.css.scss, @import'ed bourbon and all other .css.scss files, and stripped out the Sprockets stuff from app.css.
All works great in Dev. When I deploy (to heroku cedar) I get an 'unrecognized mixin' in any file that calls a mixin other than app.css.scss (where I have the @import bourbon line). The only thing that solves it is doing another @import bourbon in every files that calls a mix-in. Why do i have to duplicate that import call?