Public | Automated Build

Last pushed: 21 hours ago
Short Description
Atlassian Bitbucket with embedded database
Full Description

= README

Docker Image image:https://images.microbadger.com/badges/image/softwarecraftsmen/atlassian-bitbucket-base.svg[link="https://microbadger.com/images/softwarecraftsmen/atlassian-bitbucket-base" alt="atlassian-bitbucket-base image layers"]
image:https://images.microbadger.com/badges/version/softwarecraftsmen/atlassian-bitbucket-base.svg[link="https://microbadger.com/images/softwarecraftsmen/atlassian-bitbucket-base" alt="atlassian-bitbucket-base image layers"]

This image provides a https://www.atlassian.com/software/bitbucket/server[Bitbucket Server] with an embedded database which is sufficient for demo and evaluation purpose.
However, for production it is advised to use one of the https://confluence.atlassian.com/bitbucketserver/connecting-bitbucket-server-to-an-external-database-776640378.html[supported external databases] (e.g. PostgreSQL).

The following instructions show how to build and run Bitbucket Server.

== Prepare a docker host

[source,shell]

docker-machine create --driver virtualbox atlassian <1>
docker-machine start atlassian <2>

eval docker-machine env atlassian <3>

  1. Create a docker machine (once only)
  2. Start the docker machine
  3. Setup the docker client to use the docker-machine

== Build the image

.Build with VCS information built-in as docker label

[source,shell]

docker build --build-arg vcs_ref=$(git rev-parse --short HEAD) -t softwarecraftsmen/atlassian-bitbucket-base .

=== Building on Docker Hub

hooks/build is a script that performs a custom build providing build metadata for Docker image labels according to http://label-schema.org/[http://label-schema.org/].

=== Publish to Docker Hub

Tag the git repository using the bitbucket version number as tag

[source,shell]

git tag <bitbucket-version>

git push origin master --tags

== Run a Bitbucket Server instance

The Bitbucket container uses https://github.com/krallin/tini[tini] as init system.
The tini executable is expected at /dev/tini.
As of Docker 1.13 tini is included in Docker itself.
But it is not enabled by default, see https://docs.docker.com/engine/reference/commandline/dockerd.

.dockerd configuration

[source, json]

{
"init" : true

}

Further each container instance must be created using the --init option.

[source,shell]

docker pull softwarecraftsmen/atlassian-bitbucket-base

docker run -d --init --name bitbucket-server -p 7990:7990 softwarecraftsmen/atlassian-bitbucket-base

To open Bitbucket Server start page on Mac OSX run open http://$(docker-machine ip atlassian):7990from the shell:

== Customizing Bitbucket

=== Environment Variables

During the first start of the container a few environment variables are considered for providing default values for the setup wizard.
These allow for a fully automated setup without setup wizard intervention.

The subset of supported https://confluence.atlassian.com/bitbucketserver/automated-setup-for-bitbucket-server-776640098.html[properties ] is as follows.

.bitbucket.properties variables
|===
|Environment |`bitbucket.properties |Default

|BITBUCKET_LICENSE
|setup.license
|

|BITBUCKET_SYSADMIN_USERNAME
|setup.sysadmin.username
| Required for fully setting up an administrator account

|BITBUCKET_SYSADMIN_PASSWORD
|setup.sysadmin.password
| Required for fully setting up an administrator account

|BITBUCKET_SYSADMIN_DISPLAYNAME
|setup.sysadmin.displayName
| Required for fully setting up an administrator account

|BITBUCKET_SYSADMIN_EMAIL
|setup.sysadmin.emailAddress
| Required for fully setting up an administrator account

|BITBUCKET_JDBC_USER
|jdbc.user
| Required for setting up an external database

|BITBUCKET_JDBC_PASSWORD
|jdbc.password
| Required for setting up an external database

|BITBUCKET_JDBC_DRIVER
|jdbc.driver
| Required for setting up an external database

|BITBUCKET_JDBC_URL
|jdbc.url
| Required for setting up an external database

|BITBUCKET_DISPLAYNAME
|setup.displayName
|

|BITBUCKET_BASEURL
|setup.baseUrl
|

|===

.Reverse proxy variables
|===
|Variable |Default value | Comment

SERVER_PROXY_NAME
-
SERVER_PROXY_PORT
-

|SERVER_SCHEME
|http
|-

|SERVER_SECURE
|false
|-
|===

=== External database

For replacing the internal embedded database we just have to set 2 environment variables for the JDBC driver and URL.
Below is an example for PostgreSQL.

.Connecting to PostgreSQL

[source,shell]

export BITBUCKET_JDBC_DRIVER=org.postgresql.Driver

export BITBUCKET_JDBC_URL=jdbc:postgresql://postgresdb:5432/bitbucket

=== Custom bitbucket.properties

For adding more custom properties we just can add a https://confluence.atlassian.com/bitbucketserver/bitbucket-server-config-properties-776640155.html[`${BITBUCKET_HOME}/bitbucket.properties.template`] file to the image.
It will be moved to $BITBUCKET_HOME/shared/bitbucket.properties during the initial startup.

The extending image can add this file in its Dockerfile like

[source,shell]

COPY bitbucket.properties.template ${BITBUCKET_HOME}/bitbucket.properties.template

This base image offers a few environment variables especially for setting sensitive settings such as password or license keys that should not be committed to the repository.
They are automatically written into their respective property keys in bitbucket.properties.
These are better set through environment variables and passed to the container rather than hard coded into bitbucket.properties.

== Backup

See https://confluence.atlassian.com/bitbucketserver/using-bitbucket-server-diy-backup-776640056.html[Using Bitbucket Server DIY Backup].

Docker Pull Command
Owner
softwarecraftsmen

Comments (0)