diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b024389072..c3b50b3078 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,27 +4,27 @@ ### If your problem is with... - - [Workbench](https://github.com/rubykube/workbench) - [Microkube](https://github.com/rubykube/microkube) - [Barong](https://github.com/rubykube/barong) - - [AppLogic](https://github.com/rubykube/applogic) - - [Peatio Trading UI](https://github.com/rubykube/peatio-trading-ui) - Cryptonode e.g [Bitcoind](https://github.com/bitcoin/bitcoin), [Geth](https://github.com/ethereum/go-ethereum), - [Rippled](https://github.com/ripple/rippled), [BitGo](https://www.bitgo.com/) + [Rippled](https://github.com/ripple/rippled), [BitGo](https://www.bitgo.com/) + - [Workbench](https://github.com/rubykube/workbench) (DEPRECATED since 2.0) + - [AppLogic](https://github.com/rubykube/applogic) (NOT SUPPORTED since 2.0) + - [Peatio Trading UI](https://github.com/rubykube/peatio-trading-ui) (NOT SUPPORTED since 1.9) Then please do not report your issue here - you should instead report it to appropriate repository or organisation. ### For local installation please use... - - [Workbench](https://github.com/rubykube/workbench) - [Microkube](https://github.com/rubykube/microkube) - - [Minimalistic local development environment with docker-compose](README.md) (Advanced) + - [Minimalistic local development environment with docker-compose](README.md) (ADVANCED) + - [Workbench](https://github.com/rubykube/workbench) (DEPRECATED since 2.0) Then please open an issue here **ONLY** if you use [Minimalistic local development environment with docker-compose](README.md): ### If your issue is... - - New feature request but it is possible to add this feature in separate service e.g AppLogic, Barong or Custom Frontend. + - New feature request but it is possible to add this feature in separate service using Event or Management API. - Described in [FAQ section](https://github.com/rubykube/peatio/issues?q=is%3Aissue+is%3Aclosed+label%3AFAQ) (we are working on it now) Then please don't open new issue here. @@ -84,7 +84,6 @@ Your PR will be reviewed by the project maintainers and community, before being It's mandatory to cover your code with tests! - ## Coding Style We hope to introduce this section soon. diff --git a/README.md b/README.md index b164dc27d1..54c48c2459 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ issues, fixes, and patches to this project. We advice to use [minimalistic environment](#minimalistic-local-development-environment-with-docker-compose) if you want to develop only Peatio and don't touch processes which interact with other components. -Otherwise we advice to use [workbench based environment](#local-development-environment-with-workbench) +Otherwise we advice to use [microkube based environment](#local-development-environment-with-microkube) ### Minimalistic local development environment with docker-compose: @@ -78,7 +78,7 @@ Otherwise we advice to use [workbench based environment](#local-development-envi ## Installation -### Local development without workbench +### Local development without microkube 1. Set up initial configuration `./bin/setup` 2. Start peatio daemons `god -c lib/daemons/daemons.god` @@ -90,37 +90,26 @@ Otherwise we advice to use [workbench based environment](#local-development-envi ``` 4. Start rails server `JWT_PUBLIC_KEY=$(cat config/secrets/rsa-key.pub| base64 -w0) rails s -b0.0.0.0` -### Local development environment with workbench: +### Local development environment with microkube: -We suggest you to start using Peatio by installing [Workbench](https://github.com/rubykube/workbench). [Workbench](https://github.com/rubykube/workbench) which is based on [Docker containers](https://www.docker.com/what-docker) is a convenient and straightforward way to start Peatio development environment. +We suggest you to start using Peatio by installing [Microkube](https://github.com/rubykube/microkube). +[Microkube](https://github.com/rubykube/microkube) which is based on +[Docker containers](https://www.docker.com/what-docker) is a convenient and straightforward way to start +Peatio development environment. #### Prerequisites * [Docker](https://docs.docker.com/install/) installed * [Docker compose](https://docs.docker.com/compose/install/) installed -#### Prepare the workbench +#### Prepare the microkube -1. Recursive clone : `git clone --recursive https://github.com/rubykube/workbench.git` -2. Move to workbench `cd workbench` -3. Build the images: `make build` -4. Run the application: `make run` +Follow microkube [README](https://github.com/rubykube/microkube) for the best Peatio installation experience. -You should add those hosts to your `/etc/hosts` file: +### Local development environment with workbench (DEPRECATED since 2.0): -``` -0.0.0.0 api.wb.local -0.0.0.0 auth.wb.local - -0.0.0.0 api.slanger.wb.local -0.0.0.0 ws.slanger.wb.local - -0.0.0.0 pma.wb.local -0.0.0.0 monitor.wb.local - -0.0.0.0 btc.wb.local -0.0.0.0 eth.wb.local -``` -Now you have peatio up and running. +[Workbench](https://github.com/rubykube/workbench) is legacy way for running Peatio locally. +Probably Workbench support will be removed soon. We advice to use [Microkube](https://github.com/rubykube/microkube) +which is more lightweight environment. #### [Barong](https://github.com/rubykube/barong) @@ -166,8 +155,8 @@ After all of that you can start using Peatio in your browser just by following o You can interact with Peatio through API: -* API v2 -* Management API v1 +* Account, Market & Public API v2 +* Management API v2 * Websocket API * Event API (AMQP) diff --git a/config/application.rb b/config/application.rb index 0c552eb1e0..0d553274d3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -50,7 +50,7 @@ class Application < Rails::Application config.active_record.raise_in_transactional_callbacks = true # Configure relative url root by setting URL_ROOT_PATH environment variable. - # Used by workbench with API Gateway. + # Used by microkube with API Gateway. config.relative_url_root = ENV.fetch('URL_ROOT_PATH', '/') config.assets.initialize_on_precompile = true diff --git a/docs/architecture.md b/docs/architecture.md index e2b68c009a..662cdd0b63 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -44,7 +44,7 @@ Components managed by bosh are: * RabbitMQ * Prometheus with Grafana for monitoring -[Bosh project](http://bosh.io/) +[Bosh project](https://bosh.io/) #### Vault @@ -82,18 +82,12 @@ Our goal and roadmap is to provide advanced API endpoints in order to be able to [Peatio project](https://github.com/rubykube/peatio) -#### Peatio Workbench +#### Peatio Microkube -Peatio workbench is the recommended development, test and integration environment for new developers. +Peatio microkube is the recommended development, test and integration environment for new developers. -[Peatio Workbench](https://github.com/rubykube/peatio-workbench) +[Peatio Microkube](https://github.com/rubykube/microkube) -#### Peatio SDK - -Peatio SDK is a javascript SDK we maintain for running QA Test scenarios. -Use Peatio SDK to interact with the server side backends such as Peatio and Barong. - -[Peatio SDK](https://github.com/rubykube/peatio-workbench) #### Coinhub diff --git a/docs/setup-osx.md b/docs/setup-osx.md deleted file mode 100644 index ae0d9fc6d1..0000000000 --- a/docs/setup-osx.md +++ /dev/null @@ -1,302 +0,0 @@ -# Setup local development environment on OS X - -## Docker & peatio-workbench - -#### We advise you to use [docker](https://www.docker.com) and [peatio-workbench](https://github.com/rubykube/peatio-workbench) as your local development environment - -#### Follow [this](setup-with-docker.md) guide for container-based development environment setup - -## Overview - -1. Install [Homebrew](http://brew.sh/) -2. Install [Ruby](https://www.ruby-lang.org/en/) -3. Install [MySQL](http://www.mysql.com/) -4. Install [Redis](http://redis.io/) -5. Install [RabbitMQ](https://www.rabbitmq.com/) -6. Install [Bitcoind](https://en.bitcoin.it/wiki/Bitcoind) -7. Install [PhantomJS](http://phantomjs.org/) -8. Install ImageMagick -9. Configure Peatio - -## 1. Install Homebrew - -```shell -ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" -``` - -## 2. Install Ruby - -Install rbenv: - -```shell -brew install rbenv ruby-build -``` - -Add rbenv to bash so that it loads every time you open a terminal: - -```shell -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: - -```shell -rbenv install 2.5.0 -rbenv global 2.5.0 - -ruby -v -``` - -Install bundler: - -```shell -echo "gem: --no-ri --no-rdoc" > ~/.gemrc -gem install bundler -rbenv rehash -``` - -## 3. Install MySQL - -Install mysql brew package: - -```shell -brew install mysql -``` - -Start the mysql server: - -```shell -mysql.server start -``` - -## 4. Install Redis - -Install redis brew package: - -```shell -brew install redis -``` - -Start the redis server: - -```shell -brew services start redis -``` - -## 5. Install RabbitMQ - -Install rabbitmq brew package: - -```shell -brew install rabbitmq -``` - -Start the rabbitmq server: - -```shell -brew services start rabbitmq -``` - -## 6. Install Bitcoind - -Download and Install [Bitcoin Core](http://bitcoin.org/en/download). -Prepare config files: - -```shell -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. - -```conf -server=1 -daemon=1 - -# If run on the test network instead of the real bitcoin network -testnet=1 - -# 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 (default: 8332 or testnet: 18332) -rpcuser=USERNAME -rpcpassword=PASSWORD -rpcport=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: - -```shell -open /Applications/Bitcoin-Qt.app -``` - -## 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. - -```shell -brew install phantomjs -``` - -## 8. Install ImageMagick - -```shell -brew install imagemagick -``` - -## 9. Configure Peatio - -#### Clone the project: - -```shell -git clone git@github.com:rubykube/peatio.git -cd peatio -bundle install -``` - -#### Prepare configure files: - -```shell -bin/init_config -``` - -#### 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: - -```shell -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](https://github.com/rubykube/peatio/blob/master/docs/peatio/daemons.md). - -#### 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 https://console.developers.google.com -- 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_CLIENT_SECRET: - GOOGLE_OAUTH2_REDIRECT_URL: http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:3000/auth/google_oauth2/callback -``` - -#### Run Peatio - -Finalize the config; open `/config/application.yml` -Set the DNS of your host (IP won't work if you use Google Authentication) - -```shell -URL_HOST: ec2-34-xxx-xxx-xx.compute-1.amazonaws.com:3000 -``` - -Start the server: - -```shell -bundle exec rails server -p 3000 -``` - -Validate the server is working: - -**visit [http://localhost:3000](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 - -```shell -cd ~/code -git clone https://github.com/rubykube/peatio-trading-ui.git -cd peatio-trading-ui -bundle install -``` - -Prepare configure files: - -```shell -bin/init_config -``` - -Edit the `/config/application.yml` and set your app DNS. Ex: - -```shell -PLATFORM_ROOT_URL: http://ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com -``` -Start the server - -```shell -bundle exec rails server -p 4000 -``` - -Refer to the release note here : https://github.com/rubykube/peatio/blob/master/docs/releases/1.5.0.md - -### 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 - -``` -# -# ATTENTION! -# -# Make sure to add the next line to /etc/hosts. -# -# 127.0.0.1 peatio.tech -# - -server { - server_name peatio.tech; - listen 80; - proxy_set_header Host peatio.tech; - - location ~ ^/(?:trading|trading-ui-assets)\/ { - proxy_pass http://127.0.0.1:4000; - } - - location / { - proxy_pass http://127.0.0.1:3000; - } -} -``` - -Make sure to replace `http://peatio.tech` with your actual server DNS - -Start nginx by running `sudo nginx` - diff --git a/docs/setup-ubuntu.md b/docs/setup-ubuntu.md deleted file mode 100644 index ff33cc7e60..0000000000 --- a/docs/setup-ubuntu.md +++ /dev/null @@ -1,356 +0,0 @@ -# Setup local development environment on Ubuntu 14.04 - -## Docker & peatio-workbench - -#### We advice you to use power of [docker](https://www.docker.com) and [peatio-workbench](https://github.com/rubykube/peatio-workbench) as local development environment - -#### Follow [this](setup-with-docker.md) guide for container-based development environmetnt setup - -### Overview - -1. Install [Ruby](https://www.ruby-lang.org/en/) -2. Install [MySQL](http://www.mysql.com/) -3. Install [Redis](http://redis.io/) -4. Install [RabbitMQ](https://www.rabbitmq.com/) -5. Install [Bitcoind](https://en.bitcoin.it/wiki/Bitcoind) -6. Install [PhantomJS](http://phantomjs.org/) -7. Install JavaScript Runtime -8. Install ImageMagick -9. Configure Peatio -10. Configure peatio-trading-ui -11. Setup the nginx reverse-proxy - -### Step 1: Install Ruby - -Install the ruby build dependencies: - -```shell -sudo apt-get install git curl zlib1g-dev build-essential \ - libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \ - libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev -``` - -Install [rvm](https://rvm.io): - -```shell -gpg --keyserver hkp://keys.gnupg.net \ - --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \ - 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - -\curl -sSL https://get.rvm.io | bash -s stable --ruby=2.5.0 --gems=rails -``` - -If you want to skip fetching documentation when installing gems, -do the following: - -```shell -echo "gem: --no-ri --no-rdoc" > ~/.gemrc -``` - -## Running backend services - -You can install manually all services like mysql, redis and rabbitmq -or you docker compose file - -```shell -docker-compose -f config/backend.yml up -d -``` - -### Step 2: Install MySQL - -```shell -sudo apt-get install mysql-server mysql-client libmysqlclient-dev -``` - -Login to mysql and set the password for the root user - -Add the environement variable (ideally in .bashrc, and don't forget to `$ source ~/.bashrc` after editing the file) - - export DATABASE_HOST= - export DATABASE_USER= - export DATABASE_PASS= - -### Step 3: Install Redis - -Be sure to install the latest stable Redis, as the package, -the distro one can be outdated: - -```shell -sudo apt-add-repository -y ppa:rwky/redis -sudo apt-get update -sudo apt-get install redis-server -``` - -### Step 4: Install RabbitMQ - -Please follow instructions [here](https://www.rabbitmq.com/install-debian.html): - -```shell -# add rabbitmq debian repo -sudo apt-add-repository 'deb http://www.rabbitmq.com/debian/ testing main' -curl http://www.rabbitmq.com/rabbitmq-signing-key-public.asc | sudo apt-key add - - -# install rabbitmq -sudo apt-get update -sudo apt-get install rabbitmq-server - -# start the rabbitmq serveer -sudo rabbitmq-plugins enable rabbitmq_management -sudo service rabbitmq-server restart - -# download and install rabbitmqadmin -wget http://localhost:15672/cli/rabbitmqadmin -chmod +x rabbitmqadmin -sudo mv rabbitmqadmin /usr/local/sbin -``` - -### Step 5: Install Bitcoind - -```shell -sudo add-apt-repository ppa:bitcoin/bitcoin -sudo apt-get update -sudo apt-get install bitcoind -``` - -#### Configure - -Prepare config files: - -```shell -mkdir -p ~/.bitcoin -touch ~/.bitcoin/bitcoin.conf -vim ~/.bitcoin/bitcoin.conf -``` - -Insert the following lines into `bitcoin.conf`, -and replce with your `username` and `password`. - -```conf -server=1 -daemon=1 - -# If run on the test network instead of the real bitcoin network -testnet=1 - -# 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 (default: 8332 or testnet: 18332) -rpcuser=USERNAME -rpcpassword=PASSWORD -rpcport=18332 - -# Notify when receiving coins -walletnotify=/usr/local/sbin/rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "currency":"btc"}' -``` - -Start bitcoin daemon: - -```shell -bitcoind -``` - -### Step 6: 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. - -```shell -sudo apt-get update -sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev - -cd /usr/local/share - -PHANTOMJS_VERISON=1.9.8 -sudo wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOMJS_VERISON-linux-x86_64.tar.bz2 - -sudo tar xjf phantomjs-$PHANTOMJS_VERISON-linux-x86_64.tar.bz2 - -sudo ln -s /usr/local/share/phantomjs-$PHANTOMJS_VERISON-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs -sudo ln -s /usr/local/share/phantomjs-$PHANTOMJS_VERISON-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs -sudo ln -s /usr/local/share/phantomjs-$PHANTOMJS_VERISON-linux-x86_64/bin/phantomjs /usr/bin/phantomjs -``` - -### Step 7: Install JavaScript Runtime - -A JavaScript Runtime is needed for Asset Pipeline to work. -Any runtime will do but Node.js is recommended. - -```shell -curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - -sudo apt-get install nodejs -``` - -### Step 8: Install ImageMagick - -```shell -sudo apt-get install imagemagick -``` - -### Step 9: Configure Peatio - -Clone the project: - -```shell -mkdir code -cd code -git clone https://github.com/rubykube/peatio.git -cd peatio -bundle install -``` - -Prepare configuration files: - -```shell -bin/init_config -``` - -Then install and run yarn: - - $ npm install -g yarn - $ bundle exec rake tmp:create yarn:install - - -#### Setup bitcoind rpc endpoint - -Edit `config/seed/currencies.yml`. - -Replace `username:password` and `port`. -`username` and `password` should only contain letters and numbers, -**do not use email as `username`**. - -#### Setup database: - -```shell -bundle exec rake db:create -bundle exec rake db:migrate -bundle exec rake currencies:seed -bundle exec rake markets:seed -``` - -#### Run daemons - -Make sure you are in /peatio directory - -Run `$ god -c lib/daemons/daemons.god` to start the deamon - -More info about Peatio daemons at [Peatio daemons](https://github.com/rubykube/peatio/blob/master/docs/peatio/daemons.md). - -#### 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 https://console.developers.google.com -- 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_CLIENT_SECRET: - GOOGLE_OAUTH2_REDIRECT_URL: http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:3000/auth/google_oauth2/callback -``` - - - -#### Run Peatio - -Finalize the config; open `/config/application.yml` -Set the DNS of your host (IP won't work if you use Google Authentication) - -```shell -URL_HOST: ec2-34-xxx-xxx-xx.compute-1.amazonaws.com:3000 -``` - -Start the server: - -```shell -$ bundle exec rails server -p 3000 -``` - -If you setup peatio-workbench on a server (like AWS ec2) -- Make sure the port 3000 is open your server -- Start the server by passing the ip in parameter - -```shell -$ bundle exec rails server -b 0.0.0.0 -``` - -Validate the server is working: - -**visit [http://localhost:3000](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 - -```shell -cd ~/code -git clone https://github.com/rubykube/peatio-trading-ui.git -cd peatio-trading-ui -bundle install -bin/init_config -``` - -Edit the `/config/application.yml` and set your app DNS. Ex: - -```shell -PLATFORM_ROOT_URL: http://ec2-xx-xx-xxx-xxx.compute-1.amazonaws.com -``` - -Start the server - -```shell -bundle exec rails server -p 4000 -``` - -Refer to the release note here : https://github.com/rubykube/peatio/blob/master/docs/releases/1.5.0.md - - -### Step 11. Install nginx to setup a reverse proxy - -``` -sudo apt-get update -sudo apt-get install nginx -sudo ufw allow 'Nginx HTTP' -systemctl status nginx - -``` -At this point you should see nginx running - -But you need to edit the default config to setup the reverse proxy. -Open `/etc/nginx/sites-available/default` in your favorite editor - -Replace the content of the file by the following - -``` -# -# ATTENTION! -# -# Make sure to add the next line to /etc/hosts. -# -# 127.0.0.1 peatio.tech -# - -server { - server_name peatio.tech; - listen 80; - proxy_set_header Host peatio.tech; - - location ~ ^/(?:trading|trading-ui-assets)\/ { - proxy_pass http://127.0.0.1:4000; - } - - location / { - proxy_pass http://127.0.0.1:3000; - } -} -``` - -Make sure to replace `http://peatio.tech` with your actual server DNS - -Verify that the syntax of the config file is valid : `$ sudo nginx -t` - -Restart nginx by running `sudo systemctl restart nginx`