-
Notifications
You must be signed in to change notification settings - Fork 35
/
Dockerfile
103 lines (83 loc) · 3 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
98
99
100
101
102
103
# Use ubuntu:20.04 as base for builder stage image
FROM ubuntu:20.04 as builder
# Set Electroneum branch/tag to be used for electroneumd compilation
ARG ELECTRONEUM_BRANCH=master
# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation
ENV DEBIAN_FRONTEND="noninteractive"
# Install dependencies for electroneumd and etnblocks compilation
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
git \
build-essential \
cmake \
miniupnpc \
graphviz \
doxygen \
pkg-config \
ca-certificates \
zip \
libboost-all-dev \
libunbound-dev \
libunwind8-dev \
libssl-dev \
libcurl4-openssl-dev \
libgtest-dev \
libreadline-dev \
libzmq3-dev \
libsodium-dev \
libhidapi-dev \
libhidapi-libusb0 \
liblzma-dev \
libldns-dev \
libexpat1-dev \
libpgm-dev \
libusb-dev \
libsecp256k1-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set compilation environment variables
ENV CFLAGS='-fPIC'
ENV CXXFLAGS='-fPIC'
ENV USE_SINGLE_BUILDDIR 1
ENV BOOST_DEBUG 1
WORKDIR /root
# Clone and compile electroneumd with all available threads
ARG NPROC
RUN git clone --recursive --branch ${ELECTRONEUM_BRANCH} https://github.com/electroneum/electroneum.git \
&& cd electroneum \
&& test -z "$NPROC" && nproc > /nproc || echo -n "$NPROC" > /nproc && make -j"$(cat /nproc)"
# Copy and cmake/make etnblocks with all available threads
COPY . /root/electroneum-blockchain-explorer/
WORKDIR /root/electroneum-blockchain-explorer/build
RUN cmake .. && make -j"$(cat /nproc)"
# Use ldd and awk to bundle up dynamic libraries for the final image
RUN zip /lib.zip $(ldd etnblocks | grep -E '/[^\ ]*' -o)
# Use ubuntu:20.04 as base for final image
FROM ubuntu:20.04
# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation
ENV DEBIAN_FRONTEND="noninteractive"
# Install unzip to handle bundled libs from builder stage
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /lib.zip .
RUN unzip -o lib.zip && rm -rf lib.zip
# Add user and setup directories for electroneumd and etnblocks
RUN useradd -ms /bin/bash electroneum \
&& mkdir -p /home/electroneum/.electroneum \
&& chown -R electroneum:electroneum /home/electroneum/.electroneum
USER electroneum
# Switch to home directory and install newly built etnblocks binary
WORKDIR /home/electroneum
COPY --chown=electroneum:electroneum --from=builder /root/electroneum-blockchain-explorer/build/etnblocks .
COPY --chown=electroneum:electroneum --from=builder /root/electroneum-blockchain-explorer/build/templates ./templates/
# Expose volume used for lmdb access by etnblocks
VOLUME /home/electroneum/.electroneum
# Expose default explorer http port
EXPOSE 8081
ENTRYPOINT ["/bin/sh", "-c"]
# Set sane defaults that are overridden if the user passes any commands
CMD ["./etnblocks --enable-json-api --enable-autorefresh-option --enable-pusher"]