-
Notifications
You must be signed in to change notification settings - Fork 15
Docker Network
- Get convenience script from the official docker site and run it with sudo priveleges.
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
- Add your user to the 'docker' group in order to run as non-root user.
$ sudo usermod -aG docker your-user
- Log out and re-log in for the step above to take effect.
- Note: If you are having trouble with the above steps, please visit https://docs.docker.com/engine/install/ubuntu/ for alternative methods
- Upgrade apt sources.
$ sudo apt-get upgrade
- Download Docker Compose v1.27.4
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- Change mode of the binary to executable.
$ sudo chmod +x /usr/local/bin/docker-compose
- Note: If you are having trouble installing docker-compose please refer to the official documentation: https://docs.docker.com/compose/install/
- Install pip for python 2.7XX
$ sudo apt install python-pip
- Install python yaml package
$ pip install pyyaml
- Install git if you haven't already.
$ sudo apt install git
- Create a new directory to store your source code.
$ mkdir ~/go
- Clone Protocol repository.
$ git clone https://github.com/Oneledger/protocol.git
- Create directories to map as your shared volumes and export as environment variables.
$ mkdir -p -- ~/oldata/docker ~/oldata/docker/bin
$ export DOCKERPATH=~/oldata/docker
$ export DOCKERBIN=~/oldata/docker/bin
$ export PROTOCOLPATH=~/go/protocol
- Navigate to default folder in the protocol source code.
cd ~/go/protocol/DOCKER-network/default
- Build docker image.
docker build -t olprotocol .
If HomeBrew is already installed, please skip this step
- Install using official script:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Check result:
brew -v
Some version info should come out after this command.
Here CASK is needed, we need to install desktop version to handle macOS's permission request. After installed, we can use the cli version comes with desktop version.
brew install cask docker
After this is done, open docker desktop from launchpad, it will take some time to start.
Once it shows docker is running, try:
docker ps
If there is no error, docker is installed and working fine.
brew install docker-compose
After it's installed, try:
docker-compose -v
There should be some version info come out.
macOS comes with python2
- Install pip for python 2.7XX
sudo -H python -m ensurepip
- Install python yaml package
$ pip install pyyaml
- Install git if you haven't already.
brew install git
And follow the rest part in Ubuntu section: Clone Protocol Source Code
- Visit Docker's official website to download Docker Desktop: https://docs.docker.com/docker-for-windows/install/ (Keep in mind you will need a specific version of Windows 10 or higher)
- Once you have followed all the installation steps, you will be prompted to restart.
- After you have resarted, the docker deamon will attempt to start, then will prompt you to upgrade WSL2(Windows Subsystem for Linux). Follow the link provided and follow the steps.
- Once WSL2 has been updated, the docker daemon will start.
- Install python 2.7 for Windows: https://www.python.org/download/releases/2.7/
- Install python module pyyaml
- pip for python 2.7 doesn't seem to be supported for Windows 10 so you will have to get the module from: https://pyyaml.org/wiki/PyYAML
- use 7zip to unpack the tar file and run the setup instructions specified by PyYAML (http://pyyaml.org/download/pyyaml/PyYAML-5.3.1.tar.gz)
- Note - In powershell the default command is
py
, if you have other versions of python installed on your machine use the commandpy -2
to specify python 2.7
- Install Git for Windows: https://git-scm.com/download/win
- If you are going to use the portable version remember to add the git binary path to your
PATH
environment variable.
- If you are going to use the portable version remember to add the git binary path to your
- Follow the instructions from Ubuntu section: Clone Protocol Source Code (Remember to create appropriate directories and environment variables in Windows)
In order to use the Oneledger docker network you will have to use the python command line interface application located in the protocol repository:
.../protocol/DOCKER-network/dockernet
This application allows a developer to build and run a local blockchain network with custom specifications.
General expected flow of commands:
- Initialize docker compose files (init)
- Start Network (start)
- Rebuild binaries an restart network (update) - Can be done multiple times
- Stop and remove containers and networks (stop)
usage: dockernet [-h] {init,start,update,stop,run} ...
positional arguments:
{init,start,update,stop,run}
sub-command help
init generate docker compose files
start start network with generated docker compose files
update stop containers, rebuild binaries and start back up
stop stop and remove all containers and networks
run run command inside container
optional arguments:
-h, --help show this help message and exit
- Initialize - init
usage: dockernet init [-h] [--validators VALIDATORS]
[--nonvalidators NONVALIDATORS] [--loglevel LOGLEVEL]
[--total_funds TOTAL_FUNDS]
[--maturity_time MATURITY_TIME]
[--deleg_rewards_maturity_time DELEG_REWARDS_MATURITY_TIME]
[--rewards_interval REWARDS_INTERVAL]
[--funding_deadline FUNDING_DEADLINE]
[--voting_deadline VOTING_DEADLINE]
[--timeout_commit TIMEOUT_COMMIT] [--docker]
[--subnet SUBNET] [--empty_blocks] [--eth_rpc ETH_RPC]
[--deploy_smart_contracts] [--eth_pk ETH_PK] [--default]
[--image IMAGE] [--protocol_path PROTOCOL_PATH]
[--docker_path DOCKER_PATH] [--docker_bin DOCKER_BIN]
optional arguments:
-h, --help show this help message and exit
--validators VALIDATORS
number of validator nodes
--nonvalidators NONVALIDATORS
number of non validator nodes
--loglevel LOGLEVEL level of logging for each node
--total_funds TOTAL_FUNDS
initial funds for the network
--maturity_time MATURITY_TIME
staking maturity time in blocks
--deleg_rewards_maturity_time DELEG_REWARDS_MATURITY_TIME
delegation rewards maturity in blocks
--rewards_interval REWARDS_INTERVAL
number of reward blocks stored in one record
--funding_deadline FUNDING_DEADLINE
governance proposal funding deadline in blocks
--voting_deadline VOTING_DEADLINE
governance proposal voting deadline in blocks
--timeout_commit TIMEOUT_COMMIT
time between each block creation in (ms)
--docker docker flag used by olfullnode init
--subnet SUBNET subnet of all node IP addresses
--empty_blocks create empty blocks
--eth_rpc ETH_RPC smart contract url
--deploy_smart_contracts
deploy ethereum smart contract
--eth_pk ETH_PK ethereum test private key
--default use default docker compose files
--image IMAGE name of docker image
--protocol_path PROTOCOL_PATH
protocol source code path (env variable used if not specified)
--docker_path DOCKER_PATH
docker shared volume for nodes (env variable used if not specified)
--docker_bin DOCKER_BIN
path for protocol executables (env variable used if not specified)
- Start - start
usage: dockernet start [-h] [--docker_path DOCKER_PATH]
[--docker_bin DOCKER_BIN] [--deploy_smart_contracts]
optional arguments:
-h, --help show this help message and exit
--docker_path DOCKER_PATH
docker shared volume for nodes (env variable used if not specified)
--docker_bin DOCKER_BIN
path for protocol executables (env variable used if not specified)
--deploy_smart_contracts
wait for smart contract to be deployed before starting nodes
(argument is only necessary if it was specified in the init command)
- Update - update
usage: dockernet update [-h] [--genesis]
optional arguments:
-h, --help show this help message and exit
--genesis clean node data and start from genesis stored in $DOCKERPATH
- Stop - stop
usage: dockernet stop [-h] [--clean]
optional arguments:
-h, --help show this help message and exit
--clean clean node data
- Run - run
usage: dockernet run [-h] container cmd
.
positional arguments:
container container to execute command in
cmd command to be executed in container
.
optional arguments:
-h, --help show this help message and exit
© OneLedger 2018-2020 Contact Information