Skip to content

Origin Deployment

Joseph Bagaric edited this page Apr 2, 2020 · 18 revisions

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 12, 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/origin.git
yarn
yarn build

0. Preparation

  • Install Postgres and create a clean new database named origin. Make sure that you have a user named postgres with a password postgres.
  • Make sure you have created a .env file in the root of the monorepo and that all necessary variables are set. Use .env.example as an example of how the .env file should look.
  1. Set WEB3 to the Web3.js provider URL (RPC Server).
  2. Set BACKEND_URL to HOST:3030.

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. Migrations

yarn migrate:demo

Note: This will overwrite any DB changes you have and deploy new smart contracts. If you're using it in a production environment, run this instead:

yarn migrate:prod

3. Backend

yarn run:backend

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

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 service started and contracts deployed we can test the application.

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. If you've used http://localhost:8545, use http://localhost:8545 in MetaMask and so on.

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

5. Solar simulator

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

Start simulator:

yarn run:simulator

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.

Docker deployment [new flow]

git clone git@github.com:energywebfoundation/origin.git
mv docker-compose.yml docker-compose.old.yml
mv docker-compose.collective.yml docker-compose.yml
yarn

Copy .env.example to .env and set ORM_DATABASE_DOCKER=TRUE.

If you want to use local Ganache network then start it, for example with command:

yarn run:ganache # Skip if using other chain, but change .env WEB3 property

When your WEB3 endpoint is up and running, run these commands:

yarn build
TAG=canary ./origin-docker-run.sh
yarn run:demo