-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.viabtc_exchange_server_backends
executable file
·300 lines (253 loc) · 10.8 KB
/
Dockerfile.viabtc_exchange_server_backends
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# Dockerfile
# hjkim, 2023.07.18
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get clean && rm -fr /var/lib/apt/lists/*
RUN apt-get update
RUN apt-get -y install build-essential
RUN apt-get -y install wget
RUN apt-get -y install curl
RUN apt-get -y install git
RUN apt-get -y install python3
RUN apt-get -y install python3-pip
RUN apt-get -y install sed
RUN apt-get -y install net-tools
RUN apt-get -y install telnet
# for killall
RUN apt-get -y install psmisc
RUN apt-get -y install mysql-client
RUN apt-get -y install libcurl3-gnutls libcurl3-nss
RUN apt-get -y install libcurl4-gnutls-dev
RUN apt-get -y install libcurl4-nss-dev
RUN apt-get -y install libcurlpp-dev
RUN apt-get -y install libcurl4-openssl-dev
RUN apt-get -y install libmysqlclient-dev
RUN apt-get -y install libjansson-dev
RUN apt-get -y install libmpdec-dev
RUN apt-get -y install libev-dev
RUN apt-get -y install liblz4-dev
RUN ln -s /usr/bin/python3 /usr/bin/python
# Kafka
#
# from git
# https://github.com/wurstmeister/kafka-docker
# //https://github.com/wurstmeister/kafka-docker/archive/1.1.0.tar.gz
# $ git clone https://github.com/wurstmeister/kafka-docker.git
#
# from Docker-Compose
# $ sudo docker pull wurstmeister/kafka
# $ sudo docker-compose up -d
#
# ---
#
# (USE THIS)
# // bitnami kafka docker
# https://github.com/bitnami/containers/tree/main/bitnami/kafka
#
# from Docker-Compose
# $ curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/kafka/docker-compose.yml > docker-compose.yml
#
# Configure <docker-compose-kafka-with-zookeeper.yml>
#
# default: KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
# KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://<Public IP>:9092
#
#version: "3"
#
#services:
# zookeeper:
# #image: docker.io/bitnami/zookeeper:3.8
# image: docker.io/bitnami/zookeeper:latest
# ports:
# - "2181:2181"
# volumes:
# - "zookeeper_data:/bitnami"
# environment:
# - ALLOW_ANONYMOUS_LOGIN=yes
# kafka:
# #image: docker.io/bitnami/kafka:3.4
# image: docker.io/bitnami/kafka:latest
# ports:
# - "9092:9092"
# volumes:
# - "kafka_data:/bitnami"
# environment:
# #- KAFKA_BROKER_ID=
# - ALLOW_PLAINTEXT_LISTENER=yes
# - KAFKA_ENABLE_KRAFT=no
# - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
# - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
# #- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
# - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://10.0.2.5:9092
# depends_on:
# - zookeeper
#
#volumes:
# zookeeper_data:
# driver: local
# kafka_data:
# driver: local
#
# $ sudo docker-compose -f docker-compose-kafka-with-zookeeper.yml up -d
# librdkafka
#
# https://github.com/edenhill/librdkafka.git (redirect: https://github.com/confluentinc/librdkafka)
#
#RUN git clone https://github.com/edenhill/librdkafka.git
# or
#RUN git clone https://github.com/confluentinc/librdkafka.git
#
#error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
#fatal: the remote end hung up unexpectedly
#fatal: early EOF
#fatal: index-pack failed
#
# // USE option '--depth=1'
#RUN git clone --depth=1 https://github.com/edenhill/librdkafka.git
#
# or
# // resize 'git file buffer'
# e.g.,
# postBuffer: 100 MB (1024 * 1024 * 100(MB)) = 104,857,600
#RUN git config --global ssh.postBuffer 104857600
#RUN git config --global http.postBuffer 104857600
#
# postBuffer: 500 MB (1024 * 1024 * 500(MB)) = 524,288,000
#RUN git config --global ssh.postBuffer 524288000
#RUN git config --global http.postBuffer 524288000
#
# // clone
#RUN git clone https://github.com/edenhill/librdkafka.git
# or
#RUN git clone https://github.com/confluentinc/librdkafka.git
#
# // download
COPY ./kafka/librdkafka-v2.2.0.tar.gz /
#RUN wget -O /librdkafka-v2.2.0.tar.gz https://github.com/confluentinc/librdkafka/archive/refs/tags/v2.2.0.tar.gz
#RUN curl -o /librdkafka-v2.2.0.tar.gz -L https://github.com/confluentinc/librdkafka/archive/refs/tags/v2.2.0.tar.gz
RUN tar xzvf /librdkafka-v2.2.0.tar.gz -C / && ln -s /librdkafka-2.2.0 /librdkafka
#
# // build
RUN cd /librdkafka && ./configure && make
# Database: MySQL or MariaDB
#
# RUN sed -i -e 's/^bind-address/#&/' /etc/mysql/mariadb.conf.d/50-server.cnf
# COPY ./PROJECT-NAME.sql /root
# RUN service mysql restart && mysql -u root --password="" < /root/PROJECT-NAME.sql
# ENTRYPOINT service mysql restart && tail -f /dev/null
#
# $ sudo docker pull mysql:latest
# $ sudo docker run -d -p 33060:3306 -e MYSQL_ROOT_PASSWORD="..." mysql:latest
#
# $ sudo docker pull mariadb:latest
# $ sudo docker run -d -p 33060:3306 -e MARIADB_ROOT_PASSWORD="..." mariadb:latest
# Redis (x3: master, slave, slave)
# from Docker
# $ sudo docker pull redis
#
# Redis sentinel (x3: master, slave, slave)
# sentinel settings
# from git
# https://github.com/vhf/redis-sentinel-docker-example
# $ git clone https://github.com/vhf/redis-sentinel-docker-example.git
# Configure script
COPY ./set_info.sh /
# ViaBTC source code
# Copy from local and extract
COPY ./viabtc_exchange_server_src_2023.07.22.tar /
RUN tar xvf /viabtc_exchange_server_src_2023.07.22.tar
#
# log directory
RUN mkdir -p "/viabtc_exchange_server/logs/trade/accesshttp"
RUN mkdir -p "/viabtc_exchange_server/logs/trade/accessws"
RUN mkdir -p "/viabtc_exchange_server/logs/trade/alertcenter"
RUN mkdir -p "/viabtc_exchange_server/logs/trade/marketprice"
RUN mkdir -p "/viabtc_exchange_server/logs/trade/matchengine"
RUN mkdir -p "/viabtc_exchange_server/logs/trade/readhistory"
#
# build
RUN cd /viabtc_exchange_server/depends/hiredis && make clean && make
RUN cd /viabtc_exchange_server/network && make clean && make
RUN cd /viabtc_exchange_server/utils && make clean && make
RUN cd /viabtc_exchange_server/accesshttp && make clean && make
RUN cd /viabtc_exchange_server/accessws && make clean && make
RUN cd /viabtc_exchange_server/alertcenter && make clean && make
RUN cd /viabtc_exchange_server/marketprice && make clean && make
RUN cd /viabtc_exchange_server/matchengine && make clean && make
RUN cd /viabtc_exchange_server/readhistory && make clean && make
# ViaBTC config.json
# Edit <'log path', 'DB info', ...>
# for all service processes (matchengine, alertcenter, readhistory, accesshttp, accessws, marketprice)
#
# Working Directory info
# replace: /mnt/data/viabtc -> /viabtc_exchange_server
RUN sed -i -e 's/\/mnt\/data\/viabtc/\/viabtc_exchange_server/g' /viabtc_exchange_server/accesshttp/config.json
RUN sed -i -e 's/\/mnt\/data\/viabtc/\/viabtc_exchange_server/g' /viabtc_exchange_server/accessws/config.json
RUN sed -i -e 's/\/mnt\/data\/viabtc/\/viabtc_exchange_server/g' /viabtc_exchange_server/alertcenter/config.json
RUN sed -i -e 's/\/mnt\/data\/viabtc/\/viabtc_exchange_server/g' /viabtc_exchange_server/marketprice/config.json
RUN sed -i -e 's/\/mnt\/data\/viabtc/\/viabtc_exchange_server/g' /viabtc_exchange_server/matchengine/config.json
RUN sed -i -e 's/\/mnt\/data\/viabtc/\/viabtc_exchange_server/g' /viabtc_exchange_server/readhistory/config.json
#
# Kafka Server info
RUN sed -i -e 's/127.0.0.1:9092/127.0.0.1:9092/g' /viabtc_exchange_server/accessws/config.json
RUN sed -i -e 's/127.0.0.1:9092/127.0.0.1:9092/g' /viabtc_exchange_server/marketprice/config.json
RUN sed -i -e 's/127.0.0.1:9092/127.0.0.1:9092/g' /viabtc_exchange_server/matchengine/config.json
#
# Redis Server info
RUN sed -i -e 's/my_redis_master/my_redis_master/g' /viabtc_exchange_server/alertcenter/config.json
RUN sed -i -e 's/127.0.0.1:26380/127.0.0.1:26380/g' /viabtc_exchange_server/alertcenter/config.json
RUN sed -i -e 's/127.0.0.1:26381/127.0.0.1:26381/g' /viabtc_exchange_server/alertcenter/config.json
RUN sed -i -e 's/127.0.0.1:26382/127.0.0.1:26382/g' /viabtc_exchange_server/alertcenter/config.json
##
RUN sed -i -e 's/my_redis_master/my_redis_master/g' /viabtc_exchange_server/marketprice/config.json
RUN sed -i -e 's/127.0.0.1:26380/127.0.0.1:26380/g' /viabtc_exchange_server/marketprice/config.json
RUN sed -i -e 's/127.0.0.1:26381/127.0.0.1:26381/g' /viabtc_exchange_server/marketprice/config.json
RUN sed -i -e 's/127.0.0.1:26382/127.0.0.1:26382/g' /viabtc_exchange_server/marketprice/config.json
#
# MySQL/MariaDB Server info
RUN sed -i -e 's/\"host\":\ \"127.0.0.1\",/\"host\":\ \"127.0.0.1\",/g' /viabtc_exchange_server/matchengine/config.json
RUN sed -i -e 's/\"port\":\ 3306,/\"port\":\ 3306,/g' /viabtc_exchange_server/matchengine/config.json
RUN sed -i -e 's/\"user\":\ \"root\",/\"user\":\ \"root\",/g' /viabtc_exchange_server/matchengine/config.json
RUN sed -i -e 's/\"pass\":\ \"mysql\",/\"pass\":\ \"mysql\",/g' /viabtc_exchange_server/matchengine/config.json
##
RUN sed -i -e 's/\"host\":\ \"127.0.0.1\",/\"host\":\ \"127.0.0.1\",/g' /viabtc_exchange_server/readhistory/config.json
RUN sed -i -e 's/\"port\":\ 3306,/\"port\":\ 3306,/g' /viabtc_exchange_server/readhistory/config.json
RUN sed -i -e 's/\"user\":\ \"root\",/\"user\":\ \"root\",/g' /viabtc_exchange_server/readhistory/config.json
RUN sed -i -e 's/\"pass\":\ \"mysql\",/\"pass\":\ \"mysql\",/g' /viabtc_exchange_server/readhistory/config.json
# restart_all.sh, stop_all.sh
RUN sed -i -e 's/\/mnt\/data\/viabtc/\//g' /viabtc_exchange_server/restart_all.sh
RUN sed -i -e 's/\/mnt\/data\/viabtc/\//g' /viabtc_exchange_server/stop_all.sh
# Imports SQL schema
# - if has an error, insert 'USE trade_history; or USE trade_log;' below 'CREATE database <trade_...>;'
#
# Edit <DB info> for 'init_trade_history.sh'
#
RUN sed -i -e 's/MYSQL_HOST=\"127.0.0.1\"/MYSQL_HOST=\"127.0.0.1\"/g' /viabtc_exchange_server/sql/init_trade_history.sh
RUN sed -i -e 's/MYSQL_PORT=\"3306\"/MYSQL_PORT=\"3306\"/g' /viabtc_exchange_server/sql/init_trade_history.sh
RUN sed -i -e 's/MYSQL_USER=\"root\"/MYSQL_USER=\"root\"/g' /viabtc_exchange_server/sql/init_trade_history.sh
RUN sed -i -e 's/MYSQL_PASS=\"mysql\"/MYSQL_PASS=\"mysql\"/g' /viabtc_exchange_server/sql/init_trade_history.sh
#
# Import
#RUN cd /viabtc_exchange_server/sql && mysql -h 127.0.0.1 -u root --password="mysql" -P 3306 < create_trade_history.sql
#RUN cd /viabtc_exchange_server/sql && mysql -h 127.0.0.1 -u root --password="mysql" -P 3306 < create_trade_log.sql
#
# Initialize
# DB info required
#RUN cd /viabtc_exchange_server/sql && ./init_trade_history.sh
# Permission
#RUN groupadd -g 1000 test
#RUN useradd -r -u 1000 -g test test
#USER test:test
# ENTRYPOINT
#ENTRYPOINT /usr/share/tomcat9/bin/startup.sh && service mysql restart && apachectl -D FOREGROUND
ENTRYPOINT tail -f /dev/null
#
#ENTRYPOINT cd /viabtc_exchange_server/matchengine && ./restart.sh && \
# cd ../alertcenter && ./restart.sh && \
# cd ../readhistory && ./restart.sh && \
# cd ../accesshttp && ./restart.sh && \
# cd ../accessws && ./restart.sh && \
# cd ../marketprice && ./restart.sh && \
#
#ENTRYPOINT cd /viabtc_exchange_server && ./restart_all.sh && \
# tail -f /dev/null