Skip to content

Origin Deployment

Daniel Kmak edited this page Oct 26, 2019 · 18 revisions

Origin Deployment

Prerequisites

Machine should have at least following resources available:

  • 30 GB disk space
  • 4GB RAM
  • 2 cores CPU

Currently this corresponds to AWS t2.medium instance.


Please make sure you have installed:

  • Git
  • Python 2
  • NodeJS 10, NPM
  • Yarn
  • Docker
  • Docker Compose

To use UI you also need MetaMask installed.

On Ubuntu you can install Docker using: sudo snap install docker and then sudo chmod 666 /var/run/docker.sock.

Clone and install the repository

git clone https://github.com/energywebfoundation/ewf-monorepo.git
yarn
yarn build

0. Preparation

Create a .env file in the root of the monorepo and set all the necessary variables.

You can find an example here: .env.example

  1. Set WEB3 to the Web3.js provider URL (RPC Server).
  2. Set BACKEND_URL to HOST:3030.
  3. We will fill ASSET_CONTRACT_LOOKUP_ADDRESS and MARKET_CONTRACT_ADDRESS later to reflect contract addresses from Step 2. Demo - contracts deployment

where HOST is for example http://localhost or http://<yourdomain.com>, or some other address of your machine.

1. Blockchain (aka WEB3, RPC)

If you plan to use localhost:8545 or any local blockchain (instead of Volta RPC or production chain), please make sure to start it first:

yarn run:ganache

2. Backend

yarn run:backend

From now on API should be running on following address: HOST:3030

3. Demo - contracts deployment

Deploy contracts:

yarn run:demo

4. Frontend

Run frontend:

docker-compose down -v
docker-compose up -d --build

Now you should be able to access frontend on URL: HOST

Test everything together

Having frontend deployed and MarketContractLookup address from deploying demo we need to combine these two together.

First, make sure you have correct RPC set in MetaMask. For example, if you deployed contracts to Volta, in MetaMask add and use RPC: https://volta-rpc.energyweb.org.

Now, in your browser open your domain URL: http://<yourdomain.com>.

5. Solar simulator

Here, we have 2 services to start: simulation and consumer. Consumer has to be able to access simulation port. It sends HTTP requests to simulation. By default simulation is ran on 3031 port.

Set ENERGY_API_BASE_URL="http://localhost:3031" in .env.

Start simulation:

run:simulator:server

Start consumer:

yarn run:simulator:consumer

6. Event listener

Set the optional variables from .env.example to your .env file.

Start:

yarn run:event-listener

Remark on updating Docker containers

If you have already started docker container and then modify src files of any package then you might need to rebuild them and recreate Docker volumes to have updated docker container. In this case run:

yarn build
docker-compose down -v
docker-compose build

before running docker-compose up command.

Clone this wiki locally