Deploy 2 data center nodes of Bitbucket in docker

Hello!

In this article I will show you how you can deploy 2 data center nodes of Bitbucket in your local environments using the docker image provided by Atlassian.

This deployment will not include the load balancer because I need these nodes for app development to check if my app works properly in Data Center environment. That is why I always connect to a certain node.

First, you need to create this docker-compose.yml file:

version: '3'

services:
  bb_node_1:
    depends_on:
      - postgresql
    image: atlassian/bitbucket:latest
    networks:
      - bbnet
    volumes:
      - /Users/alexm/projects/prometheus/bitbucket/shared:/var/atlassian/application-data/bitbucket/shared
    ports:
      - '7990:7990'
      - '8000:5005'
    environment:
      - 'JDBC_URL=jdbc:postgresql://postgresql:5432/bbdb'
      - 'JDBC_USER=bb'
      - 'JDBC_PASSWORD=jellyfish'
      - 'JDBC_DRIVER=org.postgresql.Driver'
      - 'JVM_MINIMUM_MEMORY=2048m'
      - 'JVM_MAXIMUM_MEMORY=4096m'
      - 'JVM_SUPPORT_RECOMMENDED_ARGS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005'
      - 'HAZELCAST_GROUP_NAME=bb_group'
      - 'HAZELCAST_GROUP_PASSWORD=1234'
      - 'HAZELCAST_NETWORK_MULTICAST=true'

  bb_node_2:
    depends_on:
      - postgresql
    image: atlassian/bitbucket:latest
    networks:
      - bbnet
    volumes:
      - /Users/alexm/projects/prometheus/bitbucket/shared:/var/atlassian/application-data/bitbucket/shared
    ports:
      - '7991:7990'
      - '8001:5005'
    environment:
      - 'JDBC_URL=jdbc:postgresql://postgresql:5432/bbdb'
      - 'JDBC_USER=bb'
      - 'JDBC_PASSWORD=jellyfish'
      - 'JDBC_DRIVER=org.postgresql.Driver'
      - 'JVM_MINIMUM_MEMORY=2048m'
      - 'JVM_MAXIMUM_MEMORY=4096m'
      - 'JVM_SUPPORT_RECOMMENDED_ARGS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005'
      - 'HAZELCAST_GROUP_NAME=bb_group'
      - 'HAZELCAST_GROUP_PASSWORD=1234'
      - 'HAZELCAST_NETWORK_MULTICAST=true'

  postgresql:
    image: postgres:9.5-alpine
    networks:
      - bbnet
    #volumes:
    #  - postgresqldata:/var/lib/postgresql/data
    ports:
      - '5432:5432'
    environment:
      - 'POSTGRES_USER=bb'
      # CHANGE THE PASSWORD!
      - 'POSTGRES_PASSWORD=jellyfish'
      - 'POSTGRES_DB=bbdb'
      - 'POSTGRES_ENCODING=UNICODE'
      - 'POSTGRES_COLLATE=C'
      - 'POSTGRES_COLLATE_TYPE=C'
    logging:
      # limit logs retained on host to 25MB
      driver: "json-file"
      options:
        max-size: "500k"
        max-file: "50"

volumes:
  postgresqldata:
    external: false

networks:
  bbnet:
    driver: bridge

Change ‘/Users/alexm/projects/prometheus/bitbucket/shared’ to the folder path where all shared data for your nodes should be placed.

Move to the folder where you created the file and run it with this command:

docker-compose up

As a result you will have two Bitbucket nodes up. The first node will be running on port 7090 and the second node will be running on port 7091.

Also you will be able to connect with a debug session to the nodes using ports 8000 for node 1 and 8001 for node 2.

If you have problem with including the second node to the cluster just restart the container with the second node.

One thought on “Deploy 2 data center nodes of Bitbucket in docker

  1. Thank you for sharing the detailed steps, it really helped.

    For any one getting a permission error on the shared directory a dirty hack will be to explicitly grant the permission to the bitbucket user inside the docker-compose.yml file as below:

    user: 2003:2003

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: