Note: You are currently viewing documentation for Moodle 3.3. Up-to-date documentation for the latest stable version of Moodle is probably available here: Moodle Production Server with GIT.

Moodle Production Server with GIT: Difference between revisions

From MoodleDocs
(Chapter Install the repositories)
 
(bring some colors)
Line 1: Line 1:
== Moodle Production Server with GIT ==
This is the description of how we maintain our Moodle2 code at [http://www.isis.tu-berlin.de/2.0/ 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.
This is the description of how we maintain our Moodle2 code at [http://www.isis.tu-berlin.de/2.0/ 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.


Line 19: Line 16:
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.
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.


<pre>
 
wendt@integ:~$ mkdir isis
<span style="color:#808080">wendt@integ:~$</span> mkdir isis
wendt@integ:~$ cd isis/
<span style="color:#808080">wendt@integ:~$</span> cd isis/
wendt@integ:~/isis$ git init
<span style="color:#808080">wendt@integ:~/isis$</span> git init
Initialized empty Git repository in /home/wendt/isis/.git/
Initialized empty Git repository in /home/wendt/isis/.git/
wendt@integ:~/isis$  
<span style="color:#808080">wendt@integ:~/isis$</span>  
</pre>
 


Now we add moodle.org as remote repository.
Now we add moodle.org as remote repository.


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


* [new tag]        v2.3.2    -> v2.3.2
wendt@integ:~/isis$
</pre>


Next we create a local branch of the moodle 2.3 code.
Next we create a local branch of the moodle 2.3 code.
<pre>
 
wendt@integ:~/isis$ git branch --track MOODLE_23_STABLE remotes/moodle/MOODLE_23_STABLE
<span style="color:#808080">wendt@integ:~/isis$</span> git branch --track <span style="color:#ff0000">MOODLE_23_STABLE</span> <span style="color:#ff0000">remotes/moodle/MOODLE_23_STABLE</span>
Branch MOODLE_23_STABLE set up to track remote branch MOODLE_23_STABLE from moodle.
Branch <span style="color:#ff0000">MOODLE_23_STABLE</span> set up to track remote branch <span style="color:#ff0000">MOODLE_23_STABLE</span> from <span style="color:#008000">moodle</span>.
wendt@integ:~/isis$ git checkout MOODLE_23_STABLE
<span style="color:#808080">wendt@integ:~/isis$</span> git checkout <span style="color:#ff0000">MOODLE_23_STABLE</span>
Switched to branch 'MOODLE_23_STABLE'
Switched to branch '<span style="color:#ff0000">MOODLE_23_STABLE</span>'
wendt@integ:~/isis$
<span style="color:#808080">wendt@integ:~/isis$</span>
</pre>


From this we fork our initial ISIS code.
From this we fork our initial ISIS code.


<pre>
<span style="color:#808080">wendt@integ:~/isis$</span> git checkout -b <span style="color:#ff0000">isis_contrib</span>
wendt@integ:~/isis$ git checkout -b isis_contrib
Switched to a new branch '<span style="color:#ff0000">isis_contrib</span>'
Switched to a new branch 'isis_contrib'
<span style="color:#808080">wendt@integ:~/isis$</span>  
wendt@integ:~/isis$  
 
</pre>


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.
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.


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


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


<pre>
<span style="color:#808080">wendt@integ:~/isis$</span> git branch --track <span style="color:#ff0000">isis_productive</span> <span style="color:#ff0000">remotes/isis/isis_productive</span>
wendt@integ:~/isis$ git branch --track isis_productive remotes/isis/isis_productive
Branch <span style="color:#ff0000">isis_productive</span> set up to track remote branch <span style="color:#ff0000">isis_productive</span> from <span style="color:#008000">isis</span>.
Branch isis_productive set up to track remote branch isis_productive from isis.
<span style="color:#808080">wendt@integ:~/isis$</span> git branch --track <span style="color:#ff0000">isis_rebase</span> <span style="color:#ff0000">remotes/isis/isis_rebase</span>
wendt@integ:~/isis$ git branch --track isis_rebase  remotes/isis/isis_rebase
Branch <span style="color:#ff0000">isis_rebase</span> set up to track remote branch <span style="color:#ff0000">isis_rebase</span> from <span style="color:#008000">isis</span>.
Branch isis_rebase set up to track remote branch isis_rebase from isis.
<span style="color:#808080">wendt@integ:~/isis$</span> git checkout <span style="color:#ff0000">isis_contrib</span>
wendt@integ:~/isis$ git checkout isis_contrib  
Already on '<span style="color:#ff0000">isis_contrib</span>'
Already on 'isis_contrib'
<span style="color:#808080">wendt@integ:~/isis$</span> git branch --set-upstream <span style="color:#ff0000">remotes/isis/isis_contrib</span>
wendt@integ:~/isis$ git branch --set-upstream remotes/isis/isis_contrib
</pre>


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
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.


<pre>
wendt@bastet:~/isis$ git checkout <span style="color:#ff0000">isis_productive</span>
wendt@bastet:~/isis$ git checkout isis_productive  
Switched to branch '<span style="color:#ff0000">isis_productive</span>'
Switched to branch 'isis_productive'
<span style="color:#808080">wendt@integ:~/isis$</span> cd ..
wendt@integ:~/isis$ cd ..
<span style="color:#808080">wendt@integ:~$</span> rsync -a --delete --exclude=config.php --exclude=.htaccess --exclude=.git/ isis <nowiki>admin@www.isis.tu-berlin.de:/var/www/</nowiki>
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:  
admin@www.isis.tu-berlin.de's password:  
<span style="color:#808080">wendt@integ:~$</span>  
wendt@integ:~$  
</pre>


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

Revision as of 21:32, 10 October 2012

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.