EOS Developing: Right way to building from docker
EOS Developing: Right way to building from docker
This tutorial is base on dawn-2.x
Why ? Because dawn-2.x is the most stable version, it wouldn't change frequently.
Why this tutorial? Because the official repo or document has some mistakes that caused by out-of-date document updating.
First, pull down the git repo
git clone -b dawn-2.x --depth 1 https://github.com/EOSIO/eos.git --recursive
Change Dockerfile
cd eos/Docker
cp Dockerfile Dockerfile.bak
vim Dockerfile
To simply build a correct image
Just replace text start from line 75 with below:
RUN git clone -b dawn-2.x --depth 1 https://github.com/EOSIO/eos.git --recursive \
&& cd eos \
&& cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_LLVM_CONFIG=/opt/wasm/bin/llvm-config -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/opt/eos -DSecp256k1_ROOT_DIR=/usr/local \
&& cmake --build /tmp/build --target install
FROM ubuntu:16.04
LABEL author="Xiaobo Tian <[email protected]>" \
maintainer="Huang-Ming Huang <[email protected]>" \
version="0.2.1" \
description="This is an eosio/eos image"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/lib/* /usr/local/lib/
COPY --from=builder /tmp/build/install/bin /opt/eos/bin
COPY --from=builder /tmp/build/contracts /contracts
COPY --from=builder /eos/Docker/config.ini /eos/genesis.json /
COPY start_eosd.sh /opt/eos/bin/start_eosd.sh
RUN chmod +x /opt/eos/bin/start_eosd.sh
ENV LD_LIBRARY_PATH /usr/local/lib
VOLUME /opt/eos/bin/data-dir
ENV PATH /opt/eos/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Or download the entire file from here: learn_eos/correct.Dockerfile at master · panyanyany/learn_eos · GitHub
** remember to override the Dockerfile
To build a powerful image which could compile contracts
Replace text start from line 75 with below:
RUN git clone -b dawn-2.x --depth 1 https://github.com/EOSIO/eos.git --recursive \
&& cd eos \
&& cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_LLVM_CONFIG=/opt/wasm/bin/llvm-config -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/opt/eos -DSecp256k1_ROOT_DIR=/usr/local \
&& cmake --build /tmp/build --target install
# FROM ubuntu:16.04
LABEL author="Xiaobo Tian <[email protected]>" \
maintainer="Huang-Ming Huang <[email protected]>" \
version="0.2.1" \
description="This is an eosio/eos image"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install openssl && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y vim
RUN mkdir -p /opt/eos/bin && \
cp -rp /tmp/build/install/bin /opt/eos && \
cp -rp /tmp/build/contracts /contracts && \
cp -rp /eos/Docker/config.ini / && \
cp -rp /eos/genesis.json /
COPY start_eosd.sh /opt/eos/bin/start_eosd.sh
RUN chmod +x /opt/eos/bin/start_eosd.sh
RUN sed -i.bak 's/-I $filePath/-I $filePath -I $filePath\/../g' /opt/eos/bin/eoscpp
ENV LD_LIBRARY_PATH /usr/local/lib
VOLUME /opt/eos/bin/data-dir
ENV PATH /opt/eos/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Or download the entire file from here: https://github.com/panyanyany/learn_eos/blob/master/dawn-2.x/Docker/full.Dockerfile
** remember to override the Dockerfile
Build docker image
docker build . -t eosio/eos-dawn-2.x-fullfix
Run as docker services
Override origin docker-compose.yml with learn_eos/docker-compose.yml at master · panyanyany/learn_eos · GitHub
Then open 2 terminal windows.
To set up docker services:
### In terminal #1
cd eos/Docker
docker-compose up
To check whether eosc
command works:
### In terminal #2
cd eos/Docker
alias eosc='docker-compose exec walletd eosc -H eosd'
eosc get info
Sample Result:
{
"server_version": "8746d320",
"head_block_num": 9,
"last_irreversible_block_num": 0,
"head_block_id": "00000009eb010cefe6d3853465a0f1fdcc24d1c03a00794f4183b1a3d279990e",
"head_block_time": "2018-02-13T04:25:20",
"head_block_producer": "initj",
"recent_slots": "1111111111111111111111111111111111111111111111111111111111111111",
"participation_rate": "1.00000000000000000"
}
To check whether wallet available:
### In terminal #2
eosc wallet create
Sample Result:
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"<--- This is your wallet password --->"
Now you are able to follow official’s tutorials which is Tutorials · EOSIO/eos Wiki · GitHub to create accounts and import wallets.