in pact docker alpine ~ read.

Running standalone pact cli in Docker

Pact is is a contract testing tool. Contract testing is a way to ensure that services (such as an API provider and a client) can communicate with each other. Without contract testing, the only way to know that services can communicate is by using expensive and brittle integration tests.

In New10 I'm currently helping our teams to setup contract testing and tooling for it. For our needs I was building a GO cli tool that would execute set of different commands for pact, like publishing contracts or checking if service can be deployed. Pact is written with Ruby, which we don't use in our company. Instead of forcing everyone to setup Pact and Ruby on their laptops, i have decided to use standalone version of the pact packaged in the Docker. This way we can get the same behavior on both local and CI machines. Here's how you can set it up for you :

  1. Create Dockerfile
  1. Now we need to build a docker image :
docker build -t pact Dockerfile .
  1. And finally we can run pact commands:
docker run -it pact pact-broker publish {path-to-pacts} -a {consumer-version}

And that should be enough :)

Write tests and stay calm about breaking something when you change your code.

comments powered by Disqus
comments powered by Disqus