 #
 # Copyright 2018 Bitwise IO, Inc.
 #
 # 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: "2.1"

services:

  settings-tp:
    image: hyperledger/sawtooth-settings-tp:nightly
    expose:
      - 4004
    depends_on:
      - validator
    command: settings-tp -vv -C tcp://validator:4004
    stop_signal: SIGKILL

  intkey-tp-rust:
    build:
      context: ..
      dockerfile: ./examples/intkey_rust/Dockerfile
      args:
        - http_proxy
        - https_proxy
        - no_proxy
    image: sawtooth-intkey-tp-rust$INSTALL_TYPE:$ISOLATION_ID
    volumes:
      - $SAWTOOTH_SDK_RUST:/project/sawtooth-sdk-rust
    expose:
      - 4004
    depends_on:
      - validator
    command: intkey-tp-rust -C tcp://validator:4004
    stop_signal: SIGKILL

  validator:
    image: hyperledger/sawtooth-validator:nightly
    expose:
      - 4004
    command: "bash -c \"\
        sawadm keygen && \
        sawset genesis \
          -k /etc/sawtooth/keys/validator.priv \
          -o config-genesis.batch && \
        sawset proposal create \
          -k /etc/sawtooth/keys/validator.priv \
          sawtooth.consensus.algorithm.name=Devmode \
          sawtooth.consensus.algorithm.version=0.1 \
          -o config.batch && \
        sawadm genesis \
          config-genesis.batch config.batch && \
        sawtooth-validator -v \
            --endpoint tcp://validator:8800 \
            --bind component:tcp://eth0:4004 \
            --bind network:tcp://eth0:8800 \
            --bind consensus:tcp://eth0:5005 \
    \""
    stop_signal: SIGKILL

  devmode:
    image: hyperledger/sawtooth-devmode-engine-rust:nightly
    command: devmode-engine-rust --connect tcp://validator:5005 -v
    stop_signal: SIGKILL

  rest-api:
    image: hyperledger/sawtooth-rest-api:nightly
    expose:
      - 4004
      - 8008
    depends_on:
      - validator
    command: sawtooth-rest-api -v --connect tcp://validator:4004 --bind rest-api:8008
    stop_signal: SIGKILL

  test-intkey-smoke-rust:
    build:
      context: ..
      dockerfile: tests/integration-tests.dockerfile
      args:
        - http_proxy
        - https_proxy
        - no_proxy
    image: integration-tests:$ISOLATION_ID
    volumes:
      - $SAWTOOTH_SDK_RUST:/project/sawtooth-sdk-rust
    expose:
      - 8008
    depends_on:
      - validator
      - rest-api
    command: nose2-3
        -c /project/sawtooth-sdk-rust/tests/nose2.cfg
        -v
        -s /project/sawtooth-sdk-rust/tests
        test_intkey_smoke.TestIntkeySmoke
    stop_signal: SIGKILL
