Self-hosting a Git server gives you full control over your source code — no third-party access, no storage limits, no subscription fees. Bitbucket Server (now Bitbucket Data Center) is a mature option, and while running it on a Raspberry Pi 2 is not a high-performance setup, it works well for personal projects and small teams. This post covers overclocking the Pi for the extra JVM headroom, installing Bitbucket Server, and backing it with PostgreSQL.
Note: Atlassian discontinued Bitbucket Server in favour of Bitbucket Data Center. If setting this up fresh today, consider Gitea — a lightweight Git server purpose-built for low-resource environments that runs excellently on a Raspberry Pi.
Step 1 — Overclock the Pi
Bitbucket Server is a Java application. JVM startup alone stresses a stock Pi 2, so a modest overclock helps:
sudo nano /boot/config.txt
hdmi_force_hotplug=1
force_turbo=1
boot_delay=1
arm_freq=1000
core_freq=500
sdram_freq=500
over_voltage=2
gpu_mem=16
gpu_mem=16 frees as much RAM as possible for the JVM. hdmi_force_hotplug=1 prevents a known issue where removing HDMI could cause SD card data loss. Reboot after saving.
Step 2 — Download and install Bitbucket Server
Check your Git version — Bitbucket Server 4.14.9 requires Git 2.11.x or below:
git --version
Download and run the binary installer from Atlassian’s archive:
wget https://www.atlassian.com/software/stash/downloads/binary/atlassian-bitbucket-4.14.9-x64.bin
sudo chmod a+x atlassian-bitbucket-4.14.9-x64.bin
sudo ./atlassian-bitbucket-4.14.9-x64.bin
Run as root so it can register the service to start on boot. Follow the on-screen prompts. The default port is 7990.
Step 3 — Install PostgreSQL and create the database
sudo apt-get install postgresql
sudo -i -u postgres
psql
CREATE ROLE bitbucketuser WITH LOGIN PASSWORD 'your_secure_password' VALID UNTIL 'infinity';
CREATE DATABASE bitbucket WITH ENCODING='UTF8' OWNER=bitbucketuser CONNECTION LIMIT=-1;
\q
exit
Step 4 — Finish setup and tune the JVM
Reboot, then navigate to http://<your-pi-ip>:7990. The setup wizard guides you through connecting to PostgreSQL and creating an admin account.
Once running, tune the JVM heap to fit within the Pi 2’s ~1 GB RAM:
sudo nano /opt/atlassian/bitbucket/4.14.9/bin/setenv.sh
JVM_MINIMUM_MEMORY="256m"
JVM_MAXIMUM_MEMORY="512m"
Restart the Bitbucket service. With these settings the server should be responsive for everyday personal use. More Raspberry Pi tutorials on the blog.