forked from helium/miner
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile-ubuntu
106 lines (82 loc) · 2.55 KB
/
Dockerfile-ubuntu
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
98
99
100
101
102
103
104
105
106
ARG BUILDER_IMAGE=erlang:24-slim
ARG RUNNER_IMAGE=debian:bullseye-slim
FROM ${BUILDER_IMAGE} as deps-compiler
ARG REBAR_DIAGNOSTIC=0
ENV DIAGNOSTIC=${REBAR_DIAGNOSTIC}
ARG REBAR_BUILD_TARGET
ARG TAR_PATH=_build/$REBAR_BUILD_TARGET/rel/*/*.tar.gz
ARG EXTRA_BUILD_APT_PACKAGES
RUN apt update \
&& apt install -y --no-install-recommends \
autoconf \
automake \
bison \
build-essential \
bzip2 \
ca-certificates \
cmake \
curl \
flex \
git \
libdbus-1-dev \
libgmp-dev \
libprotobuf-dev \
libsodium-dev \
libssl-dev \
libtool \
lz4 \
libprotobuf-dev \
pax-utils \
wget \
${EXTRA_BUILD_APT_PACKAGES}
# Strip debug symbols from ERTS binarys to reduce size
RUN scanelf --nobanner -E ET_DYN -BF '%F' --recursive /usr/local/lib/erlang | xargs -r strip --strip-unneeded
# Install Rust toolchain
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
WORKDIR /usr/src/miner
ENV CC=gcc CXX=g++ CFLAGS="-O2" CXXFLAGS="-O2" \
ERLANG_ROCKSDB_OPTS="-DWITH_BUNDLE_SNAPPY=ON -DWITH_BUNDLE_LZ4=ON" \
ERL_COMPILER_OPTIONS="[deterministic]" \
PATH="/root/.cargo/bin:$PATH"
# Add and compile the dependencies to cache
COPY ./rebar* ./Makefile ./
COPY ./config/grpc_client_gen_local.config ./config/
COPY ./config/grpc_client_gen.config ./config/
RUN ./rebar3 compile
FROM deps-compiler as builder
ARG VERSION
ARG REBAR_DIAGNOSTIC=0
# default to building for mainnet
ARG BUILD_NET=mainnet
ENV DIAGNOSTIC=${REBAR_DIAGNOSTIC}
ARG REBAR_BUILD_TARGET
ARG TAR_PATH=_build/$REBAR_BUILD_TARGET/rel/*/*.tar.gz
# Now add our code
COPY . .
RUN ./rebar3 as ${REBAR_BUILD_TARGET} tar -n miner -v ${VERSION}
RUN mkdir -p /opt/docker/update
RUN tar -zxvf ${TAR_PATH} -C /opt/docker
RUN wget -O /opt/docker/update/genesis https://snapshots.helium.wtf/genesis.${BUILD_NET}
FROM ${RUNNER_IMAGE} as runner
ARG VERSION
ARG EXTRA_RUNNER_APT_PACKAGES
RUN apt update \
&& apt install -y \
dbus \
iproute2 \
libncurses6 \
libsodium23 \
libstdc++6 \
${EXTRA_RUNNER_APT_PACKAGES} \
&& rm -rf /var/lib/apt/lists \
&& ln -sf /opt/miner/releases/${VERSION} /config
WORKDIR /opt/miner
ENV COOKIE=miner \
# Write files generated during startup to /tmp
RELX_OUT_FILE_PATH=/tmp \
# add miner to path, for easy interactions
PATH=$PATH:/opt/miner/bin
COPY --from=builder /opt/docker /opt/miner
VOLUME ["/opt/miner/hotfix", "/var/data"]
ENTRYPOINT ["/opt/miner/bin/miner"]
CMD ["foreground"]