Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
takemiyamakoto committed Dec 17, 2016
2 parents f2fe9a5 + 61101cc commit b9e19cd
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ build/*
.idea/*
*xcworkspace*
.vscode/*
.cmake-build-debug/*
*cmake-build-debug*
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
![alt tag](Iroha_3_sm.png)

# Pull Requests
Please include a developer certificate with pull requests: http://developercertificate.org/
Please include a developer certificate with pull requests: https://www.clahub.com/agreements/hyperledger/iroha

# Architecture (Draft)

Expand Down Expand Up @@ -194,6 +194,9 @@ LevelDB
fabric3 (python library, not hyperledger/fabric)
```
## Using docker and docker-compose for development
Refer to [this guide](./docs/using_docker.md).
## Installation
```
$ git submodule init
Expand Down
29 changes: 29 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Run this script inside 'iroha-dev' docker container to build iroha and its dependencies!

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


if [ -z ${IROHA_HOME} ]; then
error "Empty variable IROHA_HOME"
fi


# build dependencies
(cd $IROHA_HOME/core/vendor/leveldb && make -j4) || error "Can't build leveldb submodule"
(cd $IROHA_HOME/core/vendor/ed25519 && make -j4) || error "Can't build ed25519 submodule"
(cd $IROHA_HOME/core/vendor/KeccakCodePackage && \
make -j4 && \
make -j4 generic64/libkeccak.a) || error "Can't build KeccakCodePackage submodule"
(cd $IROHA_HOME/core/infra/crypto && make -j4) || error "Can't build crypto submodule"

# build iroha (important: build using single thread!)
(cd $IROHA_HOME && \
(mkdir $IROHA_HOME/build || echo "[+] build directory already exists, rebuilding") && \
cd $IROHA_HOME/build && \
cmake .. && \
make ) || error "Can't build iroha"
10 changes: 5 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ machine:
checkout:
post:
- cd $IROHA_HOME
- cd $IROHA_HOME/core/vendor/leveldb; make -j 14
- cd $IROHA_HOME/core/vendor/ed25519; make -j 14
- cd $IROHA_HOME/core/vendor/leveldb; make -j 4
- cd $IROHA_HOME/core/vendor/ed25519; make -j 4
- cd $IROHA_HOME/core/vendor/Cappuccino; git pull
- cd $IROHA_HOME/core/vendor/KeccakCodePackage; make; make generic64/libkeccak.a
- cd $IROHA_HOME/core/infra/crypto/; make
Expand All @@ -33,16 +33,16 @@ dependencies:
- /tmp/protobuf
- /tmp/grpc
pre:
- if [[ ! -e /tmp/protobuf ]]; then git clone -b v3.0.0 https://github.com/google/protobuf.git /tmp/protobuf; cd /tmp/protobuf; (git cherry-pick 1760feb621a913189b90fe8595fffb74bce84598; echo Force continue); cd /tmp/protobuf; ./autogen.sh; ./configure --prefix=/usr; make -j 16; fi;
- if [[ ! -e /tmp/protobuf ]]; then git clone -b v3.0.0 https://github.com/google/protobuf.git /tmp/protobuf; cd /tmp/protobuf; (git cherry-pick 1760feb621a913189b90fe8595fffb74bce84598; echo Force continue); cd /tmp/protobuf; ./autogen.sh; ./configure --prefix=/usr; make -j 4; fi;
- cd /tmp/protobuf; sudo make install
- protoc --version

- if [[ ! -e /tmp/grpc ]]; then git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc /tmp/grpc; cd /tmp/grpc; git submodule update --init; make -j 14; fi;
- if [[ ! -e /tmp/grpc ]]; then git clone -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc /tmp/grpc; cd /tmp/grpc; git submodule update --init; make -j 4; fi;
- cd /tmp/grpc; sudo make install
- which grpc_cpp_plugin

test:
pre:
- mkdir build; cd build; cmake ..; make
override:
- ./test.sh
- ./test.sh
2 changes: 1 addition & 1 deletion core/consensus/sumeragi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ namespace sumeragi {
logger::info("sumeragi", "=+=");
logger::info("sumeragi", "start main loop");

while (true) { // TODO: replace with callback linking the event repository?
while (true) { // 千五百秋 TODO: replace with callback linking the event repository?
if(!repository::event::empty()) {
// Determine node order
determineConsensusOrder();
Expand Down
2 changes: 1 addition & 1 deletion core/vendor/Cappuccino
Submodule Cappuccino updated 4 files
+1 −2 .travis.yml
+17 −15 README.md
+161 −204 cappuccino.hpp
+13 −6 samples/chino.cpp
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '2'

services:
iroha-dev:
build: ./iroha-dev
volumes:
# mounts current folder into container's /opt.
# Note: permissions and ownership will be transfered 1-to-1.
# It means, that file owned by user:user (id=1000) will be owned by user:user (id=1000) inside container!
- "../iroha:/opt/iroha"
47 changes: 47 additions & 0 deletions docs/using_docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# How to use docker and docker-compose for `iroha` development

-----
Advantages:

- usage of docker-compose allows folder `iroha` to be mounted into container. This allows you to change code in host machine, at the same time changing it inside container(s)
- very easy to start development without dependencies conflicts

***Note***: permissions and ownership will be transfered 1-to-1 from host to container and backwards. It means, that file owned by `user:user` (**id=1000**) will be owned inside container by some other user (probably the same) **with id=1000**.
It means, that file created inside container by `root` will be owned by `root` on the host!
-----

First of all, you should clone `iroha` repository with all submodules to your host machine:

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

Then, build `iroha-dev` image using [latest docker-compose](https://github.com/docker/compose/releases) [^1]:
```bash
docker-compose build
```

Run container:
```bash
docker-compose run iroha-dev bash
```

You got shell access into container with all dependencies for `iroha`. To build `iroha`, go to `$IROHA_HOME` folder and run `build.sh`[^2]:
```bash
cd $IROHA_HOME
./build.sh
```

If you want to remove container for some reason, use [^1]:
```bash
docker-compose down
```


[^1]: You must be in the same folder with `docker-compose.yml` file.
[^2]: `build.sh` must be executed from `$IROHA_HOME` direcory inside docker container.

# How to use docker and docker-compose for production

***TBD***
75 changes: 75 additions & 0 deletions iroha-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#-----------------------------------------------------------------------
# iroha-dev - IROHA development container (base image for iroha)
#
# build : docker build -t hyperledger/iroha-dev .
#
# Copyright (c) 2016 Soramitsu,Co.,Ltd.
# All Rights Reserved.
#-----------------------------------------------------------------------
FROM ubuntu

MAINTAINER Takeshi Yonezu <[email protected]> / Bogdan Vaneev <[email protected]>

USER root

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
ENV IROHA_HOME /opt/iroha

# we use single RUN instruction to reduce number of "layers" in docker image: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices
RUN groupadd -g 168 iroha && \
useradd -u 168 -c "IROHA Administrator" -s /bin/bash -m -p $(perl -e "print(crypt('passw0rd', 'sa'));") -g iroha iroha && \
usermod -G adm,sudo iroha && \
echo "export IROHA_HOME=${IROHA_HOME}" >>/home/iroha/.bashrc && \
echo "export JAVA_HOME=${JAVA_HOME}" >>/home/iroha/.bashrc && \
echo "export IROHA_HOME=${IROHA_HOME}" >>/root/.bashrc && \
echo "export JAVA_HOME=${JAVA_HOME}" >>/root/.bashrc; \

# install dependencies
apt-get update && apt-get -y upgrade; \
apt-get -y install \
software-properties-common \
python-software-properties \
curl \
git \
make \
g++-5 \
gcc-5 \
default-jdk \
libhdf5-serial-dev \
libleveldb-dev \
libsnappy-dev\
liblmdb-dev \
libssl-dev \
snappy \
unzip \
xsltproc \
zlib1g-dev \
autoconf \
automake \
libtool \
pkg-config ; \
add-apt-repository -y ppa:ubuntu-toolchain-r/test; \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20; \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-5 20; \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20; \
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-5 20; \
curl -sSL https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz | tar -xzC /opt; \
ln -s /opt/cmake*/bin/c* /usr/local/bin; \

# install protobuf v3.0.0
cd /tmp; \
git clone -b v3.0.0 https://github.com/google/protobuf.git; \
cd protobuf; \
(git cherry-pick 1760feb621a913189b90fe8595fffb74bce84598; echo Force continue) && \
./autogen.sh && \
./configure --prefix=/usr && \
make -j4 && make install; \

# install grpc
cd /tmp; \
git clone --recursive -b $(curl -L http://grpc.io/release) https://github.com/grpc/grpc; \
cd grpc; \
make && make install


CMD ["/bin/bash"]

0 comments on commit b9e19cd

Please sign in to comment.