Bencher Self-Hosted
Bencher is open source. It is available as a SaaS, Bencher Cloud, and as a self-hostable set of container images:
- Bencher Console Server
- Bencher API Server
Deployment
The easiest way to deploy Bencher Self-Hosted is using a triptych of bencher CLI subcommands:
bencher upbencher upCreate and start the Bencher Self-Hosted containers. This is similar to running
docker compose up.Both containers join a Docker network named
bencher, whichbencher upcreates, or reuses when an earlier run left it. It stops with an error on abenchernetwork it did not create, andbencher up consoleconnects a runningbencher_apicontainer that is not on the network yet. When the Console server’sBENCHER_API_URLis unset or names a loopback address, such aslocalhost, the Console server relays to the API server’s container there: itsINTERNAL_API_URLishttp://bencher_api:6610, unless you set it with the--console-envoption. Otherwise, it relays toBENCHER_API_URL.bencher up [OPTIONS] [SERVICE]Service
Select the containers to run. The possible choices are:
all,api, andconsole. By defaultallis chosen. Similar to theSERVICEargument fordocker compose up.Options
--detachRun in detached mode. The containers will be run in the background. Similar to the
--detachflag fordocker compose up.--pull <WHEN>Pull images before running. The possible choices are:
always,missing, andnever. By defaultalwaysis chosen. Similar to the--pulloption fordocker compose up.--tag <TAG>Specify the image tag for the containers. By default the image tag matches the
bencherCLI version. The most recentbencherCLI version isv0.6.19.--console-port <PORT>Specify a port number for the Console server container. By default, port
3000is used. Similar to the port only form of the--exposeoption fordocker run.If you specify the
--console-portoption, you must also update theconsole.urlAPI server configuration to match the new port, using either the--api-envoption or the--api-volumeoption.--api-port <PORT>Specify a port number for the API server container. By default, port
6610is used. Similar to the port only form of the--exposeoption fordocker run.If you specify the
--api-portoption, you must also update the Console ServerBENCHER_API_URLenvironment variable to match the new port, using the--console-envoption.--console-env <KEY_VALUE>Pass an environment variable to the Console server container. The expected format is
KEY=value. This can be useful when working with the Console Server configuration. Similar to the--envoption fordocker run.--api-env <KEY_VALUE>Pass an environment variable to the API server container. The expected format is
KEY=value. This can be useful when working with the API Server configuration. Similar to the--envoption fordocker run.--console-volume <HOST_CONTAINER>Pass a mount volume to the Console server container. The expected format is
/host/path:/container/path. This can be useful when working with the Console Server configuration. Similar to the--volumeoption fordocker run.--api-volume <HOST_CONTAINER>Pass a mount volume to the API server container. The expected format is
/host/path:/container/path. This can be useful when working with the API Server configuration. Similar to the--volumeoption fordocker run.--helpPrint help.
bencher logsbencher logsView output from the Bencher Self-Hosted containers, if
bencher upwas run with the--detachflag. This is similar to runningdocker compose logs.bencher up [OPTIONS] [SERVICE]Service
Select the containers to run. The possible choices are:
all,api, andconsole. By defaultallis chosen. Similar to theSERVICEargument fordocker compose logs.Options
--helpPrint help.
bencher downbencher downStop and remove the Bencher Self-Hosted containers, if
bencher upwas run with the--detachflag. This is similar to runningdocker compose down.Once no container is left on the
benchernetwork, it removes that network too.bencher down [OPTIONS] [SERVICE]Service
Select the containers to run. The possible choices are:
all,api, andconsole. By defaultallis chosen. Similar to theSERVICEargument fordocker compose down.Options
--helpPrint help.
See the Bencher Compose reference for more details.
Alternatively, you could just use docker compose to orchestrate the containers.
docker-compose.yml
services: bencher_api_compose: image: ghcr.io/bencherdev/bencher-api:latest container_name: bencher_api ports: - 6610:6610 volumes: # Mount the configuration directory - "./services/api/etc:/etc/bencher" # Mount the database directory - "./services/api/data:/var/lib/bencher/data" # environment: # Set configuration string or file path # - BENCHER_CONFIG= # - BENCHER_CONFIG_PATH=
bencher_console_compose: image: ghcr.io/bencherdev/bencher-console:latest container_name: bencher_console ports: - 3000:3000 environment: # Set the API URL to the localhost IPv4 address - BENCHER_API_URL=http://127.0.0.1:6610 # The Console server relays every browser request to the API container, over the network they share # With a remote API server instead, such as https://api.bencher.example.com, set this to its URL - INTERNAL_API_URL=http://bencher_api:6610 depends_on: - bencher_api_composeSee the Docker Compose reference example for more details.
API Server URL
When using Bencher Self-Hosted,
you will need to set the --host option
to the URL of your Bencher API server
for most bencher CLI subcommands.
For example, if you were using the bencher run CLI subcommand
with a Bencher API server at https://api.bencher.example.com
then you could write something like this:
bencher run \--host https://api.bencher.example.com \--project project-abc4567-wxyz123456789 \--branch main \--testbed ci-runner \--adapter json \bencher mockIf you running the Bencher Console server on a different host than the Bencher API server,
you will also need to set the BENCHER_API_URL environment variable
on the Bencher Console server to the remote URL for your Bencher API server.
For example, if you are using the bencher up CLI subcommand
to start the Bencher Console server with a Bencher API server running at https://api.bencher.example.com
then you will need to set the --console-env option to the remote URL like this:
bencher up --console-env BENCHER_API_URL=https://api.bencher.example.com consoleHTTPS
In order to setup HTTPS, you can use Bencher Self-Hosted behind a proxy with HTTPS enabled or use a domain name with a valid SSL certificate.
Custom CA Certificates
By default, the bencher CLI loads certificates from the bundled webpki-roots crate.
The webpki-roots are a reliable set of trust roots from Mozilla,
and including them in bencher improves portability and performance.
This is especially true on macOS, where reading the system trust store incurs a significant delay.
However, in some cases, you may want to use the platform’s native certificate store,
especially if you’re relying on a corporate trust root that’s included in your system’s certificate store
for a mandatory proxy or self-signed Bencher Self-Hosted connections.
To instruct bencher to use the system’s trust store, run bencher with
the --native-tls flag.
If a direct path to the certificate is required,
set the SSL_CERT_FILE environment variable to the path of the certificate bundle,
to instruct bencher to use that file instead of the system’s trust store.
This is often the case in CI environments where the system’s trust store is not available.
If client certificate authentication (mTLS) is desired,
set the SSL_CLIENT_CERT environment variable to the path of the PEM formatted file
containing the certificate followed by the private key.
Finally, if you’re using a setup in which you want to trust a self-signed certificate
or otherwise disable certificate verification,
you can instruct bencher to allow insecure connections to dedicated hosts via
the --insecure-host flag.
This flag is only applicable to HTTPS connections, as HTTP connections are inherently insecure.
WARNING: Only use --insecure-host in a secure network with verified sources,
as it bypasses SSL verification and could expose you to man-in-the-middle attacks.
Disaster Recovery
To prevent data loss, Bencher offers a built-in disaster recovery solution. Disaster recovery requires a valid Bencher Plus Enterprise license for at least one organization on the server, and a server with disaster recovery configured refuses to start without one. A running server keeps replicating until it restarts, even after its last license expires, and from the first day of that license’s grace period, the server logs a daily error that says when it will refuse to start.
Supported replication schemes:
file: Replicate to a local file paths3: Replicate to any S3 compatible blob storage
Use the plus.disaster_recovery section of the API server configuration
to setup disaster recovery for your Bencher Self-Hosted API server.
To stop a server with disaster recovery, send the stop signal (SIGTERM or SIGINT) to the API server process alone.
The API server then finishes its open requests and stops the replication, which replicates the last changes before it exits.
A second stop signal sent straight to the replication process (litestream) cancels that last replication, and the last changes can be lost.
docker stop sends the stop signal to the API server process alone.
With systemd, set KillMode=mixed in the unit, so that the stop signal reaches the API server process alone.