Skip to content

Commit

Permalink
chore: create docker development environment
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Feb 1, 2020
1 parent ad588b7 commit 087665d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 10 deletions.
8 changes: 8 additions & 0 deletions DEVELOPER_DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Pact Provider Verifier Developer Documentation

## Development environment set up

* Install docker
* Build the docker development container: `script/docker/build-dev-container.sh`
* Run the docker container and open a bash shell into it: `script/docker/run-dev-container.sh`
* Run tests: `rake spec`
20 changes: 20 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ruby:2.2.4-alpine

RUN apk update \
&& apk --no-cache add \
"build-base>=0.4" \
"bash>=4.3" \
"ca-certificates>=20161130" \
"git>=2.8" \
"tzdata>=2015" \
&& rm -rf /var/cache/apk/*

WORKDIR /app

COPY Gemfile pact-provider-verifier.gemspec /app/
COPY lib/pact/provider_verifier/version.rb /app/lib/pact/provider_verifier/version.rb

RUN gem install bundler -v '1.17.3' \
&& bundle install --jobs 3 --retry 3

CMD []
3 changes: 2 additions & 1 deletion script/dev/bar_provider_config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'json'

app = ->(env) {
[201, [], ["something"]]
[201, { "Content-Type" => "application/json" }, [{ "name" => "Thing 1" }.to_json]]
}

run app
23 changes: 14 additions & 9 deletions script/dev/broker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ bundle exec rackup -p 4567 script/dev/bar_provider_config.ru 2> /dev/null &
pid=$!
sleep 3

# --consumer-version-selector '{"tag": "dev", "latest": true}' \
# --provider-states-setup-url http://localhost:4567/provider-state \
# --provider-version-tag "pdev" "foo" \
# --format json \
# --consumer-version-selector '{"tag": "dev", "latest": true}' \
# --tag-with-git-branch \
# --verbose
export PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true
export PACT_BROKER_BASE_URL=https://test.pact.dius.com.au
export PACT_BROKER_USERNAME=dXfltyFMgNOFZAxr8io9wJ37iUpY42M
export PACT_BROKER_PASSWORD=O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1
bundle exec bin/pact-provider-verifier \
--broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M \
--broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1 \
--provider Bar \
--provider-version-tag pdev \
--tag-with-git-branch \
--consumer-version-selector '{"tag": "dev", "latest": true}' \
--pact-broker-base-url https://test.pact.dius.com.au \
-a 1.0.100 \
--provider "Bar" \
--consumer-version-tag dev \
--consumer-version-tag dev2 \
--provider-app-version $(git rev-parse --short HEAD | xargs echo -n) \
--provider-base-url http://localhost:4567 \
--provider-states-setup-url http://localhost:4567/provider-state \
--enable-pending

kill -2 $pid
Expand Down
3 changes: 3 additions & 0 deletions script/docker/build-dev-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker build . -f Dockerfile-dev -t pact-provider-verifier-dev
3 changes: 3 additions & 0 deletions script/docker/run-dev-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker run -it --rm -v ${PWD}:/app pact-provider-verifier-dev:latest bash

0 comments on commit 087665d

Please sign in to comment.