From 020ae2dfd5505f30d6763df1d63fd9f354d8483f Mon Sep 17 00:00:00 2001 From: ssallam Date: Thu, 27 Sep 2018 11:30:07 +0200 Subject: [PATCH 1/3] Enable a few env vars to make it easier to setup the docker-compose run for developers. This requires supporting changes in keeper-contracts (28507cf385a01cde0d87dc8e4a9b6b8da73f7727). --- docker-compose-local-parity-node.yml | 72 ++++++++++++++++++++++++++++ docker-compose-no-pleuston.yml | 48 +++++++++++++++++++ docker-compose.yml | 18 ++++--- start_ocean.sh | 13 +++++ start_ocean_local_parity_node.sh | 13 +++++ start_ocean_no_pleuston.sh | 13 +++++ 6 files changed, 170 insertions(+), 7 deletions(-) create mode 100644 docker-compose-local-parity-node.yml create mode 100644 docker-compose-no-pleuston.yml create mode 100644 start_ocean.sh create mode 100755 start_ocean_local_parity_node.sh create mode 100755 start_ocean_no_pleuston.sh diff --git a/docker-compose-local-parity-node.yml b/docker-compose-local-parity-node.yml new file mode 100644 index 0000000..a85d25c --- /dev/null +++ b/docker-compose-local-parity-node.yml @@ -0,0 +1,72 @@ +version: '2.1' + +# Run: docker-compose --project-name=ocean up + +services: + mongodb: + image: mongo:3.6 + ports: + - "27017:27017" + command: mongod + networks: + - backend + + parity-node: + image: parity/parity:stable + command: + --config /parity/config/validator.toml + --engine-signer 0x00bd138abd70e2f00903268f3db08f2d25677c9e + --jsonrpc-interface 0.0.0.0 + --ws-interface 0.0.0.0 + --ui-interface 0.0.0.0 + --unsafe-expose + --jsonrpc-cors all + --unlock 0x00bd138abd70e2f00903268f3db08f2d25677c9e + volumes: + - ./parity/parity/config:/parity/config:ro + - parity-node:/root/.local/share/io.parity.ethereum/ + - ./parity/parity/authorities/validator0.json:/root/.local/share/io.parity.ethereum/keys/ocean-network/validator.json:ro + - ./parity/parity/keys:/root/.local/share/io.parity.ethereum/keys/ocean-network + - ./parity/parity/authorities/validator0.pwd:/parity/validator.pwd:ro + - ./parity/parity/node0.network.key:/root/.local/share/io.parity.ethereum/network/key:ro + ports: + - 8545:8545 + networks: + - backend + + keeper-contracts: + image: oceanprotocol/keeper-contracts:${OCEAN_VERSION:-stable} + networks: + - backend + environment: + LOCAL_CONTRACTS: "true" + DEPLOY_CONTRACTS: ${DEPLOY_CONTRACTS} + DATABASE_PATH: "/ganache-db" + REUSE_DATABASE: ${REUSE_DATABASE} + NETWORK_NAME: ${KEEPER_NETWORK_NAME} + POA_HOST: "parity-node" + volumes: + - ${ARTIFACTS_FOLDER}:/keeper-contracts/artifacts/ + - ${GANACHE_DATABASE_PATH}/ganache-db:/ganache-db + + provider: + image: oceanprotocol/provider:${OCEAN_VERSION:-stable} + ports: + - 5000:5000 + networks: + - backend + depends_on: + - keeper-contracts + environment: + KEEPER_HOST: http://parity-node + DB_HOSTNAME: mongodb + LOCAL_CONTRACTS: 'true' + volumes: + - ${ARTIFACTS_FOLDER}:/usr/local/keeper-contracts/:ro + + +networks: + backend: + +volumes: + parity-node: diff --git a/docker-compose-no-pleuston.yml b/docker-compose-no-pleuston.yml new file mode 100644 index 0000000..af469b0 --- /dev/null +++ b/docker-compose-no-pleuston.yml @@ -0,0 +1,48 @@ +version: '2.1' + +# Run: docker-compose --project-name=ocean up + +services: + mongodb: + image: mongo:3.6 + ports: + - "27017:27017" + command: mongod + networks: + - backend + + keeper-contracts: + image: oceanprotocol/keeper-contracts:${OCEAN_VERSION:-stable} + ports: + - 8545:8545 + networks: + - backend + environment: + LOCAL_CONTRACTS: "true" + DEPLOY_CONTRACTS: ${DEPLOY_CONTRACTS} + DATABASE_PATH: "/ganache-db" + REUSE_DATABASE: ${REUSE_DATABASE} + NETWORK_NAME: ${KEEPER_NETWORK_NAME} + volumes: + - ${ARTIFACTS_FOLDER}:/keeper-contracts/artifacts/ + - ${GANACHE_DATABASE_PATH}/ganache-db:/ganache-db + + provider: + image: oceanprotocol/provider:${OCEAN_VERSION:-stable} + ports: + - 5000:5000 + networks: + - backend + depends_on: + - keeper-contracts + environment: + KEEPER_HOST: http://keeper-contracts + DB_HOSTNAME: mongodb + LOCAL_CONTRACTS: "true" + volumes: + - ${ARTIFACTS_FOLDER}:/usr/local/keeper-contracts/:ro + +networks: + backend: + + diff --git a/docker-compose.yml b/docker-compose.yml index 9618be0..d005c61 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,9 +18,14 @@ services: networks: - backend environment: - LOCAL_CONTRACTS: 'true' + LOCAL_CONTRACTS: "true" + DEPLOY_CONTRACTS: ${DEPLOY_CONTRACTS} + DATABASE_PATH: "/ganache-db" + REUSE_DATABASE: ${REUSE_DATABASE} + NETWORK_NAME: ${KEEPER_NETWORK_NAME} volumes: - - artifacts:/keeper-contracts/artifacts/ + - ${ARTIFACTS_FOLDER}:/keeper-contracts/artifacts/ + - ${GANACHE_DATABASE_PATH}/ganache-db:/ganache-db provider: image: oceanprotocol/provider:${OCEAN_VERSION:-stable} @@ -33,9 +38,9 @@ services: environment: KEEPER_HOST: http://keeper-contracts DB_HOSTNAME: mongodb - LOCAL_CONTRACTS: 'true' + LOCAL_CONTRACTS: "true" volumes: - - artifacts:/usr/local/keeper-contracts/:ro + - ${ARTIFACTS_FOLDER}:/usr/local/keeper-contracts/:ro pleuston: image: oceanprotocol/pleuston:${OCEAN_VERSION:-stable} @@ -48,10 +53,9 @@ services: OCEAN_HOST: provider LOCAL_CONTRACTS: 'true' volumes: - - artifacts:/pleuston/node_modules/@oceanprotocol/keeper-contracts/artifacts/:ro + - ${ARTIFACTS_FOLDER}:/pleuston/node_modules/@oceanprotocol/keeper-contracts/artifacts/:ro networks: backend: -volumes: - artifacts: + diff --git a/start_ocean.sh b/start_ocean.sh new file mode 100644 index 0000000..9a13558 --- /dev/null +++ b/start_ocean.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +export OCEAN_VERSION=latest +# Must be set to true for the first run, change it to "false" to avoid migrating the smart contracts on each run. +export DEPLOY_CONTRACTS="true" +# Ganache specific option, these two options have no effect when not running ganache-cli +export GANACHE_DATABASE_PATH="." +export REUSE_DATABASE="true" +# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local +export KEEPER_NETWORK_NAME="ganache" +export ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts + +docker-compose up \ No newline at end of file diff --git a/start_ocean_local_parity_node.sh b/start_ocean_local_parity_node.sh new file mode 100755 index 0000000..c0ea712 --- /dev/null +++ b/start_ocean_local_parity_node.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +export OCEAN_VERSION=latest +# Must be set to true for the first run, change it to "false" to avoid migrating the smart contracts on each run. +export DEPLOY_CONTRACTS="true" +# Ganache specific option, these two options have no effect when not running ganache-cli +export GANACHE_DATABASE_PATH="." +export REUSE_DATABASE="true" +# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local +export KEEPER_NETWORK_NAME="ocean_poa_net_local" +export ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts + +docker-compose -f docker-compose-local-parity-node.yml up \ No newline at end of file diff --git a/start_ocean_no_pleuston.sh b/start_ocean_no_pleuston.sh new file mode 100755 index 0000000..2428da7 --- /dev/null +++ b/start_ocean_no_pleuston.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +export OCEAN_VERSION=latest +# Must be set to true for the first run, change it to "false" to avoid migrating the smart contracts on each run. +export DEPLOY_CONTRACTS="true" +# Ganache specific option, these two options have no effect when not running ganache-cli +export GANACHE_DATABASE_PATH="." +export REUSE_DATABASE="true" +# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local +export KEEPER_NETWORK_NAME="ganache" +export ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts + +docker-compose -f docker-compose-no-pleuston.yml up \ No newline at end of file From 78e66c929222d9cd13d04b6aa365f9242e4b048d Mon Sep 17 00:00:00 2001 From: ssallam Date: Thu, 27 Sep 2018 13:15:43 +0200 Subject: [PATCH 2/3] Replace unnecessary files with arguments. --- start_ocean.sh | 17 +++++++++++++++-- start_ocean_local_parity_node.sh | 13 ------------- start_ocean_no_pleuston.sh | 13 ------------- 3 files changed, 15 insertions(+), 28 deletions(-) mode change 100644 => 100755 start_ocean.sh delete mode 100755 start_ocean_local_parity_node.sh delete mode 100755 start_ocean_no_pleuston.sh diff --git a/start_ocean.sh b/start_ocean.sh old mode 100644 new mode 100755 index 9a13558..e21eea9 --- a/start_ocean.sh +++ b/start_ocean.sh @@ -5,9 +5,22 @@ export OCEAN_VERSION=latest export DEPLOY_CONTRACTS="true" # Ganache specific option, these two options have no effect when not running ganache-cli export GANACHE_DATABASE_PATH="." -export REUSE_DATABASE="true" +export REUSE_DATABASE="false" # Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local export KEEPER_NETWORK_NAME="ganache" export ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts -docker-compose up \ No newline at end of file +if [ "$1" == "--no-pleuston" ] +then +export REUSE_DATABASE="true" +docker-compose -f docker-compose-no-pleuston.yml up + +elif [ "$1" == "--local-parity-node" ] +then +export KEEPER_NETWORK_NAME="ocean_poa_net_local" +docker-compose -f docker-compose-local-parity-node.yml up + +else +docker-compose up + +fi \ No newline at end of file diff --git a/start_ocean_local_parity_node.sh b/start_ocean_local_parity_node.sh deleted file mode 100755 index c0ea712..0000000 --- a/start_ocean_local_parity_node.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -export OCEAN_VERSION=latest -# Must be set to true for the first run, change it to "false" to avoid migrating the smart contracts on each run. -export DEPLOY_CONTRACTS="true" -# Ganache specific option, these two options have no effect when not running ganache-cli -export GANACHE_DATABASE_PATH="." -export REUSE_DATABASE="true" -# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local -export KEEPER_NETWORK_NAME="ocean_poa_net_local" -export ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts - -docker-compose -f docker-compose-local-parity-node.yml up \ No newline at end of file diff --git a/start_ocean_no_pleuston.sh b/start_ocean_no_pleuston.sh deleted file mode 100755 index 2428da7..0000000 --- a/start_ocean_no_pleuston.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -export OCEAN_VERSION=latest -# Must be set to true for the first run, change it to "false" to avoid migrating the smart contracts on each run. -export DEPLOY_CONTRACTS="true" -# Ganache specific option, these two options have no effect when not running ganache-cli -export GANACHE_DATABASE_PATH="." -export REUSE_DATABASE="true" -# Specify which ethereum client to run or connect to: kovan, ganache, or ocean_poa_net_local -export KEEPER_NETWORK_NAME="ganache" -export ARTIFACTS_FOLDER=~/.ocean/keeper-contracts/artifacts - -docker-compose -f docker-compose-no-pleuston.yml up \ No newline at end of file From d64f139c7b5ce1e8c9107bdb34bca657a1fb6c25 Mon Sep 17 00:00:00 2001 From: ssallam Date: Thu, 27 Sep 2018 14:47:06 +0200 Subject: [PATCH 3/3] Update the readme file to reflect the new options. --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index a996197..73a8956 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,16 @@ Then bring up an instance of the whole Ocean Protocol network stack with: git clone git@github.com:oceanprotocol/docker-images.git cd docker-images/ +./start_ocean.sh + +``` + +Or + +```bash +git clone git@github.com:oceanprotocol/docker-images.git +cd docker-images/ + docker-compose --project-name=ocean up ``` @@ -65,6 +75,22 @@ export OCEAN_VERSION=latest docker-compose --project-name=ocean up ``` +### Options + +The keeper-contracts component runs with ganache by default and every run will produce and deploy new instances of the keeper contracts. +Ganache can be run with a specific database path by setting the env var `REUSE_DATABASE` to "true". By default, the ganache database will be setup in the cwd. + +The following env vars enable some customization: +* DEPLOY_CONTRACTS: skip deploying smart contracts by setting this to "false", in this case `REUSE_DATABASE` should be set to True in the previous run when using ganache +* KEEPER_NETWORK_NAME: set to one of "ganache" (default), "kovan", or "ocean_poa_net_local" +* ARTIFACTS_FOLDER: this is where the deployed smart contracts abi files will be available. This can be pointed at any path you like. When running a separate pleuston instance, it may be necessary to copy the abi files from this artifacts folder to the @oceanprotocol/keeper-contracts/artifacts folder in pleuston + +A subset of the components can be run by modifying the docker-compose file directly or by using one +of the other pre-built compose files: +* `docker-compose-no-pleuston.yml` runs all components without the pleuston. This is useful for developing/debugging +the front-end app. So first the docker compose container can be started then pleuston can be started separately from source. You can also use `./start_ocean.sh --no-pleuston` to do this +* `docker-compose-local-parity-node.yml` is similar to the above with no pleuston, but runs a local parity POA node instead of ganache-cli. You can also use `./start_ocean.sh --local-parity-node` instead + ## Contributing We use GitHub as a means for maintaining and tracking issues and source code development.