From 0e84492ffefb80815d424a8c7ebfcbb2e860bfa5 Mon Sep 17 00:00:00 2001 From: aza Date: Mon, 21 May 2018 20:05:55 +0200 Subject: [PATCH 1/2] docker --- .gitignore | 2 ++ docker/Dockerfile | 52 +++++++++++++++++++++++++++++++++++++++ docker/config.js | 49 ++++++++++++++++++++++++++++++++++++ docker/createdb.sh | 3 +++ docker/docker-compose.yml | 16 ++++++++++++ docker/start.sh | 3 +++ 6 files changed, 125 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/config.js create mode 100755 docker/createdb.sh create mode 100644 docker/docker-compose.yml create mode 100755 docker/start.sh diff --git a/.gitignore b/.gitignore index 37dc9bc..9af6d24 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ node_modules/ data/ data/* package-lock.json + +!docker/config.js diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..58b7028 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,52 @@ +FROM node:8 + +WORKDIR /build + +# install tools and dependencies +RUN apt-get update && \ + apt-get install -y \ + g++ \ + build-essential \ + curl \ + git \ + file \ + binutils \ + libssl-dev \ + pkg-config \ + libudev-dev \ + mysql-client + +# install rustup +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y + +# rustup directory +ENV PATH /root/.cargo/bin:$PATH + +# show backtraces +ENV RUST_BACKTRACE 1 + +# show tools +RUN rustc -vV && \ +cargo -V && \ +gcc -v &&\ +g++ -v + +# build parity +RUN git clone https://github.com/paritytech/parity.git +RUN cd parity && \ + cargo build --release --verbose && \ + ls /build/parity/target/release/parity && \ + strip /build/parity/target/release/parity + +ENV PATH /build/parity/target/release:$PATH + +# build genesis +RUN mkdir genesis +WORKDIR /build/genesis +ADD . /build/genesis +RUN npm install -g lerna +RUN npm install +RUN cp docker/config.js . + +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/build/genesis/docker/start.sh"] diff --git a/docker/config.js b/docker/config.js new file mode 100644 index 0000000..ab9a928 --- /dev/null +++ b/docker/config.js @@ -0,0 +1,49 @@ +module.exports = { + //Take snapshot up to which period? If left undefined, it will default to the last closed period. + period: 0, + + //The Author + author: "Anonymous", + + //Include block.one distribution in snapshot + include_b1: true, + + //Minimum balance required for snapshot inclusion. + //Note: 1 EOS is recommended, as there will be a minimum balance required to have the bandwidth required for a functional account. Additionally, this prevents dust from appearing as an initial accounts, and cleans up the chain. + snapshot_minimum_balance: 1, + + //Overwrite the snapshot.json in root directory. + overwrite_snapshot: true, + + //ETH node Connection Details + eth_node_type: '', + eth_node_path: '', + + //Redis Connection Details + redis_host: null, + redis_port: null, + + //Mysql Connection Details + mysql_db: "eos_snapshot_refactor", + mysql_user: "root", + mysql_pass: null, + mysql_host: "db", + mysql_port: 3306, + + // + // Advanced/Developer settings + // Probably do not need to change this. + // + + //Recalculate wallets table based on already synced + recalculate_wallets: false, + + //For if parity is syncing but you're testing for a period that you know is already synced. + skip_web3_sync: false + + //Enable fallback 1.0? (deprecated) + //registration_fallback: false, + + //Cache Signatures from/for fallback (deprecated) + //cache_signatures: true, +} diff --git a/docker/createdb.sh b/docker/createdb.sh new file mode 100755 index 0000000..a21c103 --- /dev/null +++ b/docker/createdb.sh @@ -0,0 +1,3 @@ +#!/bin/sh +echo "create database eos_snapshot_refactor;" | mysql -h db +mysql -h db eos_snapshot_refactor < bin/schema.sql diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..5662b91 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.1' + +services: + db: + image: mariadb:5 + restart: always + environment: + - MYSQL_ALLOW_EMPTY_PASSWORD=1 + volumes: + - ./data:/var/lib/mysql + genesis: + build: + context: .. + dockerfile: docker/Dockerfile + depends_on: + - db diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 0000000..5881c64 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,3 @@ +#!/bin/sh +parity --mode active --tracing off --pruning fast --db-compaction hdd --jsonrpc-apis all --chain mainnet --no-warp --cache-size 2048 & +node snapshot.js --load_config From f7dc2ac4965a39d9f714cbb7c549a79b24f38406 Mon Sep 17 00:00:00 2001 From: aza Date: Thu, 31 May 2018 22:43:00 +0000 Subject: [PATCH 2/2] better docker file --- docker/Dockerfile | 28 ++++++++++++++-------------- docker/config.js | 4 ++-- docker/docker-compose.yml | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 58b7028..0e355ec 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,28 +17,28 @@ RUN apt-get update && \ mysql-client # install rustup -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y +#RUN curl https://sh.rustup.rs -sSf | sh -s -- -y # rustup directory -ENV PATH /root/.cargo/bin:$PATH +#ENV PATH /root/.cargo/bin:$PATH # show backtraces -ENV RUST_BACKTRACE 1 +#ENV RUST_BACKTRACE 1 # show tools -RUN rustc -vV && \ -cargo -V && \ -gcc -v &&\ -g++ -v +#RUN rustc -vV && \ +#cargo -V && \ +#gcc -v &&\ +#g++ -v # build parity -RUN git clone https://github.com/paritytech/parity.git -RUN cd parity && \ - cargo build --release --verbose && \ - ls /build/parity/target/release/parity && \ - strip /build/parity/target/release/parity +#RUN git clone https://github.com/paritytech/parity.git +#RUN cd parity && \ +# cargo build --release --verbose && \ +# ls /build/parity/target/release/parity && \ +# strip /build/parity/target/release/parity -ENV PATH /build/parity/target/release:$PATH +#ENV PATH /build/parity/target/release:$PATH # build genesis RUN mkdir genesis @@ -49,4 +49,4 @@ RUN npm install RUN cp docker/config.js . EXPOSE 8080 8545 8180 -ENTRYPOINT ["/build/genesis/docker/start.sh"] +#ENTRYPOINT ["node snapshot.js --load_config"] diff --git a/docker/config.js b/docker/config.js index ab9a928..b2664f7 100644 --- a/docker/config.js +++ b/docker/config.js @@ -16,8 +16,8 @@ module.exports = { overwrite_snapshot: true, //ETH node Connection Details - eth_node_type: '', - eth_node_path: '', + eth_node_type: 'ipc', + eth_node_path: '/root/ipc/jsonrpc.ipc', //Redis Connection Details redis_host: null, diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5662b91..4543054 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -8,9 +8,24 @@ services: - MYSQL_ALLOW_EMPTY_PASSWORD=1 volumes: - ./data:/var/lib/mysql + parity: + image: parity/parity:v1.11.3 + command: --mode active --min-peers 150 --tracing off --pruning fast --db-compaction ssd --jsonrpc-apis all --chain mainnet --no-warp --cache-size 16384 --ipc-path /root/ipc/jsonrpc.ipc + volumes: + - ./io.parity.ethereum:/root/.local/share/io.parity.ethereum + - ipc:/root/ipc genesis: build: context: .. dockerfile: docker/Dockerfile + command: node snapshot.js --load_config --poll --resume --period=350 --verbose_mt --recalculate_wallets --auto-update=none + volumes: + - ipc:/root/ipc depends_on: - db + - parity + +volumes: + ipc: + external: true +