Skip to content

Commit

Permalink
Merge pull request #3 from EYBlockchain/michaelconnor/compile
Browse files Browse the repository at this point in the history
feat: new CONTRACT_ORIGIN='compile' env var to compile with solc
  • Loading branch information
Westlad authored Feb 11, 2020
2 parents 0dd1619 + a36eb78 commit befe203
Show file tree
Hide file tree
Showing 14 changed files with 2,143 additions and 253 deletions.
96 changes: 96 additions & 0 deletions docker-compose.compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
version: '3.5'

services:
# A local blockchain instance
ganache:
image: trufflesuite/ganache-cli:latest
command: ganache-cli --accounts=10 --defaultBalanceEther=1000 --gasLimit=8000000
ports:
- "8545:8545"
networks:
- merkle_tree_network

# The main microservice for reconstructing a merkle tree
merkle-tree:
build:
context: ./merkle-tree
dockerfile: dev.Dockerfile
restart: on-failure
depends_on:
- ganache
- mongo-merkle-tree
volumes: # ensure relative paths are correct if embedding this microservice in another application:
- ./merkle-tree/src:/app/src
- ./merkle-tree/config:/app/config # mount point might be different if configuring from another application
- ./merkle-tree/test:/app/test
- ./merkle-tree/.babelrc:/app/.babelrc
- ./merkle-tree/setup-mongo-acl-for-new-users.js:/app/setup-mongo-acl-for-new-users.js
- /var/run/docker.sock:/var/run/docker.sock
- ./deployer/contracts/:/app/contracts:consistent # required if deploying/compiling contracts from within this service (if CONTRACT_ORIGIN = 'default' or 'compile')
# - ./deployer/build/:/app/build:consistent # required if CONTRACT_ORIGIN = 'default'
ports:
- "9000:80"
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
DEPLOYER_HOST: http://deployer # required if CONTRACT_ORIGIN = 'remote' - replace with external microservice's name
DEPLOYER_PORT: 80
CONTRACT_ORIGIN: 'compile' # Where to find the contractInstances?
# Specify one of:
# - 'remote' (to GET a solc-compiled contract interface json from a remote microservice); or
# - 'mongodb' (to get a solc-compiled contract interface json from mongodb); or
# - 'default' (to get a solc-compiled contract interface json from the app/build/ folder)
# - 'compile' (to compile contracts from a .sol file, at startup, with solc, from the /app/contracts/ folder). Useful if the application using Timber doesn't use solc to generate contract interface json's.
networks:
- merkle_tree_network

# The database storing the merkle tree
mongo-merkle-tree:
image: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=admin
- MONGO_INITDB_DATABASE=merkle_tree
volumes:
- ./merkle-tree/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- mongo-merkle-tree-volume:/data/db
networks:
- merkle_tree_network

# The deployer microservice is an example of a microservice which might deploy a merkle tree smart contract.
deployer:
build:
context: ./deployer
dockerfile: Dockerfile
restart: on-failure
depends_on:
- ganache
# - merkle-tree # required if PUSH_OR_PULL = 'push'
volumes:
- ./deployer/src:/app/src
- ./deployer/config:/app/config
- ./deployer/test:/app/test
- ./deployer/.babelrc:/app/.babelrc
- leveldb-volume:/app/db
- ./deployer/contracts/:/app/contracts:delegated
- ./deployer/build/:/app/build
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
MERKLE_TREE_HOST: http://merkle-tree
MERKLE_TREE_PORT: 80
DEPLOYER_HOST: http://deployer # included so it can lazily find itself
DEPLOYER_PORT: 80
PUSH_OR_PULL: 'pull'
# 'push': POST the contracts to the merkle-tree microservice;
# 'pull': (default) Wait for a GET request for the contracts from the merkle-tree microservice
networks:
- merkle_tree_network

volumes:
mongo-merkle-tree-volume: {}
leveldb-volume: {} # only used by the example deployer microservice

networks:
merkle_tree_network:
name: merkle_tree_network
19 changes: 10 additions & 9 deletions docker-compose.remote.push.yml → docker-compose.mongodb.push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ services:
- ./merkle-tree/.babelrc:/app/.babelrc
- ./merkle-tree/setup-mongo-acl-for-new-users.js:/app/setup-mongo-acl-for-new-users.js
- /var/run/docker.sock:/var/run/docker.sock
# - ./deployer/contracts/:/app/contracts:delegated # required if deploying contracts from within this service (if CONTRACT_LOCATION = 'default')
# - ./deployer/build/:/app/build # required if CONTRACT_LOCATION = 'default'
# - ./deployer/contracts/:/app/contracts:delegated # required if deploying contracts from within this service (if CONTRACT_ORIGIN = 'default')
# - ./deployer/build/:/app/build # required if CONTRACT_ORIGIN = 'default'
ports:
- "9000:80"
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
DEPLOYER_HOST: http://deployer # required if CONTRACT_LOCATION = 'remote' - replace with external microservice's name
DEPLOYER_HOST: http://deployer # required if CONTRACT_ORIGIN = 'remote' - replace with external microservice's name
DEPLOYER_PORT: 80
CONTRACT_LOCATION: 'mongodb' # Where to find the contractInstances?
CONTRACT_ORIGIN: 'mongodb' # Where to find the contractInstances?
# Specify one of:
# - 'remote' (to GET them from a remote microservice); or
# - 'mongodb' (to get them from mongodb); or
# - 'default' (to get them from the app/build/ folder)
# - 'remote' (to GET a solc-compiled contract interface json from a remote microservice); or
# - 'mongodb' (to get a solc-compiled contract interface json from mongodb); or
# - 'default' (to get a solc-compiled contract interface json from the app/build/ folder)
# - 'compile' (to compile contracts from a .sol file, at startup, with solc, from the /app/contracts/ folder). Useful if the application using Timber doesn't use solc to generate contract interface json's.
networks:
- merkle_tree_network

Expand All @@ -64,7 +65,7 @@ services:
restart: on-failure
depends_on:
- ganache
- merkle-tree
- merkle-tree # required if PUSH_OR_PULL = 'push'
volumes:
- ./deployer/src:/app/src
- ./deployer/config:/app/config
Expand All @@ -82,7 +83,7 @@ services:
DEPLOYER_PORT: 80
PUSH_OR_PULL: 'push'
# 'push': POST the contracts to the merkle-tree microservice;
# 'pull': Wait for a GET request for the contracts from the merkle-tree microservice
# 'pull': (default) Wait for a GET request for the contracts from the merkle-tree microservice
networks:
- merkle_tree_network

Expand Down
18 changes: 10 additions & 8 deletions docker-compose.remote.pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ services:
- ./merkle-tree/.babelrc:/app/.babelrc
- ./merkle-tree/setup-mongo-acl-for-new-users.js:/app/setup-mongo-acl-for-new-users.js
- /var/run/docker.sock:/var/run/docker.sock
# - ./deployer/contracts/:/app/contracts:delegated # required if deploying contracts from within this service (if CONTRACT_LOCATION = 'default')
# - ./deployer/build/:/app/build # required if CONTRACT_LOCATION = 'default'
# - ./deployer/contracts/:/app/contracts:delegated # required if deploying contracts from within this service (if CONTRACT_ORIGIN = 'default')
# - ./deployer/build/:/app/build # required if CONTRACT_ORIGIN = 'default'
ports:
- "9000:80"
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
DEPLOYER_HOST: http://deployer # required if CONTRACT_LOCATION = 'remote' - replace with external microservice's name
DEPLOYER_HOST: http://deployer # required if CONTRACT_ORIGIN = 'remote' - replace with external microservice's name
DEPLOYER_PORT: 80
CONTRACT_LOCATION: 'remote' # Where to find the contractInstances?
CONTRACT_ORIGIN: 'remote' # Where to find the contractInstances?
# Specify one of:
# - 'remote' (to GET them from a remote microservice); or
# - 'mongodb' (to get them from mongodb); or
# - 'default' (to get them from the app/build/ folder)
# - 'remote' (to GET a solc-compiled contract interface json from a remote microservice); or
# - 'mongodb' (to get a solc-compiled contract interface json from mongodb); or
# - 'default' (to get a solc-compiled contract interface json from the app/build/ folder)
# - 'compile' (to compile contracts from a .sol file, at startup, with solc, from the /app/contracts/ folder). Useful if the application using Timber doesn't use solc to generate contract interface json's.
networks:
- merkle_tree_network

Expand All @@ -65,6 +66,7 @@ services:
restart: on-failure
depends_on:
- ganache
# - merkle-tree # required if PUSH_OR_PULL = 'push'
volumes:
- ./deployer/src:/app/src
- ./deployer/config:/app/config
Expand All @@ -82,7 +84,7 @@ services:
DEPLOYER_PORT: 80
PUSH_OR_PULL: 'pull'
# 'push': POST the contracts to the merkle-tree microservice;
# 'pull': Wait for a GET request for the contracts from the merkle-tree microservice
# 'pull': (default) Wait for a GET request for the contracts from the merkle-tree microservice
networks:
- merkle_tree_network

Expand Down
19 changes: 10 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,21 @@ services:
- ./merkle-tree/.babelrc:/app/.babelrc
- ./merkle-tree/setup-mongo-acl-for-new-users.js:/app/setup-mongo-acl-for-new-users.js
- /var/run/docker.sock:/var/run/docker.sock
- ./deployer/contracts/:/app/contracts:consistent # required if deploying contracts from within this service (if CONTRACT_LOCATION = 'default')
- ./deployer/build/:/app/build:consistent # required if CONTRACT_LOCATION = 'default'
- ./deployer/contracts/:/app/contracts:consistent # required if deploying/compiling contracts from within this service (if CONTRACT_ORIGIN = 'default' or 'compile')
- ./deployer/build/:/app/build:consistent # required if CONTRACT_ORIGIN = 'default'
ports:
- "9000:80"
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
DEPLOYER_HOST: http://deployer # required if CONTRACT_LOCATION = 'remote' - replace with external microservice's name
DEPLOYER_HOST: http://deployer # required if CONTRACT_ORIGIN = 'remote' - replace with external microservice's name
DEPLOYER_PORT: 80
CONTRACT_LOCATION: 'default' # Where to find the contractInstances?
CONTRACT_ORIGIN: 'default' # Where to find the contractInstances?
# Specify one of:
# - 'remote' (to GET them from a remote microservice); or
# - 'mongodb' (to get them from mongodb); or
# - 'default' (to get them from the app/build/ folder)
# - 'remote' (to GET a solc-compiled contract interface json from a remote microservice); or
# - 'mongodb' (to get a solc-compiled contract interface json from mongodb); or
# - 'default' (to get a solc-compiled contract interface json from the app/build/ folder)
# - 'compile' (to compile contracts from a .sol file, at startup, with solc, from the /app/contracts/ folder). Useful if the application using Timber doesn't use solc to generate contract interface json's.
networks:
- merkle_tree_network

Expand All @@ -64,7 +65,7 @@ services:
restart: on-failure
depends_on:
- ganache
- merkle-tree
# - merkle-tree # required if PUSH_OR_PULL = 'push'
volumes:
- ./deployer/src:/app/src
- ./deployer/config:/app/config
Expand All @@ -82,7 +83,7 @@ services:
DEPLOYER_PORT: 80
PUSH_OR_PULL: 'pull'
# 'push': POST the contracts to the merkle-tree microservice;
# 'pull': Wait for a GET request for the contracts from the merkle-tree microservice
# 'pull': (default) Wait for a GET request for the contracts from the merkle-tree microservice
networks:
- merkle_tree_network

Expand Down
8 changes: 6 additions & 2 deletions merkle-tree/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ module.exports = {
# Specify one of:
# - 'remote' (to GET them from a remote microservice); or
# - 'mongodb' (to get them from mongodb); or
# - 'default' (to get them from the app/build/contracts folder)
# - 'compile' (to compile the contracts from /app/build to /app/contracts)
# - 'default' (to get them from the /app/build/contracts folder)
*/
contractLocation: process.env.CONTRACT_LOCATION,
contractOrigin: process.env.CONTRACT_ORIGIN,

contractsPath: '/app/contracts/', // where to find contract .sol files (if applicable)
buildPath: '/app/build/contracts/', // where to find the contract interface json files

// external contract deployment microservice (which deploys the MerkleTree.sol contract):
deployer: {
Expand Down
Loading

0 comments on commit befe203

Please sign in to comment.