Moodle Production Server with GIT

From MoodleDocs
Revision as of 21:32, 10 October 2012 by marc wendt (talk | contribs) (bring some colors)

This is the description of how we maintain our Moodle2 code at TU Berlin. Our Moodle has ca. 30000 active user with around 2000 online user day and night. We have a lot of code changes and plugins, so it's essential for us to maintain the code as automated as possible.

Our Moodle is called ISIS. So further on everything what is named ISIS belongs to us, everything what is called moodle belongs to moodle.org.

We use several GIT-repositories. The scheme with branches looks like this

ISIS GIT schema.png

The main purpose for the ISIS remote repository is for backups. One can imagine a scenario without this remote server only with local repositories involved. If you use gitolite for your remote repository, it's even more comfortable to keep the code clean, because you are able the restrict access to branches for developer and integration manager individually.

The puzzle about the isis_rebase branch will be explained, when we come to a new moodle release.

Install the repositories

We start with the original moodle code. For orientation we suggest to read the very useful description Git_for_Administrators first. Instead of the advise there we won't clone the moodle.org-repository in the first place. We start over with creating an empty repository at the ISIS Integration server.


wendt@integ:~$ mkdir isis
wendt@integ:~$ cd isis/
wendt@integ:~/isis$ git init
Initialized empty Git repository in /home/wendt/isis/.git/
wendt@integ:~/isis$ 


Now we add moodle.org as remote repository.

wendt@integ:~/isis$ git remote add moodle git://git.moodle.org/moodle.git
wendt@integ:~/isis$ git fetch moodle
remote: Counting objects: 597378, done.
remote: Compressing objects: 100% (141938/141938), done.
remote: Total 597378 (delta 442383), reused 597378 (delta 442383)
Receiving objects: 100% (597378/597378), 223.38 MiB | 11.16 MiB/s, done.
Resolving deltas: 100% (442383/442383), done.
From git://git.moodle.org/moodle
 * [new branch]      MOODLE_13_STABLE -> moodle/MOODLE_13_STABLE
 * [new branch]      MOODLE_22_STABLE -> moodle/MOODLE_22_STABLE
.
.
.
 * [new branch]      MOODLE_23_STABLE -> moodle/MOODLE_23_STABLE
 * [new branch]      master     -> moodle/master
 * [new tag]         v1.3.5     -> v1.3.5
.
.
. 
 * [new tag]         v2.3.2     -> v2.3.2
wendt@integ:~/isis$ 


Next we create a local branch of the moodle 2.3 code.

wendt@integ:~/isis$ git branch --track MOODLE_23_STABLE remotes/moodle/MOODLE_23_STABLE
Branch MOODLE_23_STABLE set up to track remote branch MOODLE_23_STABLE from moodle.
wendt@integ:~/isis$ git checkout MOODLE_23_STABLE
Switched to branch 'MOODLE_23_STABLE'
wendt@integ:~/isis$

From this we fork our initial ISIS code.

wendt@integ:~/isis$ git checkout -b isis_contrib
Switched to a new branch 'isis_contrib'
wendt@integ:~/isis$ 


At this point we expect an empty ISIS remote repository, where we can initially push the ISIS code. First we add it as a remote repository to our local git-repository. then we push the isis_contrib branch into the different branches of the remote repository.


wendt@integ:~/isis$ git remote add isis git://isis.remote.tu-berlin.de/isis.git
wendt@integ:~/isis$ git push isis isis_contrib:isis_contrib
Counting objects: 472320, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (117914/117914), done.
Writing objects: 100% (472320/472320), 199.01 MiB | 17.92 MiB/s, done.
Total 472320 (delta 347911), reused 464510 (delta 342938)
To git://isis.remote.tu-berlin.de/isis.git
 * [new branch]      isis_contrib -> isis_contrib
wendt@integ:~/isis$ git push isis isis_contrib:isis_productive
Total 0 (delta 0), reused 0 (delta 0)
To git://isis.remote.tu-berlin.de/isis.git
 * [new branch]      isis_contrib -> isis_productive
wendt@integ:~/isis$ git push isis isis_contrib:isis_rebase
Total 0 (delta 0), reused 0 (delta 0)
To git://isis.remote.tu-berlin.de/isis.git
 * [new branch]      isis_contrib -> isis_rebase
wendt@integ:~/isis$ 

To stay in sync with the remote ISIS repository we track the remote branches to local ones now.

wendt@integ:~/isis$ git branch --track isis_productive remotes/isis/isis_productive
Branch isis_productive set up to track remote branch isis_productive from isis.
wendt@integ:~/isis$ git branch --track isis_rebase  remotes/isis/isis_rebase
Branch isis_rebase set up to track remote branch isis_rebase from isis.
wendt@integ:~/isis$ git checkout isis_contrib
Already on 'isis_contrib'
wendt@integ:~/isis$ git branch --set-upstream remotes/isis/isis_contrib

Now we are ready to bring the code to the productive Server. You can pull the code from the remote ISIS repository, but you will have a lot of overhead this way. So we simply rsync the code to the server.

wendt@bastet:~/isis$ git checkout isis_productive
Switched to branch 'isis_productive'
wendt@integ:~/isis$ cd ..
wendt@integ:~$ rsync -a --delete --exclude=config.php --exclude=.htaccess --exclude=.git/ isis admin@www.isis.tu-berlin.de:/var/www/
admin@www.isis.tu-berlin.de's password: 
wendt@integ:~$ 

This rsync command will reapear later updating the production code as well. At this point you can start using your moodle and follow the install procedure of moodle.