This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
Permalink
Cannot retrieve contributors at this time
353 lines (332 sloc)
14.1 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
grid/examples/sawtooth/docker-compose.yaml
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2018-2020 Cargill Incorporated | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# ------------------------------------------------------------------------------ | |
version: "3.6" | |
volumes: | |
contracts-shared: | |
grid-shared: | |
gridd-alpha: | |
gridd-beta: | |
templates-shared: | |
cache-shared: | |
services: | |
# ---== shared services ==--- | |
sabre-cli: | |
image: hyperledger/sawtooth-sabre-cli:latest | |
volumes: | |
- contracts-shared:/usr/share/scar | |
- grid-shared:/grid-shared | |
container_name: sabre-cli | |
stop_signal: SIGKILL | |
tnt-contract-builder: | |
image: tnt-contract-builder | |
container_name: tnt-contract-builder | |
build: | |
context: ../.. | |
dockerfile: contracts/track_and_trace/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
volumes: | |
- grid-shared:/grid-shared | |
entrypoint: | | |
bash -c " | |
while true; do curl -s http://sawtooth-rest-api:8008/state | grep -q head; if [ $$? -eq 0 ]; then break; fi; sleep 0.5; done; | |
sabre cr --create grid_track_and_trace --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre upload --filename /tmp/track_and_trace.yaml --key /grid-shared/my_key --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create a43b46 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm a43b46 grid_track_and_trace --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee01 grid_track_and_trace --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee05 grid_track_and_trace --key /grid-shared/my_key --read --url http://sawtooth-rest-api:8008 --wait 30 | |
echo '---------========= track and trace contract is loaded =========---------' | |
" | |
schema-contract-builder: | |
image: schema-contract-builder | |
container_name: schema-contract-builder | |
build: | |
context: ../.. | |
dockerfile: contracts/schema/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
volumes: | |
- grid-shared:/grid-shared | |
entrypoint: | | |
bash -c " | |
while true; do curl -s http://sawtooth-rest-api:8008/state | grep -q head; if [ $$? -eq 0 ]; then break; fi; sleep 0.5; done; | |
sabre cr --create grid_schema --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre upload --filename /tmp/schema.yaml --key /grid-shared/my_key --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create 621dee01 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee01 grid_schema --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee05 grid_schema --key /grid-shared/my_key --read --url http://sawtooth-rest-api:8008 --wait 30 | |
echo '---------========= grid schema contract is loaded =========---------' | |
" | |
pike-contract-builder: | |
image: pike-contract-builder | |
container_name: pike-contract-builder | |
build: | |
context: ../.. | |
dockerfile: contracts/pike/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
volumes: | |
- grid-shared:/grid-shared | |
entrypoint: | | |
bash -c " | |
while true; do curl -s http://sawtooth-rest-api:8008/state | grep -q head; if [ $$? -eq 0 ]; then break; fi; sleep 0.5; done; | |
sabre cr --create grid_pike --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre upload --filename /tmp/pike.yaml --key /grid-shared/my_key --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create 621dee05 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee05 grid_pike --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
echo '---------========= pike contract is loaded =========---------' | |
" | |
product-contract-builder: | |
image: product-contract-builder | |
container_name: product-contract-builder | |
build: | |
context: ../.. | |
dockerfile: contracts/product/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
volumes: | |
- grid-shared:/grid-shared | |
entrypoint: | | |
bash -c " | |
while true; do curl -s http://sawtooth-rest-api:8008/state | grep -q head; if [ $$? -eq 0 ]; then break; fi; sleep 0.5; done; | |
sabre cr --create grid_product --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre upload --filename /tmp/product.yaml --key /grid-shared/my_key --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create 621dee05 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create 621dee01 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create 621dee02 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee05 grid_product --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee01 grid_product --key /grid-shared/my_key --read --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee02 grid_product --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
echo '---------========= grid_product contract is loaded =========---------' | |
" | |
location-contract-builder: | |
image: location-contract-builder | |
container_name: location-contract-builder | |
build: | |
context: ../.. | |
dockerfile: contracts/location/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
volumes: | |
- grid-shared:/grid-shared | |
entrypoint: | | |
bash -c " | |
while true; do curl -s http://sawtooth-rest-api:8008/state | grep -q head; if [ $$? -eq 0 ]; then break; fi; sleep 0.5; done; | |
sabre cr --create grid_location --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre upload --filename /tmp/location.yaml --key /grid-shared/my_key --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create 621dee04 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee05 grid_location --key /grid-shared/my_key --read --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee01 grid_location --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee04 grid_location --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
echo '---------========= grid_location contract is loaded =========---------' | |
" | |
purchase-order-contract-builder: | |
image: purchase-order-contract-builder:${ISOLATION_ID} | |
container_name: purchase-order-contract-builder | |
build: | |
context: ../.. | |
dockerfile: contracts/purchase_order/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
volumes: | |
- grid-shared:/grid-shared | |
entrypoint: | | |
bash -c " | |
while true; do curl -s http://sawtooth-rest-api:8008/state | grep -q head; if [ $$? -eq 0 ]; then break; fi; sleep 0.5; done; | |
sabre cr --create grid_purchase_order --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre upload --filename /tmp/purchase_order.yaml --key /grid-shared/my_key --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre ns --create 621dee06 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee05 grid_purchase_order --key /grid-shared/my_key --read --url http://sawtooth-rest-api:8008 --wait 30 | |
sabre perm 621dee06 grid_purchase_order --key /grid-shared/my_key --read --write --url http://sawtooth-rest-api:8008 --wait 30 | |
echo '---------========= grid_purchase_order contract is loaded =========---------' | |
" | |
sawtooth-validator: | |
image: hyperledger/sawtooth-validator:latest | |
volumes: | |
- grid-shared:/grid-shared | |
container_name: sawtooth-validator | |
expose: | |
- 4004 | |
- 8800 | |
- 5050 | |
ports: | |
- "4004:4004" | |
# start the validator with an empty genesis batch | |
command: | | |
bash -c " | |
if [ ! -f /etc/sawtooth/keys/validator.priv ]; then | |
sawadm keygen && | |
sawtooth keygen my_key && | |
cp /root/.sawtooth/keys/my_key.* /grid-shared && | |
sawset genesis -k /root/.sawtooth/keys/my_key.priv && | |
sawset proposal create \ | |
-k /root/.sawtooth/keys/my_key.priv \ | |
sawtooth.consensus.algorithm.name=Devmode \ | |
sawtooth.consensus.algorithm.version=0.1 \ | |
-o config.batch && | |
sawset proposal create \ | |
-k /root/.sawtooth/keys/my_key.priv \ | |
sawtooth.swa.administrators=$$(cat /grid-shared/my_key.pub) \ | |
-o sabre-admin.batch | |
sawadm genesis config-genesis.batch config.batch sabre-admin.batch | |
fi; | |
sawtooth-validator -vv \ | |
--endpoint tcp://sawtooth-validator:8800 \ | |
--bind component:tcp://eth0:4004 \ | |
--bind network:tcp://eth0:8800 \ | |
--bind consensus:tcp://eth0:5050 | |
" | |
stop_signal: SIGKILL | |
sawtooth-rest-api: | |
image: hyperledger/sawtooth-rest-api:latest | |
container_name: sawtooth-rest-api | |
ports: | |
- "8008:8008" | |
depends_on: | |
- sawtooth-validator | |
command: | | |
bash -c " | |
sawtooth-rest-api -v --connect tcp://sawtooth-validator:4004 --bind sawtooth-rest-api:8008 | |
" | |
stop_signal: SIGKILL | |
sawtooth-settings-tp: | |
image: hyperledger/sawtooth-settings-tp:latest | |
container_name: sawtooth-settings-tp | |
expose: | |
- 4004 | |
command: settings-tp -v -C tcp://sawtooth-validator:4004 | |
stop_signal: SIGKILL | |
sabre-tp: | |
image: hyperledger/sawtooth-sabre-tp:0.8 | |
container_name: sawtooth-sabre-tp | |
depends_on: | |
- sawtooth-validator | |
entrypoint: sawtooth-sabre -vv --connect tcp://sawtooth-validator:4004 | |
sawtooth-client: | |
image: hyperledger/sawtooth-shell:latest | |
container_name: sawtooth-shell | |
depends_on: | |
- sawtooth-validator | |
command: | | |
bash -c " | |
sawtooth keygen && | |
tail -f /dev/null | |
" | |
stop_signal: SIGKILL | |
devmode-rust: | |
image: hyperledger/sawtooth-devmode-engine-rust:nightly | |
container_name: sawtooth-devmode-engine-rust | |
depends_on: | |
- sawtooth-validator | |
command: | | |
devmode-engine-rust -vv --connect tcp://sawtooth-validator:5050 | |
stop_signal: SIGKILL | |
# ---== alpha node ==--- | |
db-alpha: | |
image: postgres | |
container_name: db-alpha | |
hostname: db-alpha | |
restart: always | |
expose: | |
- 5432 | |
environment: | |
POSTGRES_USER: grid | |
POSTGRES_PASSWORD: grid_example | |
POSTGRES_DB: grid | |
gridd-alpha: | |
image: gridd | |
container_name: gridd-alpha | |
hostname: gridd-alpha | |
build: | |
context: ../.. | |
dockerfile: daemon/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
- CARGO_ARGS= --features experimental | |
volumes: | |
- contracts-shared:/usr/share/scar | |
- grid-shared:/grid-shared | |
- gridd-alpha:/etc/grid/keys | |
- cache-shared:/var/cache/grid | |
expose: | |
- 8080 | |
ports: | |
- "8080:8080" | |
environment: | |
GRID_DAEMON_KEY: "alpha-agent" | |
GRID_DAEMON_ENDPOINT: "http://gridd-alpha:8080" | |
entrypoint: | | |
bash -c " | |
# we need to wait for the db to have started. | |
until PGPASSWORD=grid_example psql -h db-alpha -U grid -c '\q' > /dev/null 2>&1; do | |
>&2 echo \"Database is unavailable - sleeping\" | |
sleep 1 | |
done | |
grid keygen --skip && \ | |
grid keygen --system --skip && \ | |
grid -vv database migrate \ | |
-C postgres://grid:grid_example@db-alpha/grid && | |
gridd -vv -b 0.0.0.0:8080 -k root -C tcp://sawtooth-validator:4004 \ | |
--database-url postgres://grid:grid_example@db-alpha/grid | |
" | |
# ---== beta node ==--- | |
db-beta: | |
image: postgres | |
container_name: db-beta | |
hostname: db-beta | |
restart: always | |
expose: | |
- 5432 | |
environment: | |
POSTGRES_USER: grid | |
POSTGRES_PASSWORD: grid_example | |
POSTGRES_DB: grid | |
gridd-beta: | |
image: gridd | |
container_name: gridd-beta | |
hostname: gridd-beta | |
build: | |
context: ../.. | |
dockerfile: daemon/Dockerfile | |
args: | |
- REPO_VERSION=${REPO_VERSION} | |
- CARGO_ARGS= --features experimental | |
volumes: | |
- contracts-shared:/usr/share/scar | |
- gridd-beta:/etc/grid/keys | |
- cache-shared:/var/cache/grid | |
expose: | |
- 8080 | |
ports: | |
- "8081:8080" | |
environment: | |
GRID_DAEMON_KEY: "beta-agent" | |
GRID_DAEMON_ENDPOINT: "http://gridd-beta:8080" | |
entrypoint: | | |
bash -c " | |
# we need to wait for the db to have started. | |
until PGPASSWORD=grid_example psql -h db-beta -U grid -c '\q' > /dev/null 2>&1; do | |
>&2 echo \"Database is unavailable - sleeping\" | |
sleep 1 | |
done | |
grid keygen --skip && \ | |
grid keygen --system --skip && \ | |
grid -vv database migrate \ | |
-C postgres://grid:grid_example@db-beta/grid && | |
gridd -vv -b 0.0.0.0:8080 -C tcp://sawtooth-validator:4004 \ | |
-k root \ | |
--database-url postgres://grid:grid_example@db-beta/grid | |
" |