| 149c100 by Fabio Akita at 2009-01-07 |
1 |
=== UNDERSTANDING GITORIOUS === |
|
2 |
|
|
3 |
One of the main challenges in Gitorious is its installation process. It is |
|
4 |
anything but trivial. |
|
5 |
|
|
6 |
The main piece is a plain vanilla Ruby on Rails web application, and this is |
|
7 |
the easiest part. |
|
8 |
|
|
9 |
The purpose of the web front-end is to concentrate all Git projects in an easy |
|
10 |
to manage user interface, which also makes it easy to make clones, send merge |
|
11 |
requests, manage committers and participate through comments in the website |
|
12 |
itself. The user interface also provides a nice visualization of the commit log |
|
13 |
and the source tree. So this is a high quality website for Git project management. |
|
14 |
|
|
15 |
It can be used for any number of Git workflows. It is easier to create a |
|
16 |
Centralized Workflow model, where you have one central Git repository and many |
|
17 |
committers added to it, as well as the Integration Workflow, where you have a |
|
18 |
"mainline" repository. Other developers can clone from it, keep pushing commits |
|
19 |
in their own cloned repositories and once they're done with some feature, they can |
|
20 |
easily send a merge request back to the maintainer of the original mainline. |
|
21 |
|
|
22 |
Take a look at Scott Chacon's explanation on these workflows: |
|
23 |
http://www.whygitisbetterthanx.com/#any-workflow |
|
24 |
|
|
25 |
== THE MAIN PIECES == |
|
26 |
|
|
27 |
For all of this to work, we need more than a front-end web application. There are |
|
28 |
backend pieces that we will have to understand and deal with. |
|
29 |
|
|
30 |
I'll make a general explanation of the architecture and then you will find |
|
31 |
specific procedures at: |
|
32 |
|
|
33 |
* doc/recipes/install-centos.txt |
|
34 |
* doc/recipes/install-ubuntu.txt |
|
35 |
|
|
36 |
First of all, we need Git installed in the machine. We also need a MySQL database |
|
37 |
where the project metadata is stored. |
|
38 |
|
|
39 |
All non-web operations goes through SSH, so we need that installed too. More |
|
40 |
than that, Gitorious was kind of inspired by an older project called Gitosis. It |
|
41 |
has a clever idea on which there is one local user (usually called "git"). And |
|
42 |
every developer from any project use this same user. |
|
43 |
|
|
44 |
That's how you clone a remote repository from what's called your "Push URL": |
|
45 |
|
|
46 |
git clone git@gitorious.org/gitorious/mainline.git |
|
47 |
|
|
48 |
It is very similar as operating over an SSH URL: |
|
49 |
|
| 055d821 by Marc Guenther at 2010-05-06 |
50 |
git clone ssh://git@gitorious.org/~gitorious/mainline.git |
| 149c100 by Fabio Akita at 2009-01-07 |
51 |
|
|
52 |
And that's exactly what happens. Let's break it down: |
|
53 |
|
|
54 |
* git - is the 'special' user on the server |
|
55 |
* gitorious.org - is the server itself, which needs to have |
|
56 |
* ~ - (tilde) as all Unix users will know, it is the alias for the home |
|
57 |
directory, in this case it means "/home/git" |
|
58 |
* gitorious - is the project directory under the home directory of the user git. |
|
59 |
And the neat thing about this is that every clone of the mainline |
|
60 |
repository goes under this umbrella directory. |
|
61 |
* mainline.git - is the git repository directory under the project. |
|
62 |
|
|
63 |
But it would be odd if everybody had permission to login under the same username: |
|
64 |
anyone could mess around any project's directories. But the advantage of using SSH is |
|
65 |
that it is flexible enough to provide an infrastructure to disallow such a thing. |
|
66 |
|
|
67 |
As a technical detail, whenever you log in either using a normal ssh client or the git |
|
68 |
command line, it will read its local .ssh/authorized_keys file. Inside it you will find |
|
69 |
something similar to this: |
|
70 |
|
|
71 |
### START KEY 1 ### |
|
72 |
command="gitorious akitaonrails",no-port-forwarding,no-X11-forwarding, |
|
73 |
no-agent-forwarding,no-pty ssh-rsa AAAAB...MCay0w== fabioakita@MacHal9001.local |
|
74 |
### END KEY 1 ### |
|
75 |
|
|
76 |
I cut off the big ssh key for brevity. So whenever you try to login through ssh, you will |
|
77 |
have your public key transferred and compared to those in this file. This allow for the |
|
78 |
SSH server to find your entry and therefore, which 'command' it should run. Then it will |
|
79 |
execute 'gitorious [your_login]' and it will check with the website's data if you do or |
|
80 |
do not have access to the project you want to (it passes the SSH arguments through to the |
|
81 |
gitorious command as well). That's how it determines your identity and your permissions |
|
82 |
regardless of everybody logging into the same local user account (ex. 'git'). |
|
83 |
|
|
84 |
You do all this through what's called a "Push URL", meaning that you only use it if you |
|
85 |
have permission to push your changes back to the repository (you're either the owner of |
|
86 |
the project or someone added you as a committer). |
|
87 |
|
|
88 |
If you don't have push permission, you will only see a "Public Clone URL" that resembles |
|
89 |
this one: |
|
90 |
|
|
91 |
git clone git://gitorious.org/gitorious/gitorious.git |
|
92 |
|
|
93 |
Instead of going through the SSH port, this one will connect to port 9418 of your server |
|
94 |
(if you have firewalls up, be sure to have this port open). |
|
95 |
|
|
96 |
If there is an open port, there is a daemons. The Gitorious project also give your what's |
|
97 |
called the "git-daemon" which keeps running and listening to this port. It allows for |
|
98 |
the git command to clone the remote repository but not to push stuff back. This is good |
|
99 |
for read-only scenarios. |
|
100 |
|
|
101 |
== ASYNCHRONOUS OPERATIONS == |
|
102 |
|
|
103 |
Whenever you: |
|
104 |
|
|
105 |
* Add a new ssh key to your account |
|
106 |
* Create a new project |
|
107 |
* Clone an existing project |
|
108 |
|
|
109 |
Nothing will happen. Until you manually run the script/task_notifier task inside your |
|
110 |
website's directory. This script will see what's queued and run those tasks. It would |
|
111 |
be too time consuming to stay inside a Controller's Action, so they were correctly |
|
112 |
detached into an asynchronous process that will run when it can. Usually people set it |
|
113 |
up as a Cron Job. |
|
114 |
|
|
115 |
These kinds of actions triggers notifications to the users, so e-mails are sent through |
|
116 |
plain vanilla sendmail as well. |
|
117 |
|
|
118 |
So that covers the main pieces. |
|
119 |
|
|
120 |
== OPTIONAL PIECES == |
|
121 |
|
|
122 |
The website provides a search functionality that depends on Sphinx and the Ultrasphinx |
|
123 |
plugin for Rails. It is way smarter than a plain "LIKE" operator from SQL, but it |
|
124 |
requires a living daemon and a task. |
|
125 |
|
|
126 |
So you will need another daemon for Sphinx and you will also need another Cron Job |
|
127 |
for Ultrasphinx's task that rebuilds the index to reflect recent changes. Those are |
|
128 |
optional if you don't want or don't need the search functionality. |
|
129 |
|
|
130 |
There is another task called script/graph_generator which depends on the Gruff and |
|
131 |
RMagick rubygems as well as the native ImageMagick library. It generates a nice |
|
132 |
graph on commits frequency through the days. When you run it, it will generate a |
|
133 |
PNG static image. If you don't run it, Gitorious will simply ignore it. It is very |
|
134 |
cumbersome to make this component work correctly. |
|
135 |
|
| 73c0991 by Fabio Akita at 2009-01-09 |
136 |
== PRIVATE MODE == |
|
137 |
|
|
138 |
The original intent of Gitorious is for an open source public website where every |
|
139 |
project is open to the public. |
|
140 |
|
|
141 |
But as Gitorious itself is an open source project, people can choose to have their |
|
142 |
own installation (as you will, as you're reading this documentation). |
|
143 |
|
|
144 |
Sometimes people want to install their own private Gitorious in a VPS server. And |
|
145 |
then host their company's internal projects, for example. But in this scenario, their |
|
146 |
private Gitorious would be publicly exposed to the Internet. |
|
147 |
|
|
148 |
Now you can change your config/gitorious.yml file and change this: |
|
149 |
|
| 36d031e by Johan Sørensen at 2009-01-09 |
150 |
public_mode: false |
| 73c0991 by Fabio Akita at 2009-01-09 |
151 |
|
|
152 |
The default mode is 'true', which make your Gitorious public. But if you want your |
|
153 |
own private server, change it to 'false'. |
|
154 |
|
|
155 |
In private mode, the 'Register' page is also locked and you need to create a super |
|
156 |
user manually. Do this in the server running the task 'script/create_admin'. It will |
|
157 |
ask for the administrator's email and password and will create it for you. |
|
158 |
|
| 149c100 by Fabio Akita at 2009-01-07 |
159 |
== SUMMARY == |
|
160 |
|
|
161 |
So, the shopping list goes like this: |
|
162 |
|
|
163 |
* install several operating system components, including Git and SSH |
|
164 |
* set up a 'git' (or whatever other login name) local account |
|
165 |
* install the Gitorious Rails-based website |
|
166 |
* set up the git-daemon |
|
167 |
* set up the sphinx daemon |
|
168 |
* set up the task_notifier cron job |
|
169 |
* set up the ultrasphinx cron job |
|
170 |
* set up the graph_generator cron job |
|
171 |
|