A smaller and sexier Docker image has now been built in the Pact Foundation organization. The new image can be run without root permissions, and is only 98MB compressed! All environment variable configurations are the same, so you should just be able to switch from dius/pact-broker to pactfoundation/pact-broker and run with it - note that the default port has changed from 80 to 9292 though. Let us know how you go on the #pact-broker channel of our Pact Foundation Slack.
This repository contains a Dockerized Pact Broker. You can pull the dius/pact-broker image from Dockerhub.
If you want to try out a Pact Broker that can be accessed by all your teams, without having to fill in requisition forms and wait for 3 months, you can get a free trial at pactflow.io. Built by a group of core Pact maintainers, Pactflow is a fork of the OSS Pact Broker with extra goodies like an improved UI, field level verification results and federated login. It's also fully supported, and that means when something goes wrong, someone else gets woken up in the middle of the afternoon to fix it...
- A running postgresql database and the ability to connect to it (see POSTGRESQL.md).
- If on Mac, you will need the
timeoutorgtimeoutfunction. You can installgtimeoutusingbrew install coreutils.
- Install Docker
- Prepare your environment if you are not running postgresql in a docker container. Setup the pact broker connection to the database through the use of the following environment variables. If you want to use a disposable postgres docker container just do
export DISPOSABLE_PSQL=truebefore running the script/test.sh.
For a postgres or mysql database:
* PACT_BROKER_DATABASE_ADAPTER (optional, defaults to 'postgres', see note below.)
* PACT_BROKER_DATABASE_USERNAME
* PACT_BROKER_DATABASE_PASSWORD
* PACT_BROKER_DATABASE_HOST
* PACT_BROKER_DATABASE_PORT (optional, defaults to the default port for the specified adapter)
* PACT_BROKER_DATABASE_NAME
Adapter can be 'postgres' (recommended) or 'mysql2' (please note that future JSON search features may not be supported on mysql).
For an sqlite database (only recommended for investigation/spikes, as it will be disposed of with the container unless you mount it from an external file system):
- PACT_BROKER_DATABASE_ADAPTER (set to 'sqlite')
- PACT_BROKER_DATABASE_NAME (arbitrary name eg. pact_broker.sqlite)
- Test the pact broker environment by executing script/test.sh
- Use
-p 80:80to start the docker image, as some of the Rack middleware gets confused by receiving requests for other ports and will return a 404 otherwise (port forwarding does not rewrite headers). - On OSX, if you are not using Docker native, use
docker-machine ip $(docker-machine active)to get the IP of the VirtualBox, and connect on port 80. - The application makes use of the phusion passenger application server.
- Apart from creating a database no further preparation is required.
To enable basic auth, run your container with:
PACT_BROKER_BASIC_AUTH_USERNAMEPACT_BROKER_BASIC_AUTH_PASSWORDPACT_BROKER_BASIC_AUTH_READ_ONLY_USERNAMEPACT_BROKER_BASIC_AUTH_READ_ONLY_PASSWORD
If you want to allow public read access (but still require credentials for writing), then omit setting the READ_ONLY credentials and set PACT_BROKER_ALLOW_PUBLIC_READ=true.
Developers should use the read only credentials on their local machines, and the CI should use the read/write credentials. This will ensure that pacts and verification results are only published from your CI.
Note that the verification status badges are not protected by basic auth, so that you may embed them in README markdown.
If you are using the docker container within an AWS autoscaling group, and you need to make a heartbeat URL publicly available, set PACT_BROKER_PUBLIC_HEARTBEAT=true. No database connection will be made during the execution of this endpoint.
See the Pact Broker configuration documentation.
Set the environment variable PACT_BROKER_LOG_LEVEL to one of DEBUG, INFO, WARN, ERROR, or FATAL.
- PACT_BROKER_WEBHOOK_HOST_WHITELIST - a space delimited list of hosts (eg.
github.com), network ranges (eg.10.2.3.41/24, or regular expressions (eg./.*\\.foo\\.com$/). Regular expressions should start and end with a/to differentiate them from Strings. Note that backslashes need to be escaped with a second backslash. Please read the Webhook whitelists section of the Pact Broker configuration documentation to understand how the whitelist is used. Remember to use quotes around this value as it may have spaces in it. - PACT_BROKER_WEBHOOK_SCHEME_WHITELIST - a space delimited list (eg.
http https). Defaults tohttps.
- PACT_BROKER_BASE_EQUALITY_ONLY_ON_CONTENT_THAT_AFFECTS_VERIFICATION_RESULTS -
trueby default, may be set tofalse. - PACT_BROKER_ORDER_VERSIONS_BY_DATE -
trueby default. Setting this to false is deprecated. - PACT_BROKER_DISABLE_SSL_VERIFICATION -
falseby default, may be set totrue. Disables SSL verification for webhook endpoints.
Documentation for the Pact Broker application itself can be found in the Pact Broker wiki.
For a quick start with the Pact Broker and Postgres, we have an example Docker Compose setup you can use:
- Modify the
docker-compose.ymlfile as required. - Run
docker-compose upto get a running Pact Broker and a clean Postgres database
Now you can access your local broker:
curl -v http://localhost # you can visit in your browser too!
# SSL endpoint, note that URLs in response contain https:// protocol
curl -v -k https://localhost:8443NOTE: this image should be modified before using in Production, in particular, the use of hard-coded credentials
See pact-broker-openshift for an example config file.
See the Troubleshooting page on the wiki.