Find file Copy path
303 lines (208 sloc) 6.27 KB

Setup local development environment on OS X

Docker & peatio-workbench

We advise you to use docker and peatio-workbench as your local development environment

Follow this guide for container-based development environment setup


  1. Install Homebrew
  2. Install Ruby
  3. Install MySQL
  4. Install Redis
  5. Install RabbitMQ
  6. Install Bitcoind
  7. Install PhantomJS
  8. Install ImageMagick
  9. Configure Peatio

1. Install Homebrew

ruby -e "$(curl -fsSL"

2. Install Ruby

Install rbenv:

brew install rbenv ruby-build

Add rbenv to bash so that it loads every time you open a terminal:

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

Install Ruby and set it as the default version:

rbenv install 2.5.0
rbenv global 2.5.0

ruby -v

Install bundler:

echo "gem: --no-ri --no-rdoc" > ~/.gemrc
gem install bundler
rbenv rehash

3. Install MySQL

Install mysql brew package:

brew install mysql

Start the mysql server:

mysql.server start

4. Install Redis

Install redis brew package:

brew install redis

Start the redis server:

brew services start redis

5. Install RabbitMQ

Install rabbitmq brew package:

brew install rabbitmq

Start the rabbitmq server:

brew services start rabbitmq

6. Install Bitcoind

Download and Install Bitcoin Core. Prepare config files:

mkdir -p ~/Library/Application\ Support/Bitcoin
touch ~/Library/Application\ Support/Bitcoin/bitcoin.conf
vim ~/Library/Application\ Support/Bitcoin/bitcoin.conf

Insert the following lines into bitcoin.conf. Don't forget to replace your username and password.


# If run on the test network instead of the real bitcoin network

# You must set rpcuser and rpcpassword to secure the JSON-RPC api
# Please make rpcpassword to something secure, `5gKAgrJv8CQr2CGUhjVbBFLSj29HnE6YGXvfykHJzS3k` for example.
# Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)

# Notify when receiving coins
walletnotify=/usr/local/sbin/rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "currency":"btc"}'

Open the bitcoin app:

open /Applications/

7. Install PhantomJS

Peatio uses Capybara with PhantomJS to do the feature tests, so if you want to run the tests. Install the PhantomJS is neccessary.

brew install phantomjs

8. Install ImageMagick

brew install imagemagick

9. Configure Peatio

Clone the project:

git clone
cd peatio
bundle install

Prepare configure files:


Configure assets

Then install and run yarn:

$ npm install -g yarn
$ bundle exec rake tmp:create yarn:install

Setup bitcoind rpc endpoint

Edit config/currencies.yml.

Replace username:password and port. username and password should only contain letters and numbers, do not use email as username.

Setup database:

bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake currencies:seed
bundle exec rake markets:seed

Run daemons

Read how to deal with Peatio daemons at Peatio daemons.

Setup the Google Authentication

  • By default, it ask for Google Authentication. This parameter can be changed in /config/application.yml -> OAUTH2_SIGN_IN_PROVIDER: google
  • Setup a new Web application on
  • Configure the Google Id, Secret and callback in /config/application.yml
  • Note: Make sure your host ISN'T an IP in the callback config. Looks like Google auth expect a callback to a DNS only
  GOOGLE_CLIENT_ID: <Google id>
  GOOGLE_CLIENT_SECRET: <Google secret>

Run Peatio

Finalize the config; open /config/application.yml Set the DNS of your host (IP won't work if you use Google Authentication)


Start the server:

bundle exec rails server -p 3000

Validate the server is working:

visit http://localhost:3000 or the public DNS of your server

Sign in with Google SSO

NOTE: At this point, the "trade" screen isn't working as you need to setup the trading server. See next step.

Step 10. Run Peatio Trading UI

Clone the repo and setup the Trading UI

cd ~/code
git clone
cd peatio-trading-ui
bundle install

Prepare configure files:


Edit the /config/application.yml and set your app DNS. Ex:


Start the server

bundle exec rails server -p 4000

Refer to the release note here :

Step 11. Install nginx to setup a reverse proxy

brew install nginx

At this point you should see nginx running

But you need to edit the default config to setup the reverse proxy. Open /usr/local/etc/nginx/nginx.conf in your favorite editor

Replace the content of the file by the following

# Make sure to add the next line to /etc/hosts.

server {
  listen           80;
  proxy_set_header Host;

  location ~ ^/(?:trading|trading-ui-assets)\/ {

  location / {

Make sure to replace with your actual server DNS

Start nginx by running sudo nginx