-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathDockerfile
152 lines (128 loc) · 5.03 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
FROM ubuntu:focal
USER root
WORKDIR /data
ARG dgb_version=7.17.2
ARG arch=x86_64
# You can confirm your timezone by setting the TZ database name field from:
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
ARG local_timezone=Europe/Berlin
# Update apt cache and set tzdata to non-interactive or it will fail later.
# Also install essential dependencies for the build project.
RUN DEBIAN_FRONTEND="noninteractive" apt-get update \
&& apt-get -y install tzdata \
&& ln -fs /usr/share/zoneinfo/${local_timezone} /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& apt-get install -y wget git build-essential libtool autotools-dev automake \
&& apt-get install -y nodejs npm \
pkg-config libssl-dev libevent-dev bsdmainutils python3 libboost-system-dev \
libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev \
libdb-dev libdb++-dev && \
apt-get clean
# Clone the Core wallet source from GitHub and checkout the version.
RUN git clone https://github.com/DigiByte-Core/digibyte/ --branch ${dgb_version} --single-branch
# Use multiple processors to build DigiByte from source.
# Warning: It will try to utilize all your systems cores, which speeds up the build process,
# but consumes a lot of memory which could lead to OOM-Errors during the build process.
# Recommendation: Enable this on machines that have more than 16GB RAM.
ARG parallize_build=0
# Determine how many cores the build process will use.
RUN export CORES="" && [ $parallize_build -gt 1 ] && export CORES="-j $(nproc)"; \
echo "Using $parallize_build core(s) for build process."
# Prepare the build process
ARG rootdatadir=/data
RUN cd ${rootdatadir}/digibyte && ./autogen.sh \
&& ./configure --without-gui --with-incompatible-bdb
# Start the build process
RUN cd ${rootdatadir}/digibyte \
&& make $CORES \
&& make install
# Delete source
#RUN rm -rf ${rootdatadir}/digibyte
RUN mkdir -vp \
"/root/rosetta-node" \
"${rootdatadir}/.digibyte" \
"${rootdatadir}/utxodb" \
"/tmp/npm_install"
# Copy and install rosetta implementation
COPY package.json package-lock.json /tmp/npm_install/
RUN cd /tmp/npm_install && \
npm set progress=false && \
npm config set depth 0 && \
npm install
RUN cp -a /tmp/npm_install/node_modules "/root/rosetta-node/"
# Copy the source to rosetta node directory
COPY package*.json "/root/rosetta-node/"
COPY config "/root/rosetta-node/config"
COPY index.js "/root/rosetta-node/index.js"
COPY src "/root/rosetta-node/src"
COPY test "/root/rosetta-node/test"
# General args
ARG rpc_username=user
ARG rpc_password=pass
ARG offline=0
ARG regtest_simulate_mining=0
# Set to 1 for running it in testnet mode
ARG use_testnet=0
# OR set this to 1 to enable Regtest mode.
# Note: Only one of the above can be set exclusively.
ARG use_regtest=0
# Do we want any blockchain pruning to take place? Set to 4096 for a 4GB blockchain prune.
# Alternatively set size=1 to prune with RPC call 'pruneblockchainheight <height>'
ARG prunesize=0
# Create digibyte.conf file
RUN bash -c 'echo -e "\
server=1\n\
prune=${prunesize}\n\
maxconnections=300\n\
rpcallowip=127.0.0.1\n\
daemon=1\n\
rpcuser=${rpc_username}\n\
rpcpassword=${rpc_password}\n\
txindex=0\n\
# Uncomment below if you need Dandelion disabled for any reason but it is left on by default intentionally\n\
disabledandelion=1\n\
addresstype=bech32\n\
testnet=${use_testnet}\n\
rpcworkqueue=32\n\
regtest=${use_regtest}\n\
[regtest]\n\
rpcbind=127.0.0.1\n\
listen=1\n" | tee "${rootdatadir}/digibyte.conf"'
# Set some environment variables
ENV ROOTDATADIR "$rootdatadir"
ENV ROSETTADIR "/root/rosetta-node"
ENV DGB_VERSION "$dgb_version"
ENV PORT 8080
ENV HOST 0.0.0.0
ENV DATA_PATH "${rootdatadir}/utxodb"
ENV RPC_USER "$rpc_username"
ENV RPC_PASS "$rpc_password"
ENV OFFLINE_MODE "$offline"
ENV RUN_TESTS 1
RUN if [ "$use_testnet" = "0" ] && [ "$use_regtest" = "0" ]; \
then \
echo 'export RPC_PORT="14022"' >> ~/env; \
echo 'export DGB_NETWORK="livenet"' >> ~/env; \
elif [ "$use_testnet" = "1" ] && [ "$use_regtest" = "0" ]; \
then \
echo 'export RPC_PORT="14023"' >> ~/env; \
echo 'export DGB_NETWORK="testnet"' >> ~/env; \
elif [ "$use_testnet" = "0" ] && [ "$use_regtest" = "1" ]; \
then \
echo 'export RPC_PORT="18443"' >> ~/env; \
echo 'export DGB_NETWORK="regtest"' >> ~/env; \
echo "export REGTEST_SIMULATE_MINING=\"$regtest_simulate_mining\"" >> ~/env; \
else \
echo 'export RPC_PORT=""' >> ~/env; \
echo 'export DGB_NETWORK=""' >> ~/env; \
fi
# Allow Communications:
# p2p mainnet rpc mainnet p2p testnet rpc testnet p2p regtest rpc regtest
EXPOSE 12024/tcp 14022/tcp 12026/tcp 14023/tcp 18444/tcp 18443/tcp
# Rosetta HTTP Node
EXPOSE 8080/tcp
# Create symlinks shouldn't be needed as they're installed in /usr/local/bin/
#RUN ln -s /usr/local/bin/digibyted /usr/bin/digibyted
#RUN ln -s /usr/local/bin/digibyte-cli /usr/bin/digibyte-cli
COPY docker-entrypoint.sh "${ROOTDATADIR}/docker_entrypoint.sh"
ENTRYPOINT ["./docker_entrypoint.sh"]