version: "3"

volumes:
  postgres-db: {}
  signer-data: {}
  bloxberg-data: {}
  contract-config: {} 

services:
  evm:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/bloxberg-node:${TAG:-latest}
    build:
      context: apps/bloxbergValidatorSetup
    restart: unless-stopped
    ports:
      - ${DEV_ETH_PORT_HTTP:-63545}:8545
      - ${DEV_ETH_PORT_WS:-63546}:8546
      - 30303
    volumes:
      - ./apps/bloxbergValidatorSetup/keys:/root/keys # stores the signing key locally
      - bloxberg-data:/root/.local/share/io.parity.ethereum/

  postgres:
    image: postgres:12.5-alpine
    environment:
      POSTGRES_HOST_AUTH_METHOD: trust # for postgres user access w/o password. Obvioulsy not safe but allows easy elevated debugging.  
      # PGDATA: /tmp/cic/postgres
    ports:
      - ${DEV_POSTGRES_PORT:-63432}:5432
    command: [ "-c", "max_connections=200" ]
    volumes:
      - ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql 
      - postgres-db:/var/lib/postgresql/data

  redis:
    image: ${IMAGE_BASE_URL:-docker.io}/redis:6.0.9-alpine
    ports:
      - ${DEV_REDIS_PORT:-63379}:6379
    command: "--loglevel verbose"

    
  bootstrap:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/contract-migration:${TAG:-latest}
    build:
      context: apps/contract-migration
      dockerfile: docker/Dockerfile
      args:
          DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
          PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
          EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
          EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      DEV_DATA_DIR: ${DEV_DATA_DIR:-/tmp/cic/config}
      DEV_CONFIG_RESET: $DEV_CONFIG_RESET
      DEV_FEE_PRICE: $DEV_FEE_PRICE
      DEV_FEE_LIMIT_CALL: ${DEV_FEE_LIMIT_CALL:-8000000}
      DEV_DEBUG_LEVEL: ${DEV_DEBUG_LEVEL:-0}
      DEV_TX_WAIT: $DEV_TX_WAIT
      DEV_GAS_AMOUNT: $DEV_GAS_AMOUNT
      RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      REDIS_HOST: ${REDIS_HOST:-redis}
      REDIS_PORT: ${REDIS_PORT:-6379}
      REDIS_DB: ${REDIS_DB:-0}
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis:6379}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis:6379}
      RUN_MASK: ${RUN_MASK:-0}
      TOKEN_NAME: $TOKEN_NAME
      TOKEN_SYMBOL: $TOKEN_SYMBOL
      TOKEN_TYPE: $TOKEN_TYPE
      TOKEN_DECIMALS: $TOKEN_DECIMALS
      TOKEN_REDISTRIBUTION_PERIOD: $TOKEN_REDISTRIBUTION_PERIOD
      TOKEN_SUPPLY_LIMIT: $TOKEN_SUPPLY_LIMIT
      TOKEN_DEMURRAGE_LEVEL: $TOKEN_DEMURRAGE_LEVEL
      TOKEN_SINK_ADDRESS: $TOKEN_SINK_ADDRESS
      REDIS_HOST_CALLBACK: ${REDIS_HOST_CALLBACK:-redis}
      REDIS_PORT_CALLBACK: ${REDIS_PORT_CALLBACK:-6379}
      FAUCET_AMOUNT: ${FAUCET_AMOUNT:-0}
      WALLET_KEY_FILE: ${WALLET_KEY_FILE:-/root/keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c}
      PGP_PASSPHRASE: merman
      META_URL: http://meta:8000
    command: ["./run_job.sh"]
    depends_on:
      - evm
      - postgres
      - redis
      - cic-meta-server
      - cic-eth-tasker
    volumes:
      - contract-config:/tmp/cic/config
      - ./apps/contract-migration/testdata/pgp/:/tmp/cic/pgp



  cic-signer:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/funga-eth:${TAG:-latest}
    build: 
      context: apps/cic-signer
      dockerfile: Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_signer}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      SIGNER_SOCKET_PATH: ${SIGNER_SOCKET_PATH:-http://0.0.0.0:8000}
      SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef}
    depends_on:
      - postgres
    volumes:
      - signer-data:/run/crypto-dev-signer
      - contract-config:/tmp/cic/config/:ro
    command: ["python", "/usr/local/bin/funga-ethd", "-vv"]

  # queue handling for outgoing transactions and incoming transactions
  cic-eth-tasker:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}
    build: 
      context: apps/cic-eth
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS
      RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_eth}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      REDIS_PORT: 6379
      REDIS_HOST: redis
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
      CELERY_DEBUG: ${CELERY_DEBUG:-1}
      SIGNER_PROVIDER: ${SIGNER_PROVIDER:-http://cic-signer:8000}
      SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef}
      TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1}
    restart: unless-stopped 
    depends_on:
      - evm
      - postgres
      - redis
      - cic-signer
    volumes:
      - signer-data:/run/crypto-dev-signer
      - contract-config:/tmp/cic/config/:ro
    command:
      - /bin/bash
      - -c
      - |
        set -a
        if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi 
        set +a
        ./start_tasker.sh --aux-all -q cic-eth  -vv


  cic-eth-tracker:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}
    build: 
      context: apps/cic-eth
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS
      RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_eth}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
      CELERY_DEBUG: ${CELERY_DEBUG:-1}
      CELERY_QUEUE: ${CELERY_QUEUE:-cic-eth}
      SYNCER_LOOP_INTERVAL: ${SYNCER_LOOP_INTERVAL:-5}
      SYNCER_NO_HISTORY: ${SYNCER_NO_HISTORY:-1}
      SYNCER_OFFSET: ${SYNCER_OFFSET:-0}
      TASKS_TRANSFER_CALLBACKS: ${TASKS_TRANSFER_CALLBACKS:-"cic-eth:cic_eth.callbacks.noop.noop,cic-ussd:cic_ussd.tasks.callback_handler.transaction_callback"}
    restart: unless-stopped 
    depends_on:
      - evm
      - postgres
      - redis
    volumes:
      - contract-config:/tmp/cic/config/:ro
    command:
      - /bin/bash
      - -c
      - |
        set -a
        if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi 
        set +a
        ./start_tracker.sh -vv


  cic-eth-dispatcher:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}
    build: 
      context: apps/cic-eth
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_eth}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
      CELERY_DEBUG: ${CELERY_DEBUG:-1}
      CELERY_QUEUE: ${CELERY_QUEUE:-cic-eth}
      DISPATCHER_LOOP_INTERVAL: ${DISPATCHER_LOOP_INTERVAL:-1}
    restart: unless-stopped 
    depends_on:
      - evm
      - postgres
      - redis
    volumes:
      - contract-config:/tmp/cic/config/:ro
    command:
      - /bin/bash
      - -c
      - |
        set -a
        if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi 
        set +a
        ./start_dispatcher.sh -vv


  cic-eth-retrier:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}
    build: 
      context: apps/cic-eth
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_eth}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
      CELERY_DEBUG: ${CELERY_DEBUG:-1}
      CELERY_QUEUE: ${CELERY_QUEUE:-cic-eth}
      SYNCER_LOOP_INTERVAL: ${SYNCER_LOOP_INTERVAL:-20}
      RETRY_DELAY: ${RETRY_DELAY:-60}
      RETRY_BATCH_SIZE: ${RETRY_BATCH_SIZE:-100}
    restart: unless-stopped 
    depends_on:
      - evm
      - postgres
      - redis
    volumes:
      - contract-config:/tmp/cic/config/:ro
    command:
      - /bin/bash
      - -c
      - |
        set -a
        if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi 
        set +a
        ./start_retry.sh -vv


    
  cic-cache-tracker:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-cache:${TAG:-latest}
    build: 
      context: apps/cic-cache
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS
      RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_cache}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
      CELERY_DEBUG: ${CELERY_DEBUG:-1}
      CELERY_QUEUE: ${CELERY_QUEUE:-cic-eth}
      SYNCER_LOOP_INTERVAL: ${SYNCER_LOOP_INTERVAL:-5}
      SYNCER_OFFSET: ${SYNCER_OFFSET:-0}
      SYNCER_NO_HISTORY: ${SYNCER_NO_HISTORY:-1}
      TASKS_TRANSFER_CALLBACKS: ${TASKS_TRANSFER_CALLBACKS:-"cic-eth:cic_eth.callbacks.noop.noop,cic-ussd:cic_ussd.tasks.callback_handler.transaction_callback"}
    restart: unless-stopped 
    depends_on:
      - evm
      - postgres
      - redis
    volumes:
      - contract-config:/tmp/cic/config/:ro
    command:
      - /bin/bash
      - -c
      - |
        set -a
        if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi 
        set +a
        ./start_tracker.sh -vv


  cic-cache-tasker:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-cache:${TAG:-latest}
    build: 
      context: apps/cic-cache
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS
      RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_cache}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
      CELERY_DEBUG: ${CELERY_DEBUG:-1}
      CELERY_QUEUE: ${CELERY_QUEUE:-cic-eth}
    restart: unless-stopped 
    depends_on:
      - evm
      - postgres
      - redis
    volumes:
      - contract-config:/tmp/cic/config/:ro
    command:
      - /bin/bash
      - -c
      - |
        set -a
        if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi 
        set +a
        /usr/local/bin/cic-cache-taskerd -vv
#        "/usr/local/bin/uwsgi" \
#        --wsgi-file /root/cic_cache/runnable/daemons/server.py \
#        --http :8000 \
#        --pyargv "-vv"

  
  cic-cache-server:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-cache:${TAG:-latest}
    build: 
      context: apps/cic-cache
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_cache}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      SERVER_PORT: 8000
    restart: on-failure 
    ports:
      - ${DEV_CIC_CACHE_SERVER_PORT:-63313}:8000
    depends_on:
      - postgres
      - cic-cache-tracker
    command:
      - /bin/bash
      - -c
      - |
        set -a
        if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi 
        set +a
        /usr/local/bin/uwsgi \
        --wsgi-file /root/cic_cache/runnable/daemons/server.py \
        --http :8000 \
        --pyargv "-vv"

    volumes:
      - contract-config:/tmp/cic/config/:ro
        

  # metadata replacement server for swarm
  cic-meta-server:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-meta:${TAG:-latest}
    hostname: meta
    build:
      context: apps/cic-meta
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        NPM_REPOSITORY: ${DEV_NPM_REPOSITORY:-https://registry.npmjs.org}
    environment:
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_meta}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      DATABASE_SCHEMA_SQL_PATH: ""
      SERVER_HOST: localhost
      SERVER_PORT: 8000
      PGP_EXPORTS_DIR: /root/tests/
      PGP_PRIVATEKEY_FILE: privatekeys.asc
      PGP_PASSPHRASE: merman
      PGP_PUBLICKEY_TRUSTED_FILE: publickeys.asc
      PGP_PUBLICKEY_ACTIVE_FILE: publickeys.asc
      PGP_PUBLICKEY_ENCRYPT_FILE: publickeys.asc
      SCHEMA_SQL_PATH: scripts/initdb/server.postgres.sql
    restart: on-failure 
    ports:
      - ${DEV_CIC_META_SERVER_PORT:-63380}:8000
    depends_on:
      - postgres
    volumes:
      - ./apps/contract-migration/testdata/pgp/:/tmp/cic/pgp


  cic-user-tasker:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-user:${TAG:-latest}
    build:
      context: apps/cic-ussd
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
    environment:
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_ussd}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      APP_PASSWORD_PEPPER: ${APP_PASSWORD_PEPPER:-QYbzKff6NhiQzY3ygl2BkiKOpER8RE/Upqs/5aZWW+I=}
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_BROKER_URL:-redis://redis}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      REDIS_PORT: 6379
      REDIS_HOST: redis
      PGP_PASSPHRASE: merman
      CIC_META_URL: ${CIC_META_URL:-http://meta:8000}
    restart: unless-stopped 
    depends_on:
      - postgres
      - redis
        #- cic-meta-server
      - cic-eth-tasker
      - cic-cache-tasker
    volumes:
      - ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/
    command: "/root/start_cic_user_tasker.sh -q cic-ussd -vv"


  cic-user-server:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-user:${TAG:-latest}
    build:
      context: apps/cic-ussd
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_ussd}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      SERVER_PORT: 9500
    restart: on-failure 
    ports:
      - ${DEV_CIC_USER_SERVER_PORT:-63415}:9500
    depends_on:
      - postgres
      - redis
    command: "/root/start_cic_user_server.sh -vv"


  cic-user-ussd-server:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-user:${TAG:-latest}
    build:
      context: apps/cic-ussd
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_ussd}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      APP_PASSWORD_PEPPER: ${APP_PASSWORD_PEPPER:-QYbzKff6NhiQzY3ygl2BkiKOpER8RE/Upqs/5aZWW+I=}
      CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
      REDIS_PORT: 6379
      REDIS_HOST: redis
      SERVER_PORT: 9000
    restart: on-failure
    depends_on:
      - postgres
      - redis
      - cic-eth-tasker
      - cic-cache-tasker
    ports:
      - ${DEV_CIC_USER_USSD_SERVER_PORT:-63315}:9000
    volumes:
      - ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/
    command: "/root/start_cic_user_ussd_server.sh -vv"


  cic-notify-tasker:
    image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-notify:${TAG:-latest}
    build:
      context: apps/cic-notify
      dockerfile: docker/Dockerfile
      args:
        DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
        PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
        EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
        EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
    environment:
      DATABASE_HOST: ${DATABASE_HOST:-postgres}
      DATABASE_PORT: ${DATABASE_PORT:-5432}
      DATABASE_NAME: ${DATABASE_NAME:-cic_notify}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
      DATABASE_USER: ${DATABASE_USER:-grassroots}
      DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
      DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
      DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
      DATABASE_POOL_SIZE: 0
      AFRICASTALKING_API_USERNAME: $AFRICASTALKING_API_USERNAME
      AFRICASTALKING_API_KEY: $AFRICASTALKING_API_KEY
      AFRICASTALKING_API_SENDER_ID: $AFRICASTALKING_API_SENDER_ID
      CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
      CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
    restart: unless-stopped
    depends_on:
      - postgres
      - redis
    command: "/root/start_tasker.sh -q cic-notify -vv"

  data-seeding:
      image: ${IMAGE_BASE_URL:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/data-seeding:${TAG:-latest}
      build:
        context: apps/data-seeding
        dockerfile: docker/Dockerfile
        args:
          DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
          PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
          EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
          EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
      environment:
        DATABASE_HOST: ${DATABASE_HOST:-postgres}
        DATABASE_PORT: ${DATABASE_PORT:-5432}
        DATABASE_NAME: ${DATABASE_NAME:-cic_ussd}
        DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
        DATABASE_USER: ${DATABASE_USER:-grassroots}
        DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
        DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
        DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
        DATABASE_POOL_SIZE: 0
        CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis:6379}
        CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis:6379}
        CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS
        RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
        OUT_DIR: out
        NUMBER_OF_USERS: 10
        CONFIG: config
        CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
        TOKEN_SYMBOL: GFT
          #KEYSTORE_PATH: keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c
        WALLET_KEY_FILE: ${WALLET_KEY_FILE:-/root/keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c}
        USSD_HOST: cic-user-ussd-server
        USSD_PORT: 9000
        INCLUDE_BALANCES: y
        USSD_SSL: n
        NOTIFY_DATABASE_NAME: cic_notify
        REDIS_HOST: redis
        REDIS_PORT: 6379
        REDIS_DB: 0
        META_HOST: meta
        META_PORT: 8000
        META_URL: http://meta:8000
        USSD_PROVIDER: http://cic-user-ussd-server:9000
        CELERY_QUEUE: cic-import-ussd
        EXCLUSIONS: ussd
      command:
        - /bin/bash
        - -c
        - |
          set -a
          if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
          set +a
          ./import_ussd.sh
      volumes:
        - contract-config:/tmp/cic/config/:ro
