Skip to content

Commit c403e55

Browse files
committed
added dcoker config
1 parent 6839146 commit c403e55

16 files changed

+495
-0
lines changed

peatio/.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git
2+
.dockerignore
3+
Gemfile.lock

peatio/Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM ruby:2.3.7-slim-stretch
2+
3+
RUN apt-get update && apt-get install -qq -y --fix-missing --no-install-recommends build-essential \
4+
nodejs libpq-dev postgresql-client-9.6 chrpath git-core libssl-dev \
5+
libfontconfig1-dev wget imagemagick git mysql-client default-libmysqlclient-dev
6+
7+
RUN gem update bundler
8+
9+
WORKDIR /usr/local/share
10+
ARG PHANTOMJS_VERISON
11+
ENV PHANTOMJS_VERISON=$PHANTOMJS_VERISON
12+
COPY deps/phantomjs-$PHANTOMJS_VERISON-linux-x86_64.tar.bz2 .
13+
RUN tar xjf phantomjs-$PHANTOMJS_VERISON-linux-x86_64.tar.bz2 \
14+
&& ln -s /usr/local/share/phantomjs-$PHANTOMJS_VERISON-linux-x86_64/bin/phantomjs /usr/local/share/phantomjs \
15+
&& ln -s /usr/local/share/phantomjs-$PHANTOMJS_VERISON-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs \
16+
&& ln -s /usr/local/share/phantomjs-$PHANTOMJS_VERISON-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
17+
18+
ENV RAILS_ENV=production
19+
RUN mkdir /peatio
20+
WORKDIR /peatio
21+
22+
COPY ./app/peatio/Gemfile Gemfile
23+
COPY ./app/peatio/Gemfile.lock Gemfile.lock
24+
RUN bundle install
25+
26+
COPY ./app/peatio .
27+
RUN bundle exec rake SECRET_TOKEN=pickasecuretoken assets:precompile
28+
COPY init.sh ./
29+
CMD ./init.sh

peatio/Dockerfile-bitgo_express

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM node:9-slim
2+
RUN apt-get update && apt-get install -qq -y --fix-missing --no-install-recommends build-essential git nginx
3+
RUN mkdir bitgo-express \
4+
&& cd bitgo-express
5+
#RUN npm init
6+
RUN npm install bitgo
7+
8+
RUN rm -rf /etc/nginx/sites-available/default
9+
RUN rm -rf /etc/nginx/sites-enabled/default
10+
RUN rm -rf /etc/nginx/conf.d/default.conf
11+
COPY config/bitgo-express.conf /etc/nginx/conf.d/
12+
13+
COPY bitgo_express.sh ./
14+
CMD ./node_modules/bitgo/bin/bitgo-express

peatio/Dockerfile-nginx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM nginx
2+
3+
RUN apt-get update -qq && apt-get -y install apache2-utils
4+
5+
COPY ./app/peatio /peatio
6+
7+
RUN rm -rf /etc/nginx/sites-available/default
8+
RUN rm -rf /etc/nginx/sites-enabled/default
9+
RUN rm -rf /etc/nginx/conf.d/default.conf
10+
ARG DOMAIN
11+
ENV DOMAIN=$DOMAIN
12+
COPY config/nginx.conf /etc/nginx/conf.d/peatio.conf
13+
RUN sed -e "s/\${domain}/$DOMAIN/" -i /etc/nginx/conf.d/peatio.conf
14+
COPY ./ssl_certs /ssl_certs
15+
16+
RUN mkdir /logs
17+
VOLUME ["/logs"]
18+
19+
CMD [ "nginx", "-g", "daemon off;" ]

peatio/bitgo_express.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
nginx
3+
./node_modules/bitgo/bin/bitgo-express -b localhost -p 3070 -e test

peatio/config/bitgo-express.conf

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
upstream bitgo_express {
2+
server localhost:3070;
3+
}
4+
5+
server {
6+
listen 3080;
7+
server_name _;
8+
location / {
9+
proxy_pass http://bitgo_express;
10+
proxy_buffering off;
11+
proxy_pass_header Server;
12+
proxy_set_header Host $http_host;
13+
proxy_redirect off;
14+
proxy_set_header X-Real-IP $remote_addr;
15+
proxy_set_header X-Scheme $scheme;
16+
proxy_http_version 1.1;
17+
proxy_set_header Upgrade $http_upgrade;
18+
proxy_set_header Connection "upgrade";
19+
20+
}
21+
}

peatio/config/nginx.conf

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
upstream peatio {
2+
server peatio:3000;
3+
}
4+
5+
6+
server {
7+
8+
listen 80;
9+
server_name ${domain} peatio;
10+
return 301 https://$server_name$request_uri;
11+
12+
}
13+
14+
15+
server {
16+
17+
listen 443 ssl;
18+
19+
client_max_body_size 4G;
20+
keepalive_timeout 10;
21+
22+
error_page 500 502 504 /500.html;
23+
error_page 503 @503;
24+
25+
server_name ${domain} peatio;
26+
root /peatio/public;
27+
try_files $uri/index.html $uri @peatio;
28+
29+
ssl_certificate /ssl_certs/fullchain.pem;
30+
ssl_certificate_key /ssl_certs/privkey.pem;
31+
ssl_ciphers "AES128+EECDH:AES128+EDH";
32+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
33+
ssl_prefer_server_ciphers on;
34+
35+
location @peatio {
36+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
37+
proxy_set_header Host $http_host;
38+
proxy_redirect off;
39+
40+
proxy_pass http://peatio;
41+
# limit_req zone=one;
42+
access_log /logs/nginx.access.log;
43+
error_log /logs/nginx.error.log;
44+
}
45+
46+
location ^~ /(assets)/ {
47+
try_files $uri @peatio;
48+
gzip_static on;
49+
expires max;
50+
add_header Cache-Control public;
51+
}
52+
53+
location = /50x.html {
54+
root html;
55+
}
56+
57+
location = /404.html {
58+
root html;
59+
}
60+
61+
location @503 {
62+
error_page 405 = /system/maintenance.html;
63+
if (-f $document_root/system/maintenance.html) {
64+
rewrite ^(.*)$ /system/maintenance.html break;
65+
}
66+
rewrite ^(.*)$ /503.html break;
67+
}
68+
69+
if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){
70+
return 405;
71+
}
72+
73+
if (-f $document_root/system/maintenance.html) {
74+
return 503;
75+
}
76+
77+
location ~ \.(rb|log)$ {
78+
return 405;
79+
}
80+
}

peatio/docker-compose.rds.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
version: '3'
2+
services:
3+
redis:
4+
image: redis:3.0.5
5+
volumes:
6+
- ./redis-data:/var/lib/redis/data
7+
networks:
8+
peatio-static:
9+
ipv4_address: 172.19.0.11
10+
11+
rabbitmq:
12+
image: rabbitmq:3.7.3
13+
hostname: peatio
14+
volumes:
15+
- ./rabbit-data:/var/lib/rabbitmq
16+
networks:
17+
peatio-static:
18+
ipv4_address: 172.19.0.10
19+
deploy:
20+
restart_policy:
21+
condition: on-failure
22+
23+
peatio:
24+
build:
25+
context: .
26+
args:
27+
PHANTOMJS_VERISON: ${PHANTOMJS_VERISON}
28+
RPCUSER: ${RPCUSER}
29+
RPCPASS: ${RPCPASS}
30+
RPCHOST: ${RPCHOST}
31+
RPCPORT: ${RPCPORT}
32+
DOMAIN: ${DOMAIN}
33+
stdin_open: true
34+
tty: true
35+
networks:
36+
peatio-static:
37+
ipv4_address: ${IP}
38+
environment:
39+
MYSQL_DATABASE: ${MYSQL_DATABASE}
40+
MYSQL_USER: ${MYSQL_USER}
41+
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
42+
MYSQL_HOST: ${MYSQL_HOST}
43+
SMTP_PORT: ${SMTP_PORT}
44+
SMTP_DOMAIN: ${SMTP_DOMAIN}
45+
SMTP_ADDRESS: ${SMTP_ADDRESS}
46+
SMTP_USERNAME: ${SMTP_USERNAME}
47+
SMTP_PASSWORD: ${SMTP_PASSWORD}
48+
SMTP_AUTHENTICATION: ${SMTP_AUTHENTICATION}
49+
RPCUSER: ${RPCUSER}
50+
RPCPASS: ${RPCPASS}
51+
DOMAIN: ${DOMAIN}
52+
IP: ${IP}
53+
RPCHOST: ${RPCHOST}
54+
RPCPORT: ${RPCPORT}
55+
LISTEN_ON: 0.0.0.0:3000
56+
WORKER_PROCESSES: 2
57+
# SECRET_TOKEN: ${RAILS_SECRET_TOKEN}
58+
links:
59+
- rabbitmq
60+
- redis
61+
volumes:
62+
- ./app/peatio/uploads:/peatio/uploads
63+
64+
nginx:
65+
build:
66+
context: .
67+
dockerfile: Dockerfile-nginx
68+
args:
69+
DOMAIN: ${DOMAIN}
70+
links:
71+
- peatio
72+
ports:
73+
- '80:80'
74+
- '443:443'
75+
networks:
76+
peatio-static:
77+
ipv4_address: 172.19.0.13
78+
79+
networks:
80+
peatio-static:
81+
ipam:
82+
config:
83+
- subnet: 172.19.0.0/16

peatio/docker-compose.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
version: '3'
2+
services:
3+
redis:
4+
image: redis:3.0.5
5+
volumes:
6+
- ./redis-data:/var/lib/redis/data
7+
networks:
8+
peatio-static:
9+
ipv4_address: 172.19.0.11
10+
11+
rabbitmq:
12+
image: rabbitmq:3.7.3
13+
hostname: peatio
14+
volumes:
15+
- ./rabbit-data:/var/lib/rabbitmq
16+
networks:
17+
peatio-static:
18+
ipv4_address: 172.19.0.10
19+
deploy:
20+
restart_policy:
21+
condition: on-failure
22+
23+
mysql:
24+
image: mysql:5.7.21
25+
environment:
26+
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
27+
MYSQL_DATABASE: ${MYSQL_DATABASE}
28+
MYSQL_USER: ${MYSQL_USER}
29+
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
30+
volumes:
31+
- ./mysql-data:/var/lib/mysql
32+
networks:
33+
peatio-static:
34+
ipv4_address: 172.19.0.9
35+
36+
peatio:
37+
build:
38+
context: .
39+
args:
40+
PHANTOMJS_VERISON: ${PHANTOMJS_VERISON}
41+
RPCUSER: ${RPCUSER}
42+
RPCPASS: ${RPCPASS}
43+
RPCHOST: ${RPCHOST}
44+
RPCPORT: ${RPCPORT}
45+
DOMAIN: ${DOMAIN}
46+
stdin_open: true
47+
#tty: true
48+
networks:
49+
peatio-static:
50+
ipv4_address: ${IP}
51+
environment:
52+
MYSQL_DATABASE: ${MYSQL_DATABASE}
53+
MYSQL_USER: ${MYSQL_USER}
54+
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
55+
MYSQL_HOST: ${MYSQL_HOST}
56+
SMTP_PORT: ${SMTP_PORT}
57+
SMTP_DOMAIN: ${SMTP_DOMAIN}
58+
SMTP_ADDRESS: ${SMTP_ADDRESS}
59+
SMTP_USERNAME: ${SMTP_USERNAME}
60+
SMTP_PASSWORD: ${SMTP_PASSWORD}
61+
SMTP_AUTHENTICATION: ${SMTP_AUTHENTICATION}
62+
RPCUSER: ${RPCUSER}
63+
RPCPASS: ${RPCPASS}
64+
DOMAIN: ${DOMAIN}
65+
IP: ${IP}
66+
DOMAIN: ${DOMAIN}
67+
RPCHOST: ${RPCHOST}
68+
RPCPORT: ${RPCPORT}
69+
LISTEN_ON: 0.0.0.0:3000
70+
WORKER_PROCESSES: 2
71+
# SECRET_TOKEN: ${RAILS_SECRET_TOKEN}
72+
command: bash
73+
links:
74+
- mysql
75+
- rabbitmq
76+
- redis
77+
- bitcoin
78+
volumes:
79+
- "./app/peatio:/peatio"
80+
81+
bitcoin:
82+
build:
83+
context: ../bitcoin/.
84+
args:
85+
RPCUSER: ${RPCUSER}
86+
RPCPASS: ${RPCPASS}
87+
DOMAIN: ${DOMAIN}
88+
IP: ${IP}
89+
stdin_open: true
90+
tty: true
91+
networks:
92+
peatio-static:
93+
ipv4_address: 172.19.0.12
94+
95+
nginx:
96+
build:
97+
context: .
98+
dockerfile: Dockerfile-nginx
99+
args:
100+
DOMAIN: ${DOMAIN}
101+
links:
102+
- peatio
103+
ports:
104+
- '80:80'
105+
- '443:443'
106+
networks:
107+
peatio-static:
108+
ipv4_address: 172.19.0.13
109+
110+
networks:
111+
peatio-static:
112+
ipam:
113+
config:
114+
- subnet: 172.19.0.0/16

peatio/init.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
sed -e "s/\${domain_url}/$DOMAIN/" -i config/application.yml
3+
sed -e "s/\${rpc_url}/$RPCUSER:$RPCPASS@$RPCHOST:$RPCPORT/" -i config/currencies.yml
4+
5+
bundle exec rake db:create
6+
bundle exec rake db:migrate
7+
bundle exec rake db:seed
8+
rm -rf /peatio/tmp/pids/*
9+
bundle exec rake daemons:start
10+
bundle exec rails server

peatio/rpc_vars

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export RPCUSER="peatio"
2+
sleep 1s
3+
export RPCPASS="peatio"
4+
export DOMAIN="localhost"
5+
export IP="172.19.0.4"
6+
export RPCHOST="bitcoin"
7+
export RPCPORT="9333"
8+
echo "Rpc Configs Loaded"

0 commit comments

Comments
 (0)