Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit f642c9c

Browse files
committed
update docker compose file and deployment - reorganize monitoring/logging stack and readmes
1 parent 8d1cdf9 commit f642c9c

16 files changed

+236
-56
lines changed

docker-compose.yml

+56-28
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ services:
6565
# depends_on:
6666
# - api
6767
# - parity1
68+
69+
explorer:
70+
hostname: launchpad-explorer
71+
image: appliedblockchain/launchpad-explorer:latest
72+
build:
73+
context: ./explorer
74+
environment:
75+
ETHEREUM_JSONRPC_ENDPOINT: http://parity1:8545/
76+
networks:
77+
- main
78+
ports:
79+
- 3000:3000
80+
depends_on:
81+
- parity1
82+
deploy:
83+
mode: global
84+
restart_policy:
85+
condition: on-failure
86+
6887
parity1:
6988
hostname: launchpad-parity1
7089
build:
@@ -78,10 +97,8 @@ services:
7897
- S3_BUCKET_NAME
7998
environment:
8099
- PARITY_ID=1
81-
depends_on:
82-
- discovery
83100
networks:
84-
- main
101+
- main
85102
ports:
86103
- 8180:8180
87104
- 8545:8545
@@ -90,6 +107,13 @@ services:
90107
image: appliedblockchain/launchpad-parity1:latest
91108
volumes:
92109
- parity1_data:/parity/data
110+
deploy:
111+
restart_policy:
112+
condition: on-failure
113+
placement:
114+
constraints:
115+
- node.labels.node_id == 1
116+
93117
parity2:
94118
hostname: launchpad-parity2
95119
build:
@@ -100,13 +124,18 @@ services:
100124
- NPM_TOKEN
101125
environment:
102126
- PARITY_ID=2
103-
depends_on:
104-
- discovery
105127
networks:
106128
- main
107129
image: appliedblockchain/launchpad-parity2:latest
108130
volumes:
109131
- parity2_data:/parity/data
132+
deploy:
133+
restart_policy:
134+
condition: on-failure
135+
placement:
136+
constraints:
137+
- node.labels.node_id == 2
138+
110139
parity3:
111140
hostname: launchpad-parity3
112141
build:
@@ -117,43 +146,42 @@ services:
117146
- NPM_TOKEN
118147
environment:
119148
- PARITY_ID=3
120-
depends_on:
121-
- discovery
122149
networks:
123150
- main
124151
image: appliedblockchain/launchpad-parity3:latest
125152
volumes:
126153
- parity3_data:/parity/data
154+
deploy:
155+
restart_policy:
156+
condition: on-failure
157+
placement:
158+
constraints:
159+
- node.labels.node_id == 2
160+
127161
discovery:
128162
hostname: discovery
129163
image: redis
130164
ports:
131165
- 6379:6379
132166
networks:
133-
- main
167+
- main
134168
volumes:
135169
- discovery:/data
136-
deploy:
137-
update_config:
138-
parallelism: 1
139-
delay: 1s
140-
restart_policy:
141-
condition: on-failure
142170

143-
logspout:
144-
image: gliderlabs/logspout
145-
deploy:
146-
mode: global
147-
environment:
148-
- SYSLOG_HOST=logs7.papertrailapp.com:32046
149-
# NOTE: change the papertrail url/port before deploying your project
150-
command: syslog+tls://$$SYSLOG_HOST
151-
networks:
152-
- main
153-
volumes:
154-
- type: bind
155-
target: /var/run/docker.sock
156-
source: /var/run/docker.sock
171+
# logspout:
172+
# image: gliderlabs/logspout
173+
# deploy:
174+
# mode: global
175+
# environment:
176+
# - SYSLOG_HOST=logs.papertrailapp.com:12345
177+
# # NOTE: you have to change the papertrail url with the correct one
178+
# command: syslog+tls://$$SYSLOG_HOST
179+
# networks:
180+
# - main
181+
# volumes:
182+
# - type: bind
183+
# target: /var/run/docker.sock
184+
# source: /var/run/docker.sock
157185

158186
volumes:
159187
discovery:

explorer/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM appliedblockchain/b-explorer
22

33
RUN mkdir /home/explorer/app/bin
44
RUN cd bin && npm i node-fetch
5-
COPY bin/getConfig.js /home/explorer/app/bin/getConfig.js
65

7-
CMD node bin/getConfig.js && node server.js
6+
COPY config.js /home/explorer/app
7+
8+
CMD node server.js

explorer/Dockerfile-old

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM appliedblockchain/b-explorer
2+
3+
RUN mkdir /home/explorer/app/bin
4+
RUN cd bin && npm i node-fetch
5+
COPY bin/getConfig.js /home/explorer/app/bin/getConfig.js
6+
7+
CMD node bin/getConfig.js && node server.js

explorer/config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"contracts": {
3+
},
4+
"addressBook": {
5+
}
6+
}

stack/Dockerfile-parity

+7-26
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,24 @@
1-
FROM parity/parity:v2.5.0
1+
FROM parity/parity:v2.5.5-stable
22
USER root
3-
ARG NPM_TOKEN
4-
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
53

64
RUN mkdir -p /parity
75

86
WORKDIR /parity
97

8+
RUN apt-get update -y
9+
RUN apt-get install -y curl bash redis-tools software-properties-common
10+
1011
COPY ./parity/chain/spec.json spec.json
1112
COPY ./parity/chain/reserved_peers reserved_peers
1213

13-
ARG PARITY_ID
14-
ARG S3_ACCESS_KEY_ID
15-
ARG S3_SECRET_ACCESS_KEY
16-
ARG S3_BUCKET_NAME
14+
COPY ./entrypoint-parity.sh .
1715

16+
ARG PARITY_ID
1817
RUN echo "Building parity${PARITY_ID}..."
1918

2019
COPY ./parity/${PARITY_ID}/password password
2120
COPY ./parity/${PARITY_ID}/authority.toml authority.toml
2221
COPY ./parity/${PARITY_ID}/parity ./data/keys/parity
2322
COPY ./parity/${PARITY_ID}/network.key ./data/network/key
2423

25-
RUN mkdir ~/.aws
26-
RUN echo "[default]\naws_access_key_id = $S3_ACCESS_KEY_ID\naws_secret_access_key = $S3_SECRET_ACCESS_KEY" > ~/.aws/credentials
27-
28-
RUN apt-get update -y
29-
RUN apt-get install -y curl bash redis-tools software-properties-common
30-
31-
# convoluted node 10 install
32-
RUN add-apt-repository -y -r ppa:chris-lea/node.js && rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list && rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save && \
33-
export VERSION=node_10.x && export DISTRO="$(lsb_release -s -c)" && \
34-
echo "deb http://deb.nodesource.com/$VERSION $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list \
35-
echo "deb-src http://deb.nodesource.com/$VERSION $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list && \
36-
apt-get update && apt-get install -y --allow-unauthenticated nodejs
37-
38-
COPY ./package* /parity/
39-
# COPY ./backup /parity/
40-
COPY ./parity/entrypoint-parity.sh /parity/entrypoint.sh
41-
RUN npm install
42-
43-
ENTRYPOINT [ "bash", "./entrypoint.sh" ]
24+
ENTRYPOINT [ "bash", "./entrypoint-parity.sh" ]

stack/auth/.htpasswd

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
parity:$apr1$Pb5eOIUl$VRhiOJZPiMVk/.iZ2C9BX.

stack/auth/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM nginx:alpine
2+
3+
WORKDIR /etc/nginx/
4+
5+
COPY nginx.conf .
6+
COPY .htpasswd .

stack/auth/nginx.conf

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
user nginx;
2+
worker_processes auto;
3+
#daemon off;
4+
5+
error_log /var/log/nginx/error.log warn;
6+
pid /var/run/nginx.pid;
7+
8+
events {
9+
worker_connections 8000;
10+
11+
multi_accept on;
12+
use epoll;
13+
}
14+
15+
http {
16+
include /etc/nginx/mime.types;
17+
default_type application/octet-stream;
18+
19+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
20+
'$status $body_bytes_sent "$http_referer" '
21+
'"$http_user_agent" "$http_x_forwarded_for"';
22+
23+
sendfile on;
24+
tcp_nopush on;
25+
tcp_nodelay off;
26+
27+
keepalive_timeout 65;
28+
29+
gzip on;
30+
gzip_comp_level 5;
31+
gzip_min_length 256;
32+
gzip_types
33+
application/atom+xml
34+
application/javascript
35+
application/json
36+
application/rss+xml
37+
application/vnd.ms-fontobject
38+
application/x-font-ttf
39+
application/x-web-app-manifest+json
40+
application/xhtml+xml
41+
application/xml
42+
font/opentype
43+
image/svg+xml
44+
image/x-icon
45+
text/css
46+
text/plain
47+
text/x-component;
48+
49+
client_max_body_size 120M;
50+
51+
server {
52+
listen 80;
53+
server_name _;
54+
55+
client_header_buffer_size 64k;
56+
large_client_header_buffers 4 64k;
57+
58+
location /health {
59+
default_type application/json;
60+
return 200 '{ "status": "ok" }';
61+
}
62+
63+
location / {
64+
auth_basic 'Restricted';
65+
auth_basic_user_file /etc/nginx/.htpasswd;
66+
67+
proxy_pass http://eth;
68+
proxy_set_header X-Real-IP $remote_addr;
69+
proxy_buffering off;
70+
}
71+
}
72+
73+
upstream eth {
74+
server parity1:8545;
75+
}
76+
77+
}

stack/entrypoint-parity.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
function disco() {
4+
redis-cli -h discovery --raw $*
5+
}
6+
7+
[ "$(disco ping)" == "PONG" ] || { echo "discovery redis not up, exiting..." && exit; }
8+
9+
set -ex
10+
11+
sleep 3
12+
13+
rm -f reserved_peers
14+
15+
for i in 1 2 3; do
16+
ENODE=$(disco get "enodes:parity$i")
17+
echo "$ENODE" >> reserved_peers
18+
done
19+
20+
21+
parity --chain /parity/spec.json --config /parity/authority.toml -d /parity/data
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

stack/setup/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM alpine
2+
3+
RUN apk add --update --no-cache curl redis && \
4+
rm -rf /tmp/* /var/cache/apk/*
5+
6+
COPY entrypoint.sh .
7+
8+
CMD [ "./entrypoint.sh" ]

stack/setup/entrypoint.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env sh
2+
3+
function disco() {
4+
redis-cli -h discovery --raw $*
5+
}
6+
7+
disco flushdb
8+
9+
TIME=2
10+
11+
while [ "$(disco ping)" != "PONG" ]
12+
do
13+
echo "discovery redis not up, waiting..." && sleep 1;
14+
done
15+
16+
set -ex
17+
18+
PARITY_INSTANCES="parity1 parity2 parity3"
19+
20+
sleep 5
21+
22+
for PARITY in $PARITY_INSTANCES; do
23+
ENODE_REQ=$(curl --data '{"method":"parity_enode","params":[],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST "$PARITY:8545")
24+
ENODE=$(echo "$ENODE_REQ" | grep -o "enode.*30303" | sed -e "s/\@.*/\@$PARITY:30303\"/" | sed -e "s/\"//g")
25+
disco set "enodes:$PARITY" "$ENODE"
26+
done
27+
28+
sleep $TIME
29+
30+
for i in 1 2 3; do
31+
for j in 1 2 3; do
32+
ENODE=$(disco get "enodes:parity$j")
33+
curl --data '{"method":"parity_addReservedPeer","params":["'"$ENODE"'"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST parity"$i":8545
34+
done
35+
done
36+
37+
echo "Setup completed!"

stack/tasks/docker-login.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set -xe
2+
3+
IP_A=34.240.100.168
4+
IP_B=34.254.239.237
5+
6+
ssh root@$IP_A docker login -u abbuilder -p $1
7+
ssh root@$IP_B docker login -u abbuilder -p $1

0 commit comments

Comments
 (0)