Install Bitbucket with Docker Compose
This article is for those looking for a detailed and straightforward guide on installing Bitbucket with Docker Compose.
Bitbucket is a project hosting and collaborative web service based on Mercurial and Git version control.
In this guide, we will consider the case when you already have a server with the Ubuntu Server 22.04 LTS operating system installed on it.
You can read more about how to install Ubuntu Server 22.04 LTS in my guide “Install Ubuntu Server 22.04 LTS”.
Also, the server must have Docker Engine and Docker Compose installed.
You can learn how to install Docker Engine and Docker Compose on Ubuntu Server by reading “Install Docker Engine and Docker Compose on Ubuntu Server”.
In addition, OpenSSH must be installed on the server, and port 22 must be open in order to be able to connect to the server using the SSH protocol.
To install OpenSSH on a server, you can use the command:
If you plan to connect to the server using the Windows operating system, you can use PuTTY or MobaXterm.
This guide describes how to connect to a server using the iTerm2 terminal emulator installed on the macOS operating system.
Please note that you will need to open the following TCP ports to access your server:
- TCP port 80 - to receive a free cryptographic certificate through the Let’s Encrypt CA.
- TCP port 443 - to access the Bitbucket web interface.
We connect to the server on which you plan to install Bitbucket.
Now you need to create a YAML configuration file that will contain all the necessary conditions for Bitbucket to work.
Let’s create a YAML configuration file using a text editor using the command:
Hit the “i” button to go into edit mode, then insert the following configuration for Bitbucket to work.
Next, you need to make changes to the configuration so that the contents of the file match your conditions. Parameters that need to be checked or changed are marked “(replace with yours)”.
In this guide, the bitbucket.heyvaldemar.net subdomain will be used to access Bitbucket from the Internet. You will need to specify your domain or subdomain by which your Bitbucket will be accessible from the Internet.
Please note that in this guide, Postgres will be used as a database management system, and Traefik will be used as a reverse proxy.
In the “traefik.http.middlewares.authtraefik.basicauth.users” parameter, you must specify the username and password hash to access the Traefik dashboard.
Please note that you can use this service to get the password hash.
Now press the “Esc” button to exit edit mode, then type “:x” and press the “Enter” button to save your changes and exit the editor.
Now let’s start Bitbucket with the command:
To continue the Bitbucket installation process, you need to go from the workstation to the link https://bitbucket.heyvaldemar.net, where bitbucket.heyvaldemar.net is the name of my server. Accordingly, you need to provide the name of your Bitbucket server.
This tutorial walks you through installing Bitbucket for a production environment.
In the “Language” field, select the language in which you plan to use Bitbucket.
In the “Database” field, select “External”.
Now you need to specify the system for managing the databases and the previously created database that will be used to run Bitbucket.
In the “Database Type” field, select “PostgreSQL”.
In this tutorial, the database for running Bitbucket is on the same server as Bitbucket.
In the “Hostname” field, enter “localhost”.
In the “Port” field, specify the value “5432”.
This tutorial uses “bitbucketdb” as the database name for Bitbucket.
In the “Database name” field, enter “bitbucketdb”.
This tutorial uses “bitbucketdbuser” as the database username for Bitbucket.
In the “Database username” field, specify “bitbucketdbuser”.
In the “Database password” field, specify the password assigned to the “bitbucketdbuser” user.
Click on the “Test” button.
The message “Successfully established database connection.” means that all data was entered correctly.
Click on the “Next” button.
Now you need to provide the base URL and license key for Bitbucket.
The “Base URL” field should indicate the domain or subdomain where your Bitbucket is accessible from the Internet.
In this tutorial, the subdomain bitbucket.heyvaldemar.net will be used to access Bitbucket from the Internet. You will need to specify your domain or subdomain under which your Bitbucket will be accessible from the Internet.
If you do not already have a license key, you can request a temporary key to try Bitbucket.
This guide covers installing Bitbucket with a temporary license key.
In the “License key” section, select “I need an evaluation key” and click on the “Create an account” button.
The next step is to provide: email address, first name, last name, and password to create an Atlassian account.
Click on the “Sign up” button.
Please note that you will receive an email to the email address specified during registration. In the letter, you will find a link to complete the registration.
If you already have an Atlassian account, enter the email address associated with your Atlassian account in the “Enter email” field and click on the “Continue” button.
Specify the password for the Atlassian account and click on the “Log in” button.
In the next step, you need to specify for which product you need a temporary license key, as well as the name of your organization.
Click on the “Generate License” button to generate a temporary license key for Bitbucket.
Next, you need to confirm that the temporary license key for Bitbucket will be installed on your server.
Click on the “Yes” button.
In the “Your License Key” field, insert the previously received temporary license key and click on the “Next” button.
In the next step, you need to specify: username, name, email address, and password to create a Bitbucket administrator account.
Click on the “Go to Bitbucket” button.
You can now log into your Bitbucket dashboard using your previously created Bitbucket administrator account.
Specify the username and password of an account with Bitbucket administrator rights and click on the “Log in” button.
Welcome to the Bitbucket dashboard.
Now you can create a new project and repository.
Click on the “Git on with it” button.
Click on “Create project” to start creating a new project.
In the “Project name” field, specify the name for the project and click on the “Create project” button.
Click on “Create repository” to start creating a new repository.
In the “Name” field, specify the name for the repository and click on the “Create repository” button.
Everything is ready to use Bitbucket.
To access the Traefik control panel, go to the link https://traefik.bitbucket.heyvaldemar.net from the workstation, where traefik.bitbucket.heyvaldemar.net is the name of my server. Accordingly, you need to specify the name of your server with Traefik installed.
Specify the username and password specified earlier in the YAML configuration file and click on the “OK” button.
Welcome to the Traefik dashboard.