-
Notifications
You must be signed in to change notification settings - Fork 84
/
opencex.sh
1172 lines (956 loc) · 29.6 KB
/
opencex.sh
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
if [ $(dpkg-query -W -f='${Status}' docker-ce 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo "Docker not found, install docker..."
sudo apt-get update > /dev/null 2>&1
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release > /dev/null 2>&1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update > /dev/null 2>&1
sudo apt-get install -y docker-ce docker-ce-cli containerd.io git docker-compose-plugin > /dev/null 2>&1
sudo systemctl enable docker > /dev/null 2>&1
sudo systemctl start docker > /dev/null 2>&1
echo "Docker has been successfully installed."
else
echo "Docker already installed."
fi
mkdir /app/opencex -p
cd /app/opencex || exit
git clone https://github.com/Polygant/OpenCEX-backend.git ./backend
git clone https://github.com/Polygant/OpenCEX-frontend.git ./frontend
git clone https://github.com/Polygant/OpenCEX-static.git ./nuxt
git clone https://github.com/Polygant/OpenCEX-JS-admin.git ./admin
echo "`cat <<YOLLOPUKKI
000000\ 000000\ 00000000\ 00\ 00\
00 __00\ 00 __00\ 00 _____|00 | 00 |
00 / 00 | 000000\ 000000\ 0000000\ 00 / \__|00 | \00\ 00 |
00 | 00 |00 __00\ 00 __00\ 00 __00\ 00 | 00000\ \0000 /
00 | 00 |00 / 00 |00000000 |00 | 00 |00 | 00 __| 00 00<
00 | 00 |00 | 00 |00 ____|00 | 00 |00 | 00\ 00 | 00 /\00\
000000 |0000000 |\0000000\ 00 | 00 |\000000 |00000000\ 00 / 00 |
\______/ 00 ____/ \_______|\__| \__| \______/ \________|\__| \__|
00 |
00 |
\__|
Hello! This is OpenCEX Setup. Please enter parameters for your exchange.
If you make a mistake when entering a parameter, don't worry,
at the end of each parameter block you will have the opportunity
to re-enter the parameters.
* is for the required field.
YOLLOPUKKI`"
read -p "Press enter to continue"
cd /app/opencex/backend || exit
FILE=/app/opencex/backend/.env
if test ! -f "$FILE"; then
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 1 OF 12. PROJECT VARIABLES
===========================================================
PROJECT_NAME* - name of your exchange
DOMAIN* - base domain of your exchange
ADMIN_BASE_URL* - URL of the admin panel, added to DOMAIN
ADMIN_USER* - email of the user that would have admin rights
ADMIN_MASTERPASS* - master password, used to create
balance accrual/debit transactions
SUPPORT_EMAIL - email address of support
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "PROJECT_NAME* (i.e. SuperExchange): "
read PROJECT_NAME
export PROJECT_NAME
echo -n "DOMAIN* (i.e. test.com): "
read DOMAIN
export DOMAIN
echo -n "ADMIN_BASE_URL* (i.e: admin): "
read ADMIN_BASE_URL
export ADMIN_BASE_URL
echo -n "ADMIN_USER* (i.e: [email protected]): "
read ADMIN_USER
export ADMIN_USER
echo -n "ADMIN_MASTERPASS*: "
read ADMIN_MASTERPASS
export ADMIN_MASTERPASS
echo -n "SUPPORT_EMAIL: "
read SUPPORT_EMAIL
export SUPPORT_EMAIL
#TELEGRAM - telegram chat URL (i.e. opencex)
#FACEBOOK - facebook page URL
#TWITTER - twitter page URL
#LINKEDIN - linkedin page URL
TELEGRAM=opencex
FACEBOOK=polygant
TWITTER=polygant
LINKEDIN=polygant
LOGO=
export TELEGRAM
export FACEBOOK
export TWITTER
export LINKEDIN
export LOGO
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 2 OF 12. COMMON SERVICES
===========================================================
RECAPTCHA* - Google Captcha site key
RECAPTCHA_SECRET* - Google Captcha secret key
TELEGRAM_CHAT_ID - used to send alerts to Telegram
TELEGRAM_ALERTS_CHAT_ID - monitoring collection and the state of collectors
TELEGRAM_BOT_TOKEN - token for the Alert bot
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "RECAPTCHA*: "
read RECAPTCHA
export RECAPTCHA
echo -n "RECAPTCHA_SECRET*: "
read RECAPTCHA_SECRET
export RECAPTCHA_SECRET
echo -n "TELEGRAM_CHAT_ID: "
read TELEGRAM_CHAT_ID
export TELEGRAM_CHAT_ID
echo -n "TELEGRAM_ALERTS_CHAT_ID: "
read TELEGRAM_ALERTS_CHAT_ID
export TELEGRAM_ALERTS_CHAT_ID
echo -n "TELEGRAM_BOT_TOKEN: "
read TELEGRAM_BOT_TOKEN
export TELEGRAM_BOT_TOKEN
# CAPTCHA_ALLOWED_IP_MASK=172\.\d{1,3}\.\d{1,3}\.\d{1,3}
# export CAPTCHA_ALLOWED_IP_MASK
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 3 OF 12. BLOCKCHAIN SERVICES
===========================================================
INFURA_API_KEY* - used for the ETH blockchain data
INFURA_API_SECRET* - used for the ETH blockchain data
ETHERSCAN_KEY* - used for the ETH blockchain data
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "INFURA_API_KEY*: "
read INFURA_API_KEY
export INFURA_API_KEY
echo -n "INFURA_API_SECRET*: "
read INFURA_API_SECRET
export INFURA_API_SECRET
echo -n "ETHERSCAN_KEY*: "
read ETHERSCAN_KEY
export ETHERSCAN_KEY
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 4 OF 12. SAFE ADDRESSES
===========================================================
BTC_SAFE_ADDR* - bitcoin address. All BTC deposits go there
ETH_SAFE_ADDR* - ethereum address. All ETH and ERC-20 deposits go there
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "BTC_SAFE_ADDR*: "
read BTC_SAFE_ADDR
export BTC_SAFE_ADDR
echo -n "ETH_SAFE_ADDR*: "
read ETH_SAFE_ADDR
export ETH_SAFE_ADDR
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
=======================================================================================
STEP 5 of 12. BINANCE BSC BLOCKCHAIN, BNB and USDT BEP-20 SUPPORT. (optional)
=======================================================================================
You can set ENABLED_BNB: False or leave it blank to turn it off.
BSCSCAN_KEY* - used for the BSC blockchain data
BNB_SAFE_ADDR* - binance smart chain address. All BNB and BEP-20 deposits go there
---------------------------------------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "ENABLED_BNB (True/False): "
read ENABLED_BNB
export ENABLED_BNB
if [ "$ENABLED_BNB" = "True" ]; then
echo -n "BSCSCAN_KEY*: "
read BSCSCAN_KEY
export BSCSCAN_KEY
echo -n "BNB_SAFE_ADDR*: "
read BNB_SAFE_ADDR
export BNB_SAFE_ADDR
fi
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
=======================================================================================
STEP 6 of 12. TRON BLOCKCHAIN, TRX and USDT TRC-20 SUPPORT. (optional)
=======================================================================================
You can set ENABLED_TRON: False or leave it blank to turn it off.
TRONGRID_API_KEY* - used for the Tron blockchain data
TRX_SAFE_ADDR* - tron address. All TRX and TRC-20 deposits go there
---------------------------------------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "ENABLED_TRON (True/False): "
read ENABLED_TRON
export ENABLED_TRON
if [ "$ENABLED_TRON" = "True" ]; then
echo -n "TRONGRID_API_KEY*: "
read TRONGRID_API_KEY
export TRONGRID_API_KEY
echo -n "TRX_SAFE_ADDR*: "
read TRX_SAFE_ADDR
export TRX_SAFE_ADDR
fi
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
=======================================================================================
STEP 7 of 12. POLYGON BLOCKCHAIN, MATIC and USDT MATIC SUPPORT. (optional)
=======================================================================================
You can set ENABLED_MATIC: False or leave it blank to turn it off.
POLYGONSCAN_KEY* - used for the Polygon blockchain data
MATIC_SAFE_ADDR* - Polygon address. All MATIC and ERC-20 (MATIC) deposits go there
---------------------------------------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "ENABLED_MATIC (True/False): "
read ENABLED_MATIC
export ENABLED_MATIC
COMMON_TASKS_MATIC=false
export COMMON_TASKS_MATIC
if [ "$ENABLED_MATIC" = "True" ]; then
COMMON_TASKS_MATIC=true
export COMMON_TASKS_MATIC
echo -n "POLYGONSCAN_KEY*: "
read POLYGONSCAN_KEY
export POLYGONSCAN_KEY
echo -n "MATIC_SAFE_ADDR*: "
read MATIC_SAFE_ADDR
export MATIC_SAFE_ADDR
fi
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 8 OF 12. EMAIL SERVICE
===========================================================
Used for sending notifications and alerts.
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "EMAIL_HOST*: "
read EMAIL_HOST
export EMAIL_HOST
echo -n "EMAIL_HOST_USER*: "
read EMAIL_HOST_USER
export EMAIL_HOST_USER
echo -n "EMAIL_HOST_PASSWORD*: "
read EMAIL_HOST_PASSWORD
export EMAIL_HOST_PASSWORD
echo -n "EMAIL_PORT*: "
read EMAIL_PORT
export EMAIL_PORT
echo -n "EMAIL_USE_TLS* (True/False): "
read EMAIL_USE_TLS
export EMAIL_USE_TLS
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 9 OF 12. SMS SERVICE TWILIO (optional)
===========================================================
Used for sending notifications and alerts.
You can set IS_SMS_ENABLED: False or leave it blank
to turn it off.
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "IS_SMS_ENABLED (True/False): "
read IS_SMS_ENABLED
export IS_SMS_ENABLED
if [ "$IS_SMS_ENABLED" = "True" ]; then
echo -n "TWILIO_ACCOUNT_SID: "
read TWILIO_ACCOUNT_SID
export TWILIO_ACCOUNT_SID
echo -n "TWILIO_AUTH_TOKEN: "
read TWILIO_AUTH_TOKEN
export TWILIO_AUTH_TOKEN
echo -n "TWILIO_VERIFY_SID: "
read TWILIO_VERIFY_SID
export TWILIO_VERIFY_SID
echo -n "TWILIO_PHONE: "
read TWILIO_PHONE
export TWILIO_PHONE
echo ""
fi
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 10 OF 12. KYC PROVIDER SUMSUB (OPTIONAL)
===========================================================
Used for KYC.
You can set IS_KYC_ENABLED: False or leave it blank
to turn it off.
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "IS_KYC_ENABLED (True/False): "
read IS_KYC_ENABLED
export IS_KYC_ENABLED
if [ "$IS_KYC_ENABLED" = "True" ]; then
echo -n "SUMSUB_SECRET_KEY: "
read SUMSUB_SECRET_KEY
export SUMSUB_SECRET_KEY
echo -n "SUMSUB_APP_TOKEN: "
read SUMSUB_APP_TOKEN
export SUMSUB_APP_TOKEN
echo -n "SUMSUM_CALLBACK_VALIDATION_SECRET: "
read SUMSUM_CALLBACK_VALIDATION_SECRET
export SUMSUM_CALLBACK_VALIDATION_SECRET
fi
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 11 OF 12. KYT PROVIDER SCORECHAIN (OPTIONAL)
===========================================================
Used for KYT.
You can set IS_KYT_ENABLED: False or leave it blank
to turn it off.
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "IS_KYT_ENABLED (True/False): "
read IS_KYT_ENABLED
export IS_KYT_ENABLED
if [ "$IS_KYT_ENABLED" = "True" ]; then
echo -n "SCORECHAIN_BITCOIN_TOKEN: "
read SCORECHAIN_BITCOIN_TOKEN
export SCORECHAIN_BITCOIN_TOKEN
echo -n "SCORECHAIN_ETHEREUM_TOKEN: "
read SCORECHAIN_ETHEREUM_TOKEN
export SCORECHAIN_ETHEREUM_TOKEN
echo -n "SCORECHAIN_TRON_TOKEN: "
read SCORECHAIN_TRON_TOKEN
export SCORECHAIN_TRON_TOKEN
echo -n "SCORECHAIN_BNB_TOKEN: "
read SCORECHAIN_BNB_TOKEN
export SCORECHAIN_BNB_TOKEN
fi
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
echo "`cat <<YOLLOPUKKI
===========================================================
STEP 12 OF 12. MARKET MAKING BOT - HUMMINGBOT (OPTIONAL)
===========================================================
Used for market making and other strategies.
You can set IS_HUMMINGBOT_ENABLED: False or leave it blank
to turn it off.
-----------------------------------------------------------
YOLLOPUKKI`"
while true; do
echo -n "IS_HUMMINGBOT_ENABLED (True/False): "
read IS_HUMMINGBOT_ENABLED
export IS_HUMMINGBOT_ENABLED
echo "-----------------------------------------------------------"
read -p "IS EVERYTHING CORRECT? (y or n)" YESORNO
case $YESORNO in
[Yy]* ) break;;
[Nn]* ) echo "Re-enter the parameters.";;
* ) break;;
esac
done
#echo "Instance name"
INSTANCE_NAME='opencex'
export INSTANCE_NAME
#echo "Postgres credentials - user, database name, password, server address and port"
DB_NAME=opencex
DB_USER=opencex
DB_PASS=$(< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c12)
DB_HOST=postgresql
DB_PORT=5432
export DB_NAME
export DB_USER
export DB_PASS
export DB_HOST
export DB_PORT
#echo "RabbitMQ credentials - user, password, server address and port"
AMQP_USER=opencex
AMQP_PASS=$(< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c12)
AMQP_HOST=rabbitmq
AMQP_PORT=5672
export AMQP_USER
export AMQP_PASS
export AMQP_HOST
export AMQP_PORT
#echo "Bitcoin node credentials - user, password, server address and port"
BTC_NODE_USER=opencex
BTC_NODE_PASS=$(< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c12)
BTC_NODE_PORT=8332
BTC_NODE_HOST=bitcoind
export BTC_NODE_USER
export BTC_NODE_PASS
export BTC_NODE_PORT
export BTC_NODE_HOST
#echo "Redis credentials - server address and port"
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASS=
export REDIS_HOST
export REDIS_PORT
export REDIS_PASS
#echo "the address where bots can directly access the django instance"
BOTS_API_BASE_URL=http://opencex:8080
export BOTS_API_BASE_URL
# key for encrypting private keys in the database (generated automatically)
CRYPTO_KEY=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};echo;)
export CRYPTO_KEY
# bot user password
BOT_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};echo;)
export BOT_PASSWORD
envsubst < /app/opencex/backend/.env.template > /app/opencex/backend/.env
fi
source /app/opencex/backend/.env
set -a
cd /app/opencex/frontend || exit
FILE=/app/opencex/frontend/src/local_config
if test ! -f "$FILE"; then
envsubst < /app/opencex/frontend/src/example.local_config.js > /app/opencex/frontend/src/local_config
### save to env
cat << EOF >> /app/opencex/backend/.env
#opencex frontend values
RECAPTCHA=$RECAPTCHA
TELEGRAM=$TELEGRAM
TG_NEWS=$TG_NEWS
SUPPORT_EMAIL=$SUPPORT_EMAIL
FACEBOOK=$FACEBOOK
TWITTER=$TWITTER
LINKEDIN=$LINKEDIN
EOF
fi
##################
# START BUILDING!
##################
# build front
mkdir -p /app/opencex/frontend/deploy/
cp /app/deploy/frontend/Dockerfile /app/opencex/frontend/deploy/Dockerfile
cp /app/deploy/frontend/default.conf /app/opencex/frontend/deploy/default.conf
cp /app/deploy/frontend/nginx.conf /app/opencex/frontend/deploy/nginx.conf
sed -i "s/ADMIN_BASE_URL/$ADMIN_BASE_URL/g" /app/opencex/frontend/deploy/default.conf
sed -i "s/DOMAIN/$DOMAIN/g" /app/opencex/frontend/deploy/default.conf
docker build -t frontend -f deploy/Dockerfile .
# build nuxt
mkdir -p /app/opencex/nuxt/deploy/
cd /app/opencex/nuxt || exit
cp /app/deploy/nuxt/.env.template /app/opencex/nuxt/
cp /app/deploy/nuxt/Dockerfile /app/opencex/nuxt/deploy/Dockerfile
envsubst < /app/opencex/nuxt/.env.template > /app/opencex/nuxt/.env
docker build -t nuxt -f deploy/Dockerfile .
# build admin
mkdir -p /app/opencex/admin/deploy/
cd /app/opencex/admin || exit
cp /app/deploy/admin/Dockerfile /app/opencex/admin/deploy/Dockerfile
cp /app/deploy/admin/default.conf /app/opencex/admin/deploy/default.conf
cp /app/deploy/admin/.env.template /app/opencex/admin/
sed -i "s/ADMIN_BASE_URL/$ADMIN_BASE_URL/g" /app/opencex/admin/deploy/default.conf
envsubst < /app/opencex/admin/.env.template > /app/opencex/admin/src/local_config.js
docker build -t admin -f deploy/Dockerfile .
# build backend
cd /app/opencex/backend/ || exit
chmod +x /app/opencex/backend/manage.py
docker build -t opencex .
### install Caddy
mkdir /app/opencex -p
cd /app/opencex || exit
mkdir caddy_data postgresql_data redis_data rabbitmq_data rabbitmq_logs bitcoind_data -p
chmod 777 caddy_data postgresql_data redis_data rabbitmq_data rabbitmq_logs bitcoind_data
docker network create caddy
cat << EOF > docker-compose.yml
version: "3.7"
networks:
caddy:
external: true
services:
opencex:
container_name: opencex
image: opencex:latest
command: gunicorn exchange.wsgi:application -b 0.0.0.0:8080 -w 2 --access-logfile - --error-logfile -
# entrypoint: tail -f /dev/null
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
opencex-wss:
container_name: opencex-wss
image: opencex:latest
command: daphne -b 0.0.0.0 exchange.asgi:application --ping-interval 600 --ping-timeout 600
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-cel:
container_name: opencex-cel
image: opencex:latest
command: celery -A exchange worker -l info -n general -B -s /tmp/cebeat.db -X btc,eth_new_blocks,eth_deposits,eth_payouts,eth_check_balances,eth_accumulations,eth_tokens_accumulations,eth_send_gas,bnb_new_blocks,bnb_deposits,bnb_payouts,bnb_check_balances,bnb_accumulations,bnb_tokens_accumulations,bnb_send_gas,trx_new_blocks,trx_deposits,trx_payouts,trx_check_balances,trx_accumulations,trx_tokens_accumulations,matic_new_blocks,matic_deposits,matic_payouts,matic_check_balances,matic_accumulations,matic_tokens_accumulations
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-stack:
container_name: opencex-stack
image: opencex:latest
command: python bin/stack.py
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-btc:
container_name: opencex-btc
image: opencex:latest
command: /app/manage.py btcworker
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-eth-blocks:
container_name: opencex-eth-blocks
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n eth_new_blocks -Q eth_new_blocks -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-bnb-blocks:
container_name: opencex-bnb-blocks
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n bnb_new_blocks -Q bnb_new_blocks -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-trx-blocks:
container_name: opencex-trx-blocks
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n trx_new_blocks -Q trx_new_blocks -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-matic-blocks:
container_name: opencex-matic-blocks
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n matic_new_blocks -Q matic_new_blocks -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-deposits:
container_name: opencex-deposits
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n deposits -Q trx_deposits,bnb_deposits,eth_deposits,matic_deposits -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-payouts:
container_name: opencex-payouts
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n payouts -Q trx_payouts,eth_payouts,bnb_payouts,matic_payouts -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-balances:
container_name: opencex-balances
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n check_balances -Q trx_check_balances,bnb_check_balances,eth_check_balances,matic_check_balances -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-coin-accumulations:
container_name: opencex-coin-accumulations
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n coin_accumulations -Q trx_accumulations,bnb_accumulations,eth_accumulations,matic_accumulations -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-token-accumulations:
container_name: opencex-token-accumulations
image: opencex:latest
command: bash -c "celery -A exchange worker -l info -n tokens_accumulations -Q trx_tokens_accumulations,bnb_tokens_accumulations,eth_tokens_accumulations,matic_tokens_accumulations -c 1 "
restart: always
volumes:
- /app/opencex/backend:/app
networks:
- caddy
depends_on:
- postgresql
- redis
- rabbitmq
- frontend
- nuxt
- caddy
- bitcoind
- opencex
opencex-gas:
container_name: opencex-gas
image: opencex:latest