GitBucket is a clone you could say of GitHub. However while it looks similar to GitHub it's certainly quite far from being what GitHub is. Sure it allows you to:

  • Public / Private Git repository (http access only)
  • Repository viewer (some advanced features such as online file editing are not implemented)
  • Repository search (Code and Issues)
  • Wiki
  • Issues
  • Fork / Pull request
  • Mail notification
  • Activity timeline
  • User management (for Administrators)
  • Group (like Organization in Github)
  • LDAP integration
  • Gravatar support

but there's a lot missing, most notably the ability to use the Git/SSH protocol. However, with all the features included above I decided to give it a shot.

The first thing to note is this is not written in one of my preferred languages such as PHP, Ruby (on Rails) or even on node.js. It's done in Scala, which means that Java will be involved. I absolutely despise Java. Regardless I still went forth.

For my install I decided to deploy it to Heroku which meant I didn't have to install Tomcat or Glassfish, etc...

I have a CentOS 6.x Linux server which I used. First you'll need to install Java, pretty simple. You'll also need the development tools as well.

~/gitbucket $ yum install java-1.6.0-openjdk-devel java-1.6.0-openjdk.x86_64 -y
~/gitbucket $ export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre

This will install Java and any necessary dependencies. One that's finish you'll want to get the GitBucket code. By default GitBucket doesn't come with the necessary configurations for working on Heroku, but someone has kindly updated the latest GitBucket branch with the necessary code and files.

~/gitbucket $ git clone -b heroku-1.9 https://github.com/xuwei-k/gitbucket.git

This tells git to snag the heroku-1.9 branch. From there you'll want to change the name of the branch to 'master'.

~/gitbucket $ git branch -m master

Now, you'll want to run the sbt tool, thankfully this is included in this fork of the GitBucket code. It essentially allows you to compile the code locally on your system. You'll want to run the commands when prompted, clean, compile, and stage.

~/gitbucket $ ./sbt.sh
[info] Loading project definition from /home/git/gitbucket/project
[info] Set current project to gitbucket (in build file:/home/git/gitbucket/)
>> clean
[success] Total time: 0 s, completed Jan 29, 2014 9:10:55 PM
>> compile
[info] Compiling twirl template .../main.scala.html to .../main.template.scala
[info] Compiling twirl template .../index.scala.html to .../index.template.scala
[info] Compiling twirl template .../header.scala.html to .../header.template.scala
[info] Compiling twirl template .../signinform.scala.html to .../signinform.template.scala
[info] Compiling twirl template .../signin.scala.html to .../signin.template.scala
...
>> stage
[info] Generating /home/git/gitbucket/target/scala-2.10/resource_managed/main/rebel.xml.
[info] Wrote start script for mainClass := Some(JettyLauncher) to /home/git/gitbucket/target/start
[success] Total time: 1 s, completed Jan 29, 2014 9:13:58 PM

Once this is completed you can push it out to Heroku. First create the application:

~/gitbucket $ heroku create
Creating sheltered-shelf-3564... done, stack is cedar
http://sheltered-shelf-3564.herokuapp.com/ | git@heroku.com:sheltered-shelf-3564.git
Git remote heroku added

Next push your code to Heroku.

~/gitbucket $ git push heroku master
Initializing repository, done.
Total 0 (delta 0), reused 0 (delta 0)

-----> Scala app detected
-----> Installing OpenJDK 1.7...done
-----> Downloading SBT...done
-----> Running: sbt compile stage
       Getting org.scala-sbt sbt 0.12.3 ...

It'll spew forth a lot of text, hopefully you should see something similar to:

[success] Total time: 140 s, completed Jan 30, 2014 3:26:53 AM
       [info] Generating /tmp/scala_buildpack_build_dir/target/scala-2.10/resource_managed/main/rebel.xml.
       [info] Wrote start script for mainClass := Some(JettyLauncher) to /tmp/scala_buildpack_build_dir/target/start
       [success] Total time: 1 s, completed Jan 30, 2014 3:26:55 AM
-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 204.8MB
-----> Launching... done, v6
       http://sheltered-shelf-3564.herokuapp.com deployed to Heroku

To git@heroku.com:sheltered-shelf-3564.git
 * [new branch]      master -> master

Once that's done just visit your Heroku instance, in our case it would be http://sheltered-shelf-3564.herokuapp.com. Hopefully this helps some people trying to install GitBucket and deploy it to Heroku.

GitBucket certainly looks like it could have a lot of potential, probably even more if it wasn't developed in Scala/Java. I did come across one issue so far, I installed GitBucket one night and was too tired to write this up until the morning, when I returned to login to my GitBucket installation it had removed the user account I had created the night before. When I re-logged in with the default root user, it was as if the install had completely reset. The creation timestamp for the root user was today (just now). I will have to submit an issue to takezoe/gitbucket. Other then that, I haven't come across any other issues and I think I'll continue to follow this project.

Update: I guess I was still pretty tired when I wrote this article but the issue with my GitBucket instance "resetting" on Heroku was because they don't have a persistent disk system. Anytime the instance falls asleep or goes idle the disk state resets essentially. One should be using something like Amazon S3 for disk storage or another similar service. I should have known that as well...

Resources