1

I am relatively new to docker I made a prototype using Hyperledger Sawtooth and Docker Compose I already predefined the container_name and added it to the docker-compose.yml file However, some containers run smoothly like the PostgreSQL working instance as well as the shell and custom validator, but the API ,TP(transaction processor) and subscriber are returning command not found from Bash or no such file or directory. I tried pruning the images, running it in a separate one and it is not a firewall or proxy issue. And I triple checked the file endings and paths. I am running Sawtooth Python SDK with PoET consensus. I am running Windows 10 Pro and the latest Docker versions. The backend is in Python and frontend using webpack and mithril.js although they were built successfully. Thank you in advance and sorry if the question is a bit odd I am still new to Docker.


version: '2.1'

services:

  wen-rayih-shell:
    build:
      context: .
      dockerfile: ./shell/Dockerfile
    image: sawtooth-wen-rayih-shell
    container_name: wen-rayih-shell
    volumes:
      - .:/project/sawtooth-wen-rayih
      - /project/sawtooth-wen-rayih/tracker_app/node_modules
    command: |
      bash -c "
        wen-rayih-protogen
        cd tracker_app/
        npm run build
        cd ../
        tail -f /dev/null
      "

  wen-rayih-tp:
    build:
        context: .
        dockerfile: ./processor/Dockerfile
    image: sawtooth-wen-rayih-tp
    container_name: wen-rayih-tp
    volumes:
      - '.:/project/sawtooth-wen-rayih'
    depends_on:
      - wen-rayih-shell
    command: |
      bash -c "
        sleep 1
        wen-rayih-tp -v -C tcp://validator:4004
      "

  wen-rayih-rest-api:
    build:
      context: .
      dockerfile: ./rest_api/Dockerfile
    image: wen-rayih-rest-api
    container_name: wen-rayih-rest-api
    volumes:
      - .:/project/sawtooth-wen-rayih
    ports:
      - '8000:8000'
    depends_on:
      - wen-rayih-shell
    command: |
      bash -c "
        wen-rayih-rest-api \
          -B wen-rayih-rest-api:8000 \
          -C validator:4004 \
          --db-host postgres \
          -vv
      "

  wen-rayih-subscriber:
    build:
      context: .
      dockerfile: ./subscriber/Dockerfile
    image: sawtooth-wen-rayih-subscriber
    container_name: wen-rayih-subscriber
    volumes:
      - '.:/project/sawtooth-wen-rayih'
    depends_on:
      - wen-rayih-shell
      - postgres
    command: |
      bash -c "
        wen-rayih-subscriber init \
          --db-host postgres \
          -vv
        sleep 3
        wen-rayih-subscriber subscribe \
          --db-host postgres \
          -C tcp://validator:4004 \
          -vv
      "

  settings-tp:
    image: hyperledger/sawtooth-settings-tp:1.2
    container_name: sawtooth-settings-tp
    depends_on:
      - validator
    entrypoint: settings-tp -vv -C tcp://validator:4004

  rest-api:
    image: hyperledger/sawtooth-rest-api:1.2
    container_name: sawtooth-rest-api
    expose:
      - 8008
    ports:
      - '8008:8008'
    depends_on:
      - validator
    entrypoint: sawtooth-rest-api -vv -C tcp://validator:4004 --bind rest-api:8008

  validator:
    image: hyperledger/sawtooth-validator:1.2
    container_name: sawtooth-validator
    expose:
      - 4004
    ports:
      - '4004:4004'
    command: |
      bash -c "
        if [ ! -f /etc/sawtooth/keys/validator.priv ]; then
          sawadm keygen
          sawtooth keygen my_key
          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
          sawadm genesis config-genesis.batch config.batch
        fi;
        sawtooth-validator -vv \
          --endpoint tcp://validator:8800 \
          --bind component:tcp://eth0:4004 \
          --bind network:tcp://eth0:8800 \
          --bind consensus:tcp://eth0:5050
      "

  devmode-engine:
    image: hyperledger/sawtooth-devmode-engine-rust:1.2
    expose:
      - 5050
    ports:
      - '5050:5050'
    container_name: sawtooth-devmode-engine-rust-default
    depends_on:
      - validator
    entrypoint: devmode-engine-rust --connect tcp://validator:5050

  postgres:
    image: postgres:alpine
    container_name: wen-rayih-postgres
    restart: always
    environment:
      POSTGRES_USER: sawtooth
      POSTGRES_PASSWORD: sawtooth
      POSTGRES_DB: wen-rayih
    ports:
      - '5432:5432'

  adminer:
    image: adminer
    container_name: wen-rayih-adminer
    restart: always
    ports:
      - '8080:8080'

  tracker-app:
    build: ./tracker_app
    image: wen-rayih-tracker-app
    container_name: tracker-app
    volumes:
      - ./tracker_app/public/:/usr/local/apache2/htdocs/
    expose:
      - 80
    ports:
      - '8040:80'
    depends_on:
      - wen-rayih-shell
      - wen-rayih-rest-api

george
  • 11
  • 2
  • 1
    Question is not clear. Please paste your compose file or give more details on which images you're using, how are you setting up the network. BTW, there's are multiple docker-compose files in the source code. Also, the official documentation has explanation on how to use it. – Arun Apr 30 '20 at 16:03
  • hello, yes I followed the documentation of sawtooth, you mean there are many compose files in sawtooth's source code? – george May 01 '20 at 07:47

1 Answers1

0

in order to execute these "commands" wen-rayih-rest-api, wen-rayih-subscriber, wen-rayih-tp you have to create the files that represent them.

E.g file: ./bin/wen-rayih-rest-api

import os
import sys


TOP_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.insert(0, os.path.join(TOP_DIR, 'rest_api'))

from wen-rayih-rest-api.main import main

if __name__ == "__main__":
    main()

Supposing that you have already developed these files inside a bin folder in your project you need to tell the containers where to find these files by adding the bin folder in the path of each container. So in the Dockerfile of the subscriber, the TP and the API you have to add a command like this:

ENV PATH $PATH:/project/sawtooth-wen-rayih/bin.

Charalarg
  • 75
  • 1
  • 9