Skip to content

Commit f739b7e

Browse files
committed
add docker support
1 parent a45fe8a commit f739b7e

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore

Dockerfile

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
FROM golang:1.13.4-buster
2+
MAINTAINER ldoublewood <ldoublewood@gmail.com>
3+
4+
ENV SRC_DIR /lotus
5+
6+
RUN apt-get update && apt-get install -y && apt-get install -y ca-certificates llvm clang mesa-opencl-icd ocl-icd-opencl-dev
7+
8+
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y
9+
10+
11+
# Get su-exec, a very minimal tool for dropping privileges,
12+
# and tini, a very minimal init daemon for containers
13+
ENV SUEXEC_VERSION v0.2
14+
ENV TINI_VERSION v0.18.0
15+
RUN set -x \
16+
&& cd /tmp \
17+
&& git clone https://github.com/ncopa/su-exec.git \
18+
&& cd su-exec \
19+
&& git checkout -q $SUEXEC_VERSION \
20+
&& make \
21+
&& cd /tmp \
22+
&& wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/tini \
23+
&& chmod +x tini
24+
25+
# Download packages first so they can be cached.
26+
COPY go.mod go.sum $SRC_DIR/
27+
COPY extern/ $SRC_DIR/extern/
28+
RUN cd $SRC_DIR \
29+
&& go mod download
30+
31+
COPY Makefile $SRC_DIR
32+
33+
# Because extern/filecoin-ffi building script need to get version number from git
34+
COPY .git/ $SRC_DIR/.git/
35+
COPY .gitmodules $SRC_DIR/
36+
37+
# Download dependence first
38+
RUN cd $SRC_DIR \
39+
&& mkdir $SRC_DIR/build \
40+
&& . $HOME/.cargo/env \
41+
&& make clean \
42+
&& make deps
43+
44+
45+
COPY . $SRC_DIR
46+
47+
# Build the thing.
48+
RUN cd $SRC_DIR \
49+
&& . $HOME/.cargo/env \
50+
&& make
51+
52+
# Now comes the actual target image, which aims to be as small as possible.
53+
FROM busybox:1-glibc
54+
MAINTAINER ldoublewood <ldoublewood@gmail.com>
55+
56+
# Get the executable binary and TLS CAs from the build container.
57+
ENV SRC_DIR /lotus
58+
COPY --from=0 $SRC_DIR/lotus /usr/local/bin/lotus
59+
COPY --from=0 $SRC_DIR/lotus-storage-miner /usr/local/bin/lotus-storage-miner
60+
COPY --from=0 /tmp/su-exec/su-exec /sbin/su-exec
61+
COPY --from=0 /tmp/tini /sbin/tini
62+
COPY --from=0 /etc/ssl/certs /etc/ssl/certs
63+
64+
65+
# This shared lib (part of glibc) doesn't seem to be included with busybox.
66+
COPY --from=0 /lib/x86_64-linux-gnu/libdl-2.28.so /lib/libdl.so.2
67+
COPY --from=0 /lib/x86_64-linux-gnu/libutil-2.28.so /lib/libutil.so.1
68+
COPY --from=0 /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0 /lib/libOpenCL.so.1
69+
COPY --from=0 /lib/x86_64-linux-gnu/librt-2.28.so /lib/librt.so.1
70+
COPY --from=0 /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
71+
72+
# WS port
73+
EXPOSE 1234
74+
# P2P port
75+
EXPOSE 5678
76+
77+
78+
# Create the home directory and switch to a non-privileged user.
79+
ENV HOME_PATH /data
80+
ENV PARAMCACHE_PATH /var/tmp/filecoin-proof-parameters
81+
82+
RUN mkdir -p $HOME_PATH \
83+
&& adduser -D -h $HOME_PATH -u 1000 -G users lotus \
84+
&& chown lotus:users $HOME_PATH
85+
86+
87+
VOLUME $HOME_PATH
88+
VOLUME $PARAMCACHE_PATH
89+
90+
# Execute the daemon subcommand by default
91+
CMD ["/sbin/tini", "--", "lotus", "daemon"]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ FFI_DEPS:=$(addprefix $(FFI_PATH),$(FFI_DEPS))
2222
$(FFI_DEPS): build/.filecoin-install ;
2323

2424
build/.filecoin-install: $(FFI_PATH)
25-
$(MAKE) -C $(FFI_PATH) $(FFI_DEPS:$(FFI_PATH)%=%)
25+
FFI_BUILD_FROM_SOURCE=1 $(MAKE) -C $(FFI_PATH) $(FFI_DEPS:$(FFI_PATH)%=%)
2626
@touch $@
2727

2828
MODULES+=$(FFI_PATH)

0 commit comments

Comments
 (0)