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