This folder contains the necessary files to build and run Bedrock in a Docker container.
Dockerfile: Defines the Docker image for Bedrocklibstuff/bedrock.sh: Startup script for Bedrock within the containerdocker-compose.yml: Docker Compose configuration for running a Bedrock cluster
The Dockerfile sets up a container based on phusion/baseimage:noble-1.0.0
and includes the following key steps:
- Installs necessary packages
- Copies the Bedrock binary to the container
- Sets up the database directory
- Exposes ports 8888 and 9000
- Configures the startup script
- Creates a non-root user for running Bedrock
This script is responsible for starting Bedrock with the appropriate parameters. It:
- Checks for a compatible Bash version
- Sets up default parameters
- Processes environment variables to configure Bedrock
- Starts Bedrock as the non-root user
The docker-compose.yml file defines a Bedrock cluster with three nodes. It includes:
- Three Bedrock services (node0, node1, node2)
- Network configuration for inter-node communication
- Volume mounts for data persistence
- Environment variable configuration for each node
To build and run the Bedrock cluster using Docker Compose:
docker-compose up --buildThis command will build the Docker image and start the Bedrock cluster as defined in the docker-compose.yml file.
This script automates the process of building the Docker image and extracting the Bedrock binary. It performs the following steps:
- Builds the Docker image using the Dockerfile
- Creates a temporary container from the built image
- Copies the Bedrock binary from the container to a local output directory
- Removes the temporary container
To use this script:
./build_and_extract.shAfter running the script, you'll find the Bedrock binary in the ../output directory.
To run a single Bedrock container:
docker run -d \
--name bedrock-node \
-p 8888:8888 \
-p 9000:9000 \
-e NODE_NAME=node1 \
-e PRIORITY=100 \
-e PEER_LIST=node2:9000,node3:9000 \
bedrockThe following environment variables can be used to configure Bedrock:
NODE_NAME: Name of the Bedrock nodePRIORITY: Priority of the node in the clusterPEER_LIST: Comma-separated list of peer nodesPLUGINS: Plugins to enableCACHE_SIZE 44D2: Size of the cacheWORKER_THREADS: Number of worker threadsQUERY_LOG: Query log configurationMAX_JOURNAL_SIZE: Maximum journal size
Additional flags can be set using the VERBOSE, QUIET, and CLEAN environment variables.
- 8888: HTTP server port
- 9000: Peer communication port
The Bedrock database is stored at /var/db/bedrock.db within the container. In the Docker Compose setup, volumes are used to persist data for each node.
Bedrock logs are written to /var/log/bedrock.log inside the container.
Example of log output:
$ docker logs bedrock-node2
bedrock-node2 | Oct 17 16:14:52 da62315a18ec bedrock: xxxxxx (SQLiteNode.cpp:1253) _onMESSAGE [sync] [info] {node2/LEADING} Received PING from peer 'node0'. Sending PONG.
bedrock-node2 | Oct 17 16:14:52 da62315a18ec bedrock: xxxxxx (SQLiteNode.cpp:1261) _onMESSAGE [sync] [info] {node2/LEADING} Received PONG from peer 'node0' (0ms latency)
bedrock-node2 | Oct 17 16:14:52 da62315a18ec bedrock: xxxxxx (SQLiteNode.cpp:1253) _onMESSAGE [sync] [info] {node2/LEADING} Received PING from peer 'node1'. Sending PONG.
bedrock-node2 | Oct 17 16:14:52 da62315a18ec bedrock: xxxxxx (SQLiteNode.cpp:1261) _onMESSAGE [sync] [info] {node2/LEADING} Received PONG from peer 'node1' (0ms latency)
The Bedrock nodes are connected to a custom bridge network bedrock-cluster, allowing for easy communication between nodes.