EOS技术爱好者区块链之虚拟货币EOS区块链

EOS Developing: 构建 docker 镜像的正确方

2018-02-13  本文已影响238人  panyanyany

本教程基于 dawn-2.x
因为 dawn-2.x 是最稳定的版本,不会变来变去。

为何会有这篇教程? 因为官方仓库里的教程随着代码更新已经过时了,遗留了很多错误。

首先 clone eos 仓库到本地

git clone -b dawn-2.x --depth 1 https://github.com/EOSIO/eos.git --recursive

修改 Dockerfile

cd eos/Docker
cp Dockerfile Dockerfile.bak
vim Dockerfile

如果只是简单地构建一个正确的镜像

从 75 行开始,用下面的代码替代:

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 <peterwillcn@gmail.com>" \
  maintainer="Huang-Ming Huang <huangh@objectcomputing.com>" \
  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

或者直接下载我替换好的文件: learn_eos/correct.Dockerfile at master · panyanyany/learn_eos · GitHub
** 记得要覆盖掉 Dockerfile 哦!

如果想构建一个强大的,可以用来编译合约的镜像

从 75 行开始,用下面的代码替代:

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 <peterwillcn@gmail.com>" \
  maintainer="Huang-Ming Huang <huangh@objectcomputing.com>" \
  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

或者下载我修改好的文件: https://github.com/panyanyany/learn_eos/blob/master/dawn-2.x/Docker/full.Dockerfile

** 记得要覆盖掉 Dockerfile 哦!

构建 docker 镜像

docker build . -t eosio/eos-dawn-2.x-fullfix

以 docker 服务运行

首先用 learn_eos/docker-compose.yml at master · panyanyany/learn_eos · GitHub覆盖 docker-compose.yml

然后打开2个终端窗口

启动 docker 服务:

### In terminal #1
cd eos/Docker
docker-compose up

检查 eosc 命令是否正常:

### In terminal #2
cd eos/Docker
alias eosc='docker-compose exec walletd eosc -H eosd'
eosc get info

结果示例:

{
  "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"
}

检查钱包是否可用:

### In terminal #2
eosc wallet create

结果示例:

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 --->"

现在你可以根据官方教程来创建帐户和导入钱包了 Tutorials · EOSIO/eos Wiki · GitHub


接下来是广告时间:
Telegram 小组:EOS技术爱好者
我的 Steemit:@pyy
我的简书:http://www.jianshu.com/u/0708f50bcf26
我的知乎:https://www.zhihu.com/people/never-younger
我的公众号:OutOfRange

上一篇下一篇

猜你喜欢

热点阅读