使用docker部署filecoin lotus远程work节点

1. 下载源码

cd /root
git clone https://github.com/filecoin-project/lotus.git
cd lotus/

2. 拷贝Dockerfile到源码根目录

cp tools/dockers/docker-examples/basic-miner-busybox/Dockerfile .

3. 拷贝时区文件

cp /etc/localtime .

4. 修改Dockerfile

  • 增加了时区
  • 修改了默认entrypint命令
  • 修改默认用户
FROM golang:1.13-buster
MAINTAINER ldoublewood <[email protected]>

ENV SRC_DIR /lotus

RUN apt-get update && apt-get install -y && apt-get install -y ca-certificates llvm clang mesa-opencl-icd ocl-icd-opencl-dev

RUN curl -sSf https://sh.rustup.rs | sh -s -- -y


# Get su-exec, a very minimal tool for dropping privileges,
# and tini, a very minimal init daemon for containers
ENV SUEXEC_VERSION v0.2
ENV TINI_VERSION v0.18.0
RUN set -x \
  && cd /tmp \
  && git clone https://github.com/ncopa/su-exec.git \
  && cd su-exec \
  && git checkout -q $SUEXEC_VERSION \
  && make \
  && cd /tmp \
  && wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini \
  && chmod +x tini

# Download packages first so they can be cached.
COPY go.mod go.sum $SRC_DIR/
COPY extern/ $SRC_DIR/extern/
RUN cd $SRC_DIR \
  && go mod download

COPY Makefile $SRC_DIR

# Because extern/filecoin-ffi building script need to get version number from git
COPY .git/ $SRC_DIR/.git/
COPY .gitmodules $SRC_DIR/
COPY localtime $SRC_DIR/

# Download dependence first
RUN cd $SRC_DIR \
  && mkdir $SRC_DIR/build \
  && . $HOME/.cargo/env \
  && make clean \
  && make deps


COPY . $SRC_DIR

ARG MAKE_TARGET=all

# Build the thing.
RUN cd $SRC_DIR \
  && . $HOME/.cargo/env \
  && make $MAKE_TARGET

# Now comes the actual target image, which aims to be as small as possible.
FROM busybox:1-glibc
MAINTAINER ldoublewood <[email protected]>

# Get the executable binary and TLS CAs from the build container.
ENV SRC_DIR /lotus
COPY --from=0 $SRC_DIR/lotus /usr/local/bin/lotus
COPY --from=0 $SRC_DIR/lotus-* /usr/local/bin/
COPY --from=0 /tmp/su-exec/su-exec /sbin/su-exec
COPY --from=0 /tmp/tini /sbin/tini
COPY --from=0 /etc/ssl/certs /etc/ssl/certs


# This shared lib (part of glibc) doesn't seem to be included with busybox.
COPY --from=0 /lib/x86_64-linux-gnu/libdl-2.28.so /lib/libdl.so.2
COPY --from=0 /lib/x86_64-linux-gnu/libutil-2.28.so /lib/libutil.so.1
COPY --from=0 /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /lib/libOpenCL.so.1
COPY --from=0 /lib/x86_64-linux-gnu/librt-2.28.so /lib/librt.so.1
COPY --from=0 /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1

COPY --from=0 $SRC_DIR/localtime /etc/
# WS port
EXPOSE 1234
# P2P port
EXPOSE 5678


# Create the home directory and switch to a non-privileged user.
ENV HOME_PATH /data
ENV PARAMCACHE_PATH /var/tmp/filecoin-proof-parameters

RUN mkdir -p $HOME_PATH $PARAMCACHE_PATH \
  && chown root:root $HOME_PATH $PARAMCACHE_PATH


VOLUME $HOME_PATH
VOLUME $PARAMCACHE_PATH

USER root

# Execute the daemon subcommand by default
CMD ["/sbin/tini", "--", "lotus-seal-worker", "run"]

默认会安装lotus、lotus-storage-minier、lotus-seal-work,默认跑lotus-seal-worker,可以覆盖entrypoint跑lotus和lotus-storage-minier命令

5. 构建镜像

docker build -t lotus-test:v0.28-work .
 

构建好后再推送到镜像仓库

6. 运行 lotus-seal-work

docker run  --name lotus-work  -d -e WORKER_PATH=/data/lotusworker -e STORAGE_API_INFO=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIiwiYWRtaW4iXX0.gyhqIDRToC29zhIQZDbuqht-GcGJ6HwsKQM7Hu_6HhF:/ip4/192.168.0.1/tcp/2345/http  -p 1234:1234 -v /data/lotuswork/lotusworker:/data/lotusworker -v  /data/filecoin-proof-parameters-v20:/var/tmp/filecoin-proof-parameters    lotus-test:v0.28-work  

注:

  1. 需要指定WORKER_PATH并挂载到本地目录至少准备1T的存储空间
  2. STORAGE_API_INFO指定存储矿工TOKEN:STORAGE_NODE_MULTIADDR

参考

官方document

发布了14 篇原创文章 · 获赞 0 · 访问量 160

猜你喜欢

转载自blog.csdn.net/kk3909/article/details/104813909