forked from moneroexamples/onion-monero-blockchain-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
97 lines (77 loc) · 2.87 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
# Use ubuntu:20.04 as base for builder stage image
FROM ubuntu:20.04 as builder
# Set Monero branch/tag to be used for monerod compilation
ARG MONERO_BRANCH=release-v0.18
# Added DEBIAN_FRONTEND=noninteractive to workaround tzdata prompt on installation
ENV DEBIAN_FRONTEND="noninteractive"
# Install dependencies for monerod and xmrblocks 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 \
&& 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 monerod with all available threads
ARG NPROC
RUN git clone --recursive --branch ${MONERO_BRANCH} https://github.com/monero-project/monero.git \
&& cd monero \
&& test -z "$NPROC" && nproc > /nproc || echo -n "$NPROC" > /nproc && make -j"$(cat /nproc)"
# Copy and cmake/make xmrblocks with all available threads
COPY . /root/onion-monero-blockchain-explorer/
WORKDIR /root/onion-monero-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 xmrblocks | 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 monerod and xmrblocks
RUN useradd -ms /bin/bash monero \
&& mkdir -p /home/monero/.bitmonero \
&& chown -R monero:monero /home/monero/.bitmonero
USER monero
# Switch to home directory and install newly built xmrblocks binary
WORKDIR /home/monero
COPY --chown=monero:monero --from=builder /root/onion-monero-blockchain-explorer/build/xmrblocks .
COPY --chown=monero:monero --from=builder /root/onion-monero-blockchain-explorer/build/templates ./templates/
# Expose volume used for lmdb access by xmrblocks
VOLUME /home/monero/.bitmonero
# Expose default explorer http port
EXPOSE 8081
ENTRYPOINT ["/bin/sh", "-c"]
# Set sane defaults that are overridden if the user passes any commands
CMD ["./xmrblocks --enable-json-api --enable-autorefresh-option --enable-pusher"]