Skip to content

Commit

Permalink
Added tiny (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Warchant committed Mar 8, 2017
1 parent a1229da commit 754d450
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docker/tiny/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# among tested images only with ubuntu works
FROM ubuntu:latest

COPY iroha /iroha

ENV IROHA_HOME=/iroha
ENV LD_LIBRARY_PATH=/iroha/libx86_64

WORKDIR /iroha

RUN useradd -ms /bin/bash iroha
USER iroha

CMD /iroha/bin/iroha-main
46 changes: 46 additions & 0 deletions docker/tiny/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Description

In order to improve build speed of iroha and make it more stable and testable, `tiny` docker image is created.

It uses pre-built shared objects for linux x86_64 (which circle-ci is using) and very small Dockerfile.

It will be used mainly to ease build and test of iroha.

Also (probably) it will be used as minified production version.


# Note

There are binary libraries in lib* directory. We use them to copy inside tiny container.
Do not remove them please.

# How to build `iroha` using docker

Clone `iroha.git` on your directory.

```
git clone https://github.com/hyperledger/iroha.git
cd iroha
```

Build depends on the environment variable `IROHA_HOME` so you need to set it:

`export IROHA_HOME=$(pwd)`

Run build script and wait for completion.
```
${IROHA_HOME}/docker/build.sh
```


# Usage example

In order to use iroha, you need to create `${IROH_HOME}/config/sumeragi.json` config file in each node (docker container).
Create **valid** `sumeragi.json` for each node and run:

```
docker run -v /path/to/sumeragi.json:/iroha/config/sumeragin.json hyperledger/iroha-docker
```


#### Good luck!
50 changes: 50 additions & 0 deletions docker/tiny/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

if [ -z ${IROHA_HOME} ]; then
echo "[FATAL] Empty variable IROHA_HOME"
exit 1
fi

error(){
echo "[Error] $1"
exit 1
}

SOURCE=${IROHA_HOME}
BUILD=/tmp/iroha-build
TINY=${IROHA_HOME}/docker/tiny
RELEASE=${TINY}/iroha

export LD_LIBRARY_PATH=${TINY}/libx86_64

mkdir -p ${BUILD}
cd ${BUILD}
cmake ${IROHA_HOME} -DCMAKE_BUILD_TYPE=Release
make -j 10 || error "Can't build iroha"


rsync -avr ${BUILD}/bin ${RELEASE} && \
rsync -avr ${BUILD}/test_bin ${RELEASE} && \
rsync -avr ${TINY}/libx86_64 ${RELEASE} && \
rsync -avr ${TINY}/scripts ${RELEASE} && \
rsync -avr ${IROHA_HOME}/smart_contract/java_tests ${RELEASE} && \
rsync -avr ${IROHA_HOME}/jvm ${RELEASE} && \
rsync -avr ${IROHA_HOME}/external/src/google_leveldb/out-shared/lib* ${RELEASE}/libx86_64 && \
rsync -avr ${IROHA_HOME}/config ${RELEASE} || error "Can not copy release files"


docker build -t hyperledger/iroha-docker ${TINY}


rm -rf ${TINY}/iroha


cat << "EOF"
_______ ______ .__ __. _______
| \ / __ \ | \ | | | ____|
| .--. | | | | | \| | | |__
| | | | | | | | . ` | | __|
| '--' | `--' | | |\ | | |____
|_______/ \______/ |__| \__| |_______|
EOF
Binary file added docker/tiny/libx86_64/libRepository.so
Binary file not shown.
Binary file added docker/tiny/libx86_64/libcrypto.so.1.0.0
Binary file not shown.
Binary file added docker/tiny/libx86_64/libgrpc++.so.1
Binary file not shown.
Binary file added docker/tiny/libx86_64/libgrpc.so.1
Binary file not shown.
1 change: 1 addition & 0 deletions docker/tiny/libx86_64/libleveldb.so
1 change: 1 addition & 0 deletions docker/tiny/libx86_64/libleveldb.so.1
Binary file added docker/tiny/libx86_64/libleveldb.so.1.20
Binary file not shown.
Binary file added docker/tiny/libx86_64/libprotobuf.so.10
Binary file not shown.
Binary file added docker/tiny/libx86_64/libsnappy.so.1
Binary file not shown.
Binary file added docker/tiny/libx86_64/libssl.so.1.0.0
Binary file not shown.
3 changes: 3 additions & 0 deletions docker/tiny/scripts/configure-then-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
/configure.sh
/run.sh
6 changes: 6 additions & 0 deletions docker/tiny/scripts/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

${IROHA_HOME}/bin/make_sumeragi -i eth0 -n `hostname` -o /tmp/me.json && \
mkdir -p ${IROHA_HOME}/config && \
(nc configdiscovery 8000 < /tmp/me.json) > ${IROHA_HOME}/config/sumeragi.json || \
echo "[FAILED][configure.sh]"
3 changes: 3 additions & 0 deletions docker/tiny/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

su - iroha -c 'env IROHA_HOME=/usr/local/iroha /usr/local/iroha/bin/iroha-main'
18 changes: 18 additions & 0 deletions docker/tiny/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

total=0
test_path=

if [ -d ${IROHA_HOME}/build ]; then
test_path=${IROHA_HOME}/build/test_bin/*;
else
test_path=${IROHA_HOME}/test_bin/*;
fi

for file in $test_path; do
# run test
${file}
total=$((total + $?))
done

exit $total

0 comments on commit 754d450

Please sign in to comment.