Run Crossbar with Docker Compose
Operating a crossbar server with Docker Compose
Overview
Crossbar can be run pretty easily with Docker. The instructions below will walk you through running Crossbar in Docker containers using Docker Compose.
For Swagger documentation, see: https://crossbar.switchboard.xyz/docs
Crossbar and Task Runner Simulator
Crossbar uses another piece of software called Task Runner Simulator to simulate feeds. You can provide Crossbar with the address of the Task Runner Simulator instance via an environment variable. If you don't provide it, Crossbar will fall back on using the public Task Runner Simulator endpoint at crossbar.switchboard.xyz
, however it's not recommended to rely on this and we don't provide any guarantee of service. The instructions in this guide include running the Task Runner Simulator server alongside Crossbar.
Prerequisites
Before running crossbar, ensure you have the following
Docker and Docker Compose installed on your machine.
A custom Solana RPC for Task Runner Simulator actions (optional - strongly recommended)
Pinata or another IPFS node for job storage
Step 1: Set Up Your Project Directory
Create a Project Directory: Create a directory for your project. This directory will contain all the necessary files for your Docker container deployment.
Step 2: Create the docker-compose.yml
File
docker-compose.yml
FileCreate a
docker-compose.yml
File: In your project directory, create a file nameddocker-compose.yml
. This file will define the Docker services and environment variables.
Step 3: Create the .env
File
.env
FileCreate a
.env
File: In the same directory, create a.env
file to store your environment variables. This file is read bydocker compose
and will override the default values in the compose file if specified.
Step 4: Build and Run the Docker Container
Build and Run the Docker Container: Navigate to your project directory and run the following command to start your Docker container:
This command will start the container in detached mode. The -d
flag stands for "detached," meaning the container runs in the background.
Step 5: Verify the Deployment
Verify the Deployment: Once the container is running, you can verify that the service is up and running by accessing it at
http://localhost:8080
. You can also check the status of the container by running:
This command will show the status of the running services.
Step 6: Stopping and Restarting the Docker Container
Stop the Docker Container: To stop the container, run:
This command will stop and remove the containers defined in your docker-compose.yml
file.
Restart the Docker Container: To restart the container, run:
Additional Tips
Logs: To view the logs of the running container, use the following command:
Updating Environment Variables: If you need to update the environment variables, edit the
.env
file and restart the container:
Testing it out:
Try the deployment out by navigating to (can take a few seconds the first run): http://localhost:8080/updates/evm/1115/4f0e020e3d6f65cf21adb7766d065f787293154964be259dddb56e848ff838a0
The equivalent result should look something like the output from the public node: https://crossbar.switchboard.xyz/updates/evm/1115/4f0e020e3d6f65cf21adb7766d065f787293154964be259dddb56e848ff838a0
Last updated