Skip to content

Commit

Permalink
Add Dockerfile for testing (braintree#160)
Browse files Browse the repository at this point in the history
# What

Add a Dockerfile containing setup for repeatable local development on cpairs.

# Why

Setting a cpair up to develop on server SDKs is tedious. The instance has to be setup, and the setup instructions in the [internal wiki](https://internal.braintreepayments.com/display/DEV/Client+Library+Development+Tips) don't work verbatim on cpairs, so it's a time consuming activity to get setup. Instead of assuming cpairs are setup or expecting developers to manually set them up, lets move that into a Dockerfile so it is predictable and documented in code.

# Example

Run gateway on cpair:
```
drake exec --target authy dbdo
drake exec --target provisioner dbdo
drake exec --target arbiter dbdo
drake exec --target integrations dbdo
drake exec dbdo
drake exec rake db:populate_cosmos_data
drake up -d authy
drake up -d provisioner
drake up -d arbiter
drake up -d integrations
drake up
```

Open console in docker container and run make
```
make
# rake
```
  • Loading branch information
Leigh McCulloch authored and GitHub Enterprise committed Jan 8, 2018
1 parent b35fa6b commit 4a59493
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM debian:wheezy

RUN apt-get update

# For installing hhvm
RUN apt-get install -y apt-transport-https software-properties-common
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94
RUN echo deb https://dl.hhvm.com/debian wheezy main > /etc/apt/sources.list.d/hhvm.list
RUN apt-get update

RUN apt-get -y install curl rake php5 php5-cli php5-curl php-pear hhvm phpunit

WORKDIR /braintree-php
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: console build

console: build
docker run -it -v="$(PWD):/braintree-php" --net="host" braintree-php /bin/bash -l -c "\
curl -sS https://getcomposer.org/installer | php -d suhosin.executor.include.whitelist=phar && \
php -d suhosin.executor.include.whitelist=phar ./composer.phar install; \
bash"

build:
docker build -t braintree-php .
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ Version [2.40.0](https://github.com/braintree/braintree_php/releases/tag/2.40.0)

* [Official documentation](https://developers.braintreepayments.com/php/sdk/server/overview)

## Developing (Docker)

The `Makefile` and `Dockerfile` will build an image containing the dependencies and drop you to a terminal where you can run tests.

```
make
```

## Testing

The unit specs can be run by anyone on any system, but the integration specs are meant to be run against a local development server of our gateway code. These integration specs are not meant for public consumption and will likely fail if run on your system. To run unit tests use rake: `rake test:unit`.
Expand Down

0 comments on commit 4a59493

Please sign in to comment.