Skip to content

Commit

Permalink
switch to von-indy image and allow registration by did/verkey pair in…
Browse files Browse the repository at this point in the history
…stead of seed
  • Loading branch information
andrewwhitehead committed Apr 11, 2018
1 parent 81bcfa6 commit f7b59ed
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 165 deletions.
105 changes: 22 additions & 83 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,91 +1,30 @@
FROM ubuntu:16.04
FROM von-indy:latest

ARG uid=1000
ARG indy_stream=master

ARG indy_plenum_ver=1.2.237
ARG indy_anoncreds_ver=1.0.32
ARG indy_node_ver=1.2.297
ARG python3_indy_crypto_ver=0.2.0
ARG indy_crypto_ver=0.2.0

ENV LC_ALL="C.UTF-8"
ENV LANG="C.UTF-8"
ENV SHELL="/bin/bash"

ENV RUST_LOG=error

# Install environment
RUN apt-get update -y && apt-get install -y \
git \
wget \
python3.5 \
python3-pip \
python-setuptools \
python3-nacl \
apt-transport-https \
ca-certificates \
build-essential \
pkg-config \
cmake \
libssl-dev \
libsqlite3-dev \
libsodium-dev \
curl

RUN pip3 install -U \
pip \
setuptools

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88
RUN echo "deb https://repo.sovrin.org/deb xenial $indy_stream" >> /etc/apt/sources.list

RUN useradd -ms /bin/bash -u $uid indy

RUN apt-get update -y && apt-get install -y \
indy-plenum=${indy_plenum_ver} \
indy-anoncreds=${indy_anoncreds_ver} \
indy-node=${indy_node_ver} \
python3-indy-crypto=${python3_indy_crypto_ver} \
libindy-crypto=${indy_crypto_ver} \
libzmq3-dev \
vim

USER indy
WORKDIR /home/indy

# Install rust toolchain
RUN curl -o rustup https://sh.rustup.rs
RUN chmod +x rustup
RUN ./rustup -y

# Build libindy
RUN git clone https://github.com/bcgov/indy-sdk.git
WORKDIR /home/indy/indy-sdk/libindy
RUN git fetch
RUN /home/indy/.cargo/bin/cargo build

# Move libindy to lib path
USER root
RUN mv target/debug/libindy.so /usr/lib

RUN pip3 install --upgrade setuptools
RUN pip3 install pipenv
ADD --chown=indy:indy indy_config.py /etc/indy/

USER indy
WORKDIR /home/indy

ADD bin/* /usr/local/bin/
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
build-essential \
python3.5-dev && \
pip --no-cache-dir install \
sanic==0.7.0 \
ujson==1.33 && \
apt-get remove --purge -y \
build-essential \
python3.5-dev && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

RUN awk '{if (index($1, "NETWORK_NAME") != 0) {print("NETWORK_NAME = \"sandbox\"")} else print($0)}' /etc/indy/indy_config.py> /tmp/indy_config.py
RUN mv /tmp/indy_config.py /etc/indy/indy_config.py
ADD . $HOME

ADD --chown=indy:indy . /home/indy
RUN mkdir -p $HOME/ledger/sandbox/data && \
mkdir -p $HOME/.indy_client/wallet && \
chown -R indy:indy $HOME && \
chmod -R ug+rw $HOME

RUN mkdir -p /home/indy/.indy_client/wallet
# used by validator-info
#RUN apt-get install -y --no-install-recommends iproute2 sovrin

RUN chgrp -R indy /home/indy/.indy_client/wallet \
&& chmod -R g+rwx /home/indy/.indy_client/wallet

RUN cd server && \
pipenv install -r requirements.txt
USER indy
6 changes: 3 additions & 3 deletions bin/read_ledger
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def print_txns(ledger, args):
return

# --seq_no
seq_no = args.seq_no
seq_no = int(args.seq_no) if args.seq_no is not None else None
if seq_no:
print_by_seq_no(ledger, seq_no, serializer)
return
Expand All @@ -147,8 +147,8 @@ def print_count(ledger):


def print_all(ledger, serializer):
frm = args.frm
to = args.to
frm = int(args.frm) if args.frm is not None else None
to = int(args.to) if args.to is not None else None
for txn in ledger.getAllTxn(frm=frm, to=to):
txn = serializer.serialize(txn, toBytes=False)
print(txn)
Expand Down
4 changes: 2 additions & 2 deletions bin/von_generate_transactions
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ nodeArg=""
if [ ! -z "$nodeNum" ]; then
nodeArg="--nodeNum $nodeNum"
# Only run this for nodes:
echo init_indy_node "Node$nodeNum" 9418 80
init_indy_node "Node$nodeNum" 9418 80
#echo init_indy_node "Node$nodeNum" 9418 80
#init_indy_node "Node$nodeNum" 9418 80
fi

if [ ! -z $ipAddresses ]; then
Expand Down
42 changes: 18 additions & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ services:
# Client
#
client:
build: .
image: von-base
image: von-network-base
command: 'bash -c ''./scripts/start_client.sh'''
environment:
- DOCKERHOST=${DOCKERHOST}
networks:
- von
volumes:
- von-client-cli:/home/indy/.indy-cli
- von-client-libindy:/var/lib/indy
- client-cli:/home/indy/.indy-cli
- client-data:/var/lib/indy

#
# Webserver
#
webserver:
build: .
image: von-base
image: von-network-base
command: 'bash -c ''./scripts/start_webserver.sh'''
environment:
- IP=${IP}
Expand All @@ -37,7 +35,7 @@ services:
- node4
volumes:
- ./server:/home/indy/server
- von-webserver:/home/indy/.indy-cli
- webserver-cli:/home/indy/.indy-cli
- node1-data:/home/indy/.mnt/node1
- node2-data:/home/indy/.mnt/node2
- node3-data:/home/indy/.mnt/node3
Expand All @@ -47,8 +45,7 @@ services:
# Nodes
#
node1:
build: .
image: von-base
image: von-network-base
command: 'bash -c ''./scripts/start_node.sh 1'''
networks:
- von
Expand All @@ -60,11 +57,10 @@ services:
- IPS=${IPS}
- DOCKERHOST=${DOCKERHOST}
volumes:
- node1-data:/var/lib/indy

- node1-data:/home/indy/ledger
node2:
build: .
image: von-base
image: von-network-base
command: 'bash -c ''./scripts/start_node.sh 2'''
networks:
- von
Expand All @@ -76,11 +72,10 @@ services:
- IPS=${IPS}
- DOCKERHOST=${DOCKERHOST}
volumes:
- node2-data:/var/lib/indy
- node2-data:/home/indy/ledger

node3:
build: .
image: von-base
image: von-network-base
command: 'bash -c ''./scripts/start_node.sh 3'''
networks:
- von
Expand All @@ -92,11 +87,10 @@ services:
- IPS=${IPS}
- DOCKERHOST=${DOCKERHOST}
volumes:
- node3-data:/var/lib/indy

- node3-data:/home/indy/ledger
node4:
build: .
image: von-base
image: von-network-base
command: 'bash -c ''./scripts/start_node.sh 4'''
networks:
- von
Expand All @@ -108,16 +102,16 @@ services:
- IPS=${IPS}
- DOCKERHOST=${DOCKERHOST}
volumes:
- node4-data:/var/lib/indy
- node4-data:/home/indy/ledger

networks:
von:

volumes:
client-cli:
client-data:
webserver-cli:
node1-data:
node2-data:
node3-data:
node4-data:
von-client-cli:
von-client-libindy:
von-webserver:
12 changes: 12 additions & 0 deletions indy_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
NETWORK_NAME = 'sandbox'

LEDGER_DIR = '/home/indy/ledger'
LOG_DIR = '/home/indy/log'
KEYS_DIR = LEDGER_DIR
GENESIS_DIR = LEDGER_DIR
BACKUP_DIR = '/home/indy/backup'
PLUGINS_DIR = '/home/indy/plugins'
NODE_INFO_DIR = LEDGER_DIR

CLI_BASE_DIR = '/home/indy/.indy-cli/'
CLI_NETWORK_DIR = '/home/indy/.indy-cli/networks'
15 changes: 11 additions & 4 deletions manage
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export DOCKERHOST=${APPLICATION_URL-$(docker run --net=host codenvy/che-ip)}
set -e

SCRIPT_HOME="$( cd "$( dirname "$0" )" && pwd )"
export COMPOSE_PROJECT_NAME="von"
export COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-von}"

# =================================================================================================================
# Usage:
Expand All @@ -21,7 +21,6 @@ usage () {
start - Creates the application containers from the built images
and starts the services based on the docker-compose.yml file.
Examples:
$0 start
$0 start <ip_proxy_1>,<ip_proxy_2>,<ip_proxy_3>,<ip_proxy_4> &
Expand Down Expand Up @@ -84,7 +83,15 @@ case "$1" in
docker-compose stop
;;
build)
docker-compose build
# Build von-indy image used as a base
if [ -n "$INDY_RELEASE" ]; then
INDY_BUILD_FLAGS="--build-arg indy_build_flags=--release"
fi
echo -e "\nBuilding von-indy image ..."
docker build -t 'von-indy' $INDY_BUILD_FLAGS \
'https://github.com/cywolf/von-indy.git'

docker build -t von-network-base .
;;
rebuild)
docker-compose build --no-cache
Expand All @@ -102,4 +109,4 @@ case "$1" in
usage;;
esac

popd >/dev/null
popd >/dev/null
27 changes: 16 additions & 11 deletions scripts/start_webserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ set -e

if [ ! -d "/home/indy/.indy-cli/networks/sandbox" ]; then
echo "Ledger does not exist - Creating..."
if [ ! -z "$IPS" ]; then
echo von_generate_transactions -s "$IPS"
von_generate_transactions -s "$IPS"
elif [ ! -z "$IP" ]; then
echo von_generate_transactions -i "$IP"
von_generate_transactions -i "$IP"
else
echo von_generate_transactions
von_generate_transactions
if [ ! -z "$IPS" ]; then
echo von_generate_transactions -s "$IPS"
von_generate_transactions -s "$IPS"
elif [ ! -z "$IP" ]; then
echo von_generate_transactions -i "$IP"
von_generate_transactions -i "$IP"
else
echo von_generate_transactions
von_generate_transactions
fi
fi

fi
# link node ledgers where webserver can find them
for node in 1 2 3 4; do
ln -s /home/indy/.mnt/node${node}/sandbox/data/Node${node} \
/home/indy/ledger/sandbox/data/node${node}
done

cd server && pipenv run python server.py
cd server && python server.py
Loading

0 comments on commit f7b59ed

Please sign in to comment.