-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
97 lines (75 loc) · 3.34 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# build container stage
FROM golang:1.18.1-buster AS build-env
RUN apt-get update -y && \
apt-get install sudo cron git mesa-opencl-icd gcc bzr jq pkg-config clang libhwloc-dev ocl-icd-opencl-dev build-essential hwloc -y
ENV LOTUS_PATH="~/.lotus-local-net"
ENV LOTUS_MINER_PATH="~/.lotus-miner-local-net"
ENV CGO_CFLAGS="-D__BLST_PORTABLE__"
ENV CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
ENV LOTUS_SKIP_GENESIS_CHECK="_yes_"
ENV RUSTFLAGS="-C target-cpu=native -g"
ENV FFI_BUILD_FROM_SOURCE=1
ENV NETWORK="2k"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
WORKDIR /src
# Tag of the lotus version to build
ARG BRANCH
RUN git clone https://github.com/filecoin-project/lotus.git --depth 1 --branch $BRANCH && \
cd lotus && \
git submodule update --init --recursive && \
make clean && \
make $NETWORK
# building the healthcheck util, to know when Lotus is ready for use
FROM golang:1.18.1-buster AS utils
WORKDIR /src
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
RUN go build -trimpath -o /usr/local/bin/healthcheck ./cmd/healthcheck
# runtime container stage
FROM ubuntu:20.04
LABEL network=local
LABEL filecoin=lotus
ENV DEBIAN_FRONTEND noninteractive
ENV LOTUS_USER="lotus_user"
# Add useful debug tools
RUN apt-get update && apt-get install curl nano -y && rm -rf /var/lib/apt/lists/*
# create nonroot user and lotus folder
RUN adduser --uid 2000 --gecos "" --disabled-password --quiet $LOTUS_USER
COPY --from=build-env /src/lotus/lotus /usr/local/bin/lotus
COPY --from=build-env /src/lotus/lotus-gateway /usr/local/bin/lotus-gateway
COPY --from=build-env /src/lotus/lotus-shed /usr/local/bin/lotus-shed
COPY --from=build-env /src/lotus/lotus-miner /usr/local/bin/lotus-miner
COPY --from=build-env /src/lotus/lotus-seed /usr/local/bin/lotus-seed
COPY --from=build-env /etc/ssl/certs /etc/ssl/certs
COPY --from=build-env /lib/x86_64-linux-gnu /lib/
# lotus libraries
COPY --from=build-env /lib/x86_64-linux-gnu/libutil.so.1 \
/lib/x86_64-linux-gnu/librt.so.1 \
/lib/x86_64-linux-gnu/libgcc_s.so.1 \
/lib/x86_64-linux-gnu/libdl.so.2 \
/usr/lib/x86_64-linux-gnu/libltdl.so.7 \
/usr/lib/x86_64-linux-gnu/libnuma.so.1 \
/usr/lib/x86_64-linux-gnu/libhwloc.so.5 /lib/
COPY --from=build-env /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /lib/libOpenCL.so.1
ENV LOTUS_PATH="/home/$LOTUS_USER/.lotus-local-net"
ENV LOTUS_MINER_PATH="/home/$LOTUS_USER/.lotus-miner-local-net"
ENV LOTUS_SKIP_GENESIS_CHECK="_yes_"
ENV CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
ENV CGO_CFLAGS="-D__BLST_PORTABLE__"
USER $LOTUS_USER
WORKDIR /home/$LOTUS_USER
RUN lotus fetch-params 2048 && \
lotus-seed pre-seal --sector-size 2KiB --num-sectors 2
RUN lotus-seed genesis new ~/localnet.json
RUN lotus-seed genesis add-miner ~/localnet.json ~/.genesis-sectors/pre-seal-t01000.json
COPY --from=utils /usr/local/bin/healthcheck /usr/local/bin/healthcheck
COPY --chown=2000:2000 config/daemon.toml $LOTUS_PATH/config.toml
COPY --chown=2000:2000 config/miner.toml $LOTUS_MINER_PATH/config.toml
COPY --chown=0:0 scripts/run /usr/local/bin/run-lotus
HEALTHCHECK --interval=5s --timeout=2s --start-period=1m CMD ["/usr/local/bin/healthcheck"]
# API port
EXPOSE 1234/tcp
ENTRYPOINT ["/usr/local/bin/run-lotus"]