2008 July 9th
Unless you have been sleeping under a rock, which I hear is good for your health, you have come to hear about Git. Originally created by Linus Torvalds, Git is an open source version control system that has quickly gained a lot of traction with Rails developers. This could be credited to the great Github, but I think it is because of Git’s feature set. Visit the official Git Website to learn more.
At $20 a month Media-Temples Grid-Service is an incredible bargain. I make extensive use of all of it features, including the recently added ability to host Git repositories. What follows is a tutorial on how to host your Git repositories on Media Temple’s Grid-Service from Mac OS Leopard.
Prerequisites
- Git 1.5.6.2
- Mac OS X Leopard
- Terminal Skills
There are binaries available for installing Git on Mac OS X. Visit the git-osx-installer project on Google Code.
Domain
In order to be able to clone your repositories from the Grid over HTTP you need to create a domain specifically for Git. You can setup git.domain.com, but any domain will do. Remember to setup the domain in your Grid account. Without this you will only be able to clone Git repositories over ssh which is a pain.
The project
We are going to setup an example project called icecream-man. Change into a directory that is safe to work in and let's get to it. If you already have a Git project setup you can skip this section.
# This is where I keep all of my projects
cd Sites/
mkdir icecream-man
cd icecream-man
git init
touch .gitignore
git status
git add .
git commit -v -a
Attack of the Clones
Before we can push our local Git repositories to the Grid we have to create a bare clone. A short aside about what git means by bare: A default git repository assumes that you’ll be using it as your working directory, so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don’t need copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what “bare” means to git. Just the repository itself.1
cd Sites/
git clone --bare icecream-man icecream-man.git
touch icecream-man.git/git-daemon-export-ok
Upload the repository
To get the project on our Grid I use scp, but you could just as easily FTP the icecream-man.git directory into your Grid account.
scp -r icecream-man.git serveradmin%s#####.gridserver.com@s#####.gridserver.com:domains/git.domain.com/html/icecream-man.git
Now we have to ssh into our Grid account and finalize the setup.
ssh serveradmin%s#####.gridserver.com@s#####.gridserver.com
cd domains/git.domain.com/html/icecream-man.git
git --bare update-server-info
chmod a+x hooks/post-update
Pulling
Now we are ready to clone our Git repository from our Grid account. We are able to clone using a pretty URL thanks to our Git specific domain. Yeah!
git clone http://git.domain.com/icecream-man.git
Pushing
Once you have made some local commits that you want to push to the Grid you can use this command:
git push ssh://serveradmin%s#####.gridserver.com@s#####.gridserver.com/home/#####/domains/git.domain.com/html/icecream-man.git master
Here is what I do so that I do not have to type in that long command every time I want to push my changes to the remote Git repository. Git allows for each project to have multiple tracked repositories. Since we cloned our project from “http://git.domain.com/icecream-man.git” Git thinks it can push there to. Let's add another remote repository and tell Git to push our changes there.
cd Sites/icecream-man/
git remote add grid ssh://serveradmin%s#####.gridserver.com@s#####.gridserver.com/home/#####/domains/git.domain.com/html/icecream-man.git
Now we can push changes to our Grid account using “git push grid master“. Git knows that the remote reposotory named “grid” corresponds to the Grid's push URL. Much better, I know. We can take this even further and create an alias for the command in our “.bash_login” file. To view the available remote locations type “git remote” from inside the project directory. Then you can view the details of a remote repository by typing “git remote show grid“. I use this very heavily, and am successfully hosting six active Git repositories on my Grid account. Without this tiny shortcut I do not think I would be able to do it, and I would be GitHub bound.
References
2007 November 18th
At $20 a month, Media Temple’s Grid-Service is an incredible bargain. I recently broke up with Django and decided to move my work back to Ruby on Rails. What follows is another tentative guide to installing Mephisto on Media Temple’s Grid Service.
First things first
Enable Rails container
- Log in to your (mt) account center and select your primary domain.
- Click into the ‘(gs) GridContainers’ section.
- Click the ‘manage’ link for the Rails GridContainer.
- Click ‘Enable Container’.
*Note:* You will need about 45 MB of ram dedicated to Mephisto.
Create the database
- Click into the ‘Manage Databases’ section.
- Click the ‘Add A Database’ tab.
- Give your database a name and select a database type.
- Click ‘Next’
Setting up Ruby on Rails
ssh serveradmin%domain.com@domain.com **OS X Terminal
serveradmin@domain.com **Windows
mtr generate_config **serveradmin@domain.com and password
mtr setup_rubygems
source ~/.bash_profile
gem install rails -y
gem install mysql --source=http://gems.mediatemple.net
gem install postgres --source=http://gems.mediatemple.net\r\ngem install daemons gem_plugin -y
gem install mongrel --source=http://gems.mediatemple.net
Install Mephisto
cd $HOME/../../containers
mkdir rails && cd rails
svn co -r 2920 http://svn.techno-weenie.net/projects/mephisto/trunk mephisto
cd mephisto
gem install tzinfo --remote
cp config/database.example.yml config/database.yml
Note: Here we checkout revision 2920 instead of the head. 2920 is the latest revision of Mephisto to work without rails edge, although the 0.7.3 release was revision 2501.
Initialize Mephisto
rake db:bootstrap RAILS_ENV=production
mtr add mephisto $PWD domain.com
mtr start mephisto
mtr generate_htaccess mephisto
mtr create_link mephisto domain.com
Note: We do not have to manually create the log directory. It is automatically created when we rake the db.
That’’s it! Now visit yourdomain.com to see our result.
References
This blog was installed using the steps outlined in this guide.
2007 October 28th
Using Subversion on the Media Temple Grid-Service is much easier than it seems. Actually, it is easier than my previous host.
Setup the repository
ssh serveradmin%domain.com@domain.com **OS X
Terminalserveradmin@domain.com **Windows
cd data
mkdir svn && cd svn
svnadmin create --fs-type fsfs reponame
Initial import
On your local machine.
mkdir reponame && cd reponame
mkdir trunk
mkdir tags
mkdir branches
svn import . svn+ssh://serveradmin%domain.com@s#####.gridserver.com/home/#####/data/svn/reponame/ -m "Initial import"
Checking out
Now that we have our subversion repository setup and our code checked in, we should check out a copy for development.
svn co svn+ssh://serveradmin%domain.com@s#####.gridserver.com/home/#####/data/svn/reponame/trunk reponame
Deployment
If you are going to deploy your website from a local subversion repository.
ssh serveradmin%domain.com@domain.com **OS X Terminalserveradmin@domain.com **Windows
cd domains
cd domain.com
mv html html-2
svn co file:///home/#####/data/svn/reponame/trunk html
That does it. Rinse and repeat as needed.
References
2007 October 17th
What follows is a tentative guide to installing Beast, a forum application written in Ruby on Rails, on Media Temple Grid-Service.
First things first
Enable Rails container
- Log in to your (mt) account center and select your primary domain.
- Click into the “(gs) GridContainers” section.
- Click the “manage” link for the Rails GridContainer.
- Click “Enable Container”.
Note: You will need about 35 MB of ram for Beast.
Create database
- Click into the “Manage Databases” section.
- Click the “Add A Database” tab.
- Give your database a name and select a database type.
- Click “Next”
Setup email
You must have a beast@domain.com user setup for sending activation emails.
Setting up Ruby on Rails
ssh serveradmin%domain.com@domain.com **OS X Terminal
serveradmin@domain.com **Windows
mtr generate_config **serveradmin@domain.com and password
mtr setup_rubygemssource ~/.bash_profile
gem install rails -y
gem install mysql --source=http://gems.mediatemple.net
gem install postgres --source=http://gems.mediatemple.net
gem install daemons gem_plugin -y
gem install mongrel --source=http://gems.mediatemple.net
Installing the Beast
cd $HOME/../../containers
mkdir rails && cd rails
svn co -r 2873 http://svn.techno-weenie.net/projects/beast/trunk beast
cd beast
gem install RedCloth
gem install ruby-openid
cp config/database.example.yml config/database.yml
Note: Instead of installing beast from the stable 1.0 branch we checkout revision 2873 from the trunk. This way we can update to stable versions of the trunk without having to worry about merging branches. Stable 1.0 is actually revision 2907, but I have not been able to install it successfully.
Edit database.yml
production:
adapter: mysql
database: db#####_beast_production
username: db#####
password: xxxxxxx
host: internal-db.s#####.gridserver.com
Edit environment.rb
Add your email settings to the end of the ‘beast/config/environment.rb’ file.
# email settings
ActionMailer::Base.smtp_settings = {
:address => "mail.domain.com",
:port => 25,
:domain => "domain.com",
:authentication => :login,
:user_name => "beast@domain.com",
:password => "xxxxxxx"
}
Initialize Beast
rake db:schema:load RAILS_ENV=production
mtr add beast $PWD domain.com
mtr start beast
mtr generate_htaccess beast
mtr create_link beast domain.com
References
You can now see a working example by visiting http://yourdomain.com.