How to build Couchbase Server

Couchbase Server is Open Source under Apache2 license and even if an user would normally not build it from the source code (in fact the custom built versions are not officially supported by Couchbase), you might want to participate in the Couchbase Community by providing some lines of code. The first thing you need is to be able to build Couchbase Server from the source code.

The Couchbase Server source code is not just in one repository. Instead it is spread over multiple Git repositories. A tool which can be used in order to abstract the access to these multiple Git repositories is 'repo'. So 'repo' is a repository management tool on top of Git. It's also by Google for Android and so a short documentation can be found here: https://source.android.com/source/using-repo.html . The installation instructions are available at http://source.android.com/source/downloading.html#installing-repo .

Here some 'repo' commands:
  • repo init: Installs the repository to the current directory
  • repo sync: Downloads the new changes and updates the working files in the local directory
  • repo start: Begins a new branch for development, starting from the revision specified in the manifest
Repo is using manifest files. The Couchbase manifest files can be found here: https://github.com/couchbase/manifest . Let's take a look into one of these files (e.g. /released/4.5.0-beta.xml):

<remote name="couchbase" fetch="git://github.com/couchbase/" review="review.couchbase.org" />
...
<default remote="couchbase" revision="master" />
<project name="bleve" remote="blevesearch" revision="760057afb67ba9d8d7ad52f49a87f2bf9d31a945" path="godeps/src/github.com/blevesearch/bleve"/>
...

As you can see, the manifest includes the Git repos those are containing Couchbase dependencies. By default the master branch was referenced here. Each dependency can be provided with a specific Git Hash or branch name in order to make sure that you build based on the right version of the dependent library.

Before we build it's required to have at least make and cmake installed on your build box. If not the build will fail by telling you what's required. I already had a C development environment, python and Go installed on my computer. The build of Couchbase is actually quite simple:

cd --
mkdir -p src/couchbase
cd src/couchbase
repo init -u git://github.com/couchbase/manifest.git -m 
repo sync
make

The built version of Couchbase is then available in the sub-folder 'install'.

Comments