From 9632da2eaa7aa7806bd2b1f4c0dc96d400f36dd6 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 26 Jun 2017 13:38:20 +0800 Subject: [PATCH] Eos run in docker --- Docker/Dockerfile | 54 ++++++++++++++++++++++++++----- Docker/PKGBUILD | 53 ------------------------------ Docker/README.md | 23 +++++++++++-- Docker/bootstrap.sh | 11 ------- Docker/config.ini | 68 +++++++++++++++++++++++++++++++++++++++ Docker/docker-compose.yml | 10 ++++++ Docker/entrypoint.sh | 17 ++++++++++ README.md | 24 ++++++++++++++ 8 files changed, 186 insertions(+), 74 deletions(-) delete mode 100644 Docker/PKGBUILD delete mode 100755 Docker/bootstrap.sh create mode 100644 Docker/config.ini create mode 100755 Docker/docker-compose.yml create mode 100644 Docker/entrypoint.sh diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 8fbea508e93..1be080e8ede 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,8 +1,46 @@ -FROM base/archlinux:latest -MAINTAINER Nathan Hourt - -RUN pacman --noconfirm --needed -Syu clang ninja cmake git autoconf automake make m4 binutils pkg-config libtool fakeroot boost llvm -RUN mkdir /work -WORKDIR /work -COPY * /work/ -RUN bash ./bootstrap.sh +FROM ubuntu:xenial-20170619 +MAINTAINER xiaobo (peterwillcn@gmail.com) + +RUN echo 'APT::Install-Recommends 0;' >> /etc/apt/apt.conf.d/01norecommends \ + && echo 'APT::Install-Suggests 0;' >> /etc/apt/apt.conf.d/01norecommends \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y vim sudo wget htop iftop net-tools ca-certificates unzip + +RUN echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" >> /etc/apt/sources.list.d/llvm.list \ + && echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" >> /etc/apt/sources.list.d/llvm.list \ + && wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y git-core automake autoconf libtool make cmake build-essential automake pkg-config libtool \ + mpi-default-dev libicu-dev python-dev python3-dev libbz2-dev zlib1g-dev clang libssl-dev \ + clang-4.0 lldb-4.0 lld-4.0 \ + && rm -rf /var/lib/apt/lists/* + +RUN cd /tmp && wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz \ + && tar zxf boost_1_64_0.tar.gz \ + && cd boost_1_64_0 \ + && ./bootstrap.sh --with-toolset=clang \ + && ./b2 -a -j$(nproc) stage release -sHAVE_ICU=1 --sICU_PATH=/usr \ + && ./b2 install --prefix=/usr \ + && rm -rf /tmp/boost_1_64_0* + +RUN update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-4.0/bin/clang 400 \ + && update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-4.0/bin/clang++ 400 + +RUN cd /tmp && git clone https://github.com/cryptonomex/secp256k1-zkp.git \ + && tar zcf secp256k1-zkp.tgz secp256k1-zkp && cd secp256k1-zkp \ + && ./autogen.sh && ./configure && make && make install \ + && ldconfig && rm -rf /tmp/secp256k1-zkp* + +RUN cd /tmp && git clone https://github.com/EOSIO/eos.git --recursive \ + && cd eos && mkdir build && cd build \ + && cmake -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_STANDARD=14 -DCMAKE_INSTALL_PREFIX=/opt/eos ../ \ + && make -j$(nproc) && make install \ + && rm -rf /tmp/eos* + +RUN mkdir -p /opt/eos/bin/data-dir +COPY config.ini genesis.json / +COPY entrypoint.sh /sbin +RUN cd /opt/eos/bin && chmod +x /sbin/entrypoint.sh +VOLUME /opt/eos/bin/data-dir +EXPOSE 9876 8888 +ENTRYPOINT ["/sbin/entrypoint.sh"] diff --git a/Docker/PKGBUILD b/Docker/PKGBUILD deleted file mode 100644 index f5499fda902..00000000000 --- a/Docker/PKGBUILD +++ /dev/null @@ -1,53 +0,0 @@ -# Maintainer: Nathan Hourt - -pkgname=libsecp256k1-zkp-cnx -pkgver=20150529 -pkgrel=1 -pkgdesc="Optimized C library for EC operations on curve secp256k1 (Cryptonomex fork)" -arch=('i686' 'x86_64') -url="https://github.com/cryptonomex/secp256k1-zkp" -makedepends=('autoconf' 'automake' 'libtool' 'git' 'm4' 'make' 'pkg-config') -license=('MIT') -source=(${pkgname%-git}::git+https://github.com/cryptonomex/secp256k1-zkp) -sha256sums=('SKIP') -provides=('libsecp256k1' 'secp256k1') -conflicts=('libsecp256k1' 'secp256k1') - -pkgver() { - cd ${pkgname%-git} - git log -1 --format="%cd" --date=short | sed "s|-||g" -} - -build() { - cd ${pkgname%-git} - - msg2 'Building...' - ./autogen.sh - ./configure \ - --prefix=/usr \ - --sbindir=/usr/bin \ - --libexecdir=/usr/lib/libsecp256k1 \ - --sysconfdir=/etc \ - --sharedstatedir=/usr/share/libsecp256k1 \ - --localstatedir=/var/lib/libsecp256k1 \ - --disable-tests \ - --with-gnu-ld - make -} - -package() { - cd ${pkgname%-git} - - msg2 'Installing license...' - install -Dm 644 COPYING -t "$pkgdir/usr/share/licenses/libsecp256k1" - - msg2 'Installing documentation' - install -Dm 644 README.md -t "$pkgdir/usr/share/doc/libsecp256k1" - - msg2 'Installing...' - make DESTDIR="$pkgdir" install - - msg2 'Cleaning up pkgdir...' - find "$pkgdir" -type d -name .git -exec rm -r '{}' + - find "$pkgdir" -type f -name .gitignore -exec rm -r '{}' + -} diff --git a/Docker/README.md b/Docker/README.md index d9210df7710..2d8948f4af9 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -1,3 +1,22 @@ -## Example Dockerfile +### Run in docker -This is an example Dockerfile, which demonstrates how to build Eos successfully. At present, it is not intended for any other purposes than documentation. +So simple and fast operation EOS: + - [Docker](https://docs.docker.com) + - [Docker-compose](https://github.com/docker/compose) + - [Docker-volumes](https://github.com/cpuguy83/docker-volumes) + +Build eos images + +``` +cd eos/Docker +docker build -t eosio/eos . +``` + +Start docker + +``` +sudo mkdir -p /data/store/eos +docker-compose -f docker-compose.yml up +``` + +Done diff --git a/Docker/bootstrap.sh b/Docker/bootstrap.sh deleted file mode 100755 index c56ef7d49a4..00000000000 --- a/Docker/bootstrap.sh +++ /dev/null @@ -1,11 +0,0 @@ -mkdir -m 777 secp -mv PKGBUILD secp -cd secp -su -s /bin/bash -c makepkg nobody -pacman --noconfirm -U libsecp256k1-zkp-cnx-20150529-1-x86_64.pkg.tar.xz -cd .. -rm -rf secp Dockerfile README.md bootstrap.sh -git clone https://github.com/eosio/eos --recursive -cd eos -cmake -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang . -ninja diff --git a/Docker/config.ini b/Docker/config.ini new file mode 100644 index 00000000000..103a6859697 --- /dev/null +++ b/Docker/config.ini @@ -0,0 +1,68 @@ +# File to read Genesis State from +# genesis-json = +genesis-json = "/opt/eos/bin/data-dir/genesis.json" + +# the location of the block log (absolute path or relative to application data dir) +block-log-dir = "blocks" + +# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. +# checkpoint = + +# open the database in read only mode +readonly = 0 + +# the location of the chain shared memory files (absolute path or relative to application data dir) +shared-file-dir = "blockchain" + +# Minimum size MB of database shared memory file +shared-file-size = 8192 + +# The local IP and port to listen for incoming http connections. +http-server-endpoint = 127.0.0.1:8888 + +# The local IP address and port to listen for incoming connections. +listen-endpoint = 127.0.0.1:9876 + +# The IP address and port of a remote peer to sync with. +# remote-endpoint = + +# The public IP address and port that should be advertized to peers. +public-endpoint = 0.0.0.0:9876 + +# Enable block production, even if the chain is stale. +enable-stale-production = true + +# Percent of producers (0-99) that must be participating in order to produce blocks +required-participation = false + +# ID of producer controlled by this node (e.g. "init0", quotes are required, may specify multiple times) +# producer-name = +producer-name = init0 +producer-name = init1 +producer-name = init2 +producer-name = init3 +producer-name = init4 +producer-name = init5 +producer-name = init6 +producer-name = init7 +producer-name = init8 +producer-name = init9 +producer-name = init10 +producer-name = init11 +producer-name = init12 +producer-name = init13 +producer-name = init14 +producer-name = init15 +producer-name = init16 +producer-name = init17 +producer-name = init18 +producer-name = init19 +producer-name = init20 + +# Tuple of [PublicKey, WIF private key] (may specify multiple times) +private-key = ["EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"] + +# Plugin(s) to enable, may be specified multiple times +# plugin = + +plugin = eos::producer_plugin diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml new file mode 100755 index 00000000000..058be4934dc --- /dev/null +++ b/Docker/docker-compose.yml @@ -0,0 +1,10 @@ +version: "2" + +services: + eos: + image: eosio/eos + ports: + - "8888:8888" + - "9876:9876" + volumes: + - /data/store/eos:/opt/eos/bin/data-dir diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.sh new file mode 100644 index 00000000000..b372eb777e4 --- /dev/null +++ b/Docker/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh +cd /opt/eos/bin + +if [ -f '/opt/eos/bin/data-dir/config.ini' ] + then + echo + else + cp /config.ini /opt/eos/bin/data-dir +fi +if [ -f '/opt/eos/bin/data-dir/genesis.json' ] + then + echo + else + cp /genesis.json /opt/eos/bin/data-dir +fi + +exec /opt/eos/bin/eosd diff --git a/README.md b/README.md index e0250a3e86e..93f7660eae0 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,27 @@ plugin = eos::producer_plugin ``` Now it should be possible to run `eosd` and see it begin producing blocks. At present, the P2P code is not implemented, so only single-node configurations are possible. When the P2P networking is implemented, this instructions will be updated to show how to create an example multi-node testnet. + +### Run in docker + +So simple and fast operation EOS: + - [Docker](https://docs.docker.com) + - [Docker-compose](https://github.com/docker/compose) + - [Docker-volumes](https://github.com/cpuguy83/docker-volumes) + +Build eos images + +``` +cd eos/Docker +docker build -t eosio/eos . +``` + +Start docker + +``` +sudo mkdir -p /data/store/eos +docker-compose -f docker-compose.yml up +``` + +Done +