Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

Commit 004d66a

Browse files
Tidy up docker (#126)
* Copy .maintain/Dockerfile into .plug So we can maintain it ourselves * Change CMD -> ENTRYPOINT so params can be passed, instead of overriding CMD * Use .plug/bootstrap to build docker image Also export TERM for images missing this env var * Add docker compose to help testing * Overwrite :latest image on push * Add promfana services * Ignore .plug/data * Update .plug/logger.sh Co-authored-by: Jordan <beauchjord@gmail.com> * Use anchor to not repeat * Change grafana port to 3001 to avoid conflict with react default port Co-authored-by: Jordan <beauchjord@gmail.com>
1 parent dfa6023 commit 004d66a

File tree

7 files changed

+167
-1
lines changed

7 files changed

+167
-1
lines changed

.circleci/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ jobs:
123123
else
124124
DOCKER_TAG="${CIRCLE_TAG}"
125125
fi
126-
docker build --pull -t plugnet/plugblockchain:$DOCKER_TAG -f ./.maintain/Dockerfile .
126+
docker build --pull \
127+
-t plugnet/plugblockchain:$DOCKER_TAG \
128+
-t plugnet/plugblockchain:latest \
129+
-f ./.plug/Dockerfile .
127130
docker push plugnet/plugblockchain:$DOCKER_TAG
128131
no_output_timeout: 60m
129132
workflows:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ rls*.log
2121
.local
2222
**/hfuzz_target/
2323
**/hfuzz_workspace/
24+
.plug/data

.plug/Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Note: We don't use Alpine and its packaged Rust/Cargo because they're too often out of date,
2+
# preventing them from being used to build Substrate/Polkadot/Plug.
3+
4+
FROM phusion/baseimage:0.11 as builder
5+
LABEL description="Pl^g build image: The Pl^g binary is built here."
6+
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
ARG PROFILE=release
10+
WORKDIR /plug
11+
12+
COPY . /plug
13+
14+
RUN apt-get update && \
15+
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \
16+
apt-get install -y \
17+
clang \
18+
cmake \
19+
git \
20+
libssl-dev \
21+
pkg-config
22+
23+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
24+
export PATH="$PATH:$HOME/.cargo/bin" && \
25+
.plug/bootstrap && \
26+
cargo build "--$PROFILE"
27+
28+
# ===== SECOND STAGE ======
29+
30+
FROM phusion/baseimage:0.11
31+
LABEL description="Pl^g runner image: A minimal image for running Pl^g."
32+
ARG PROFILE=release
33+
34+
RUN mv /usr/share/ca* /tmp && \
35+
rm -rf /usr/share/* && \
36+
mv /tmp/ca-certificates /usr/share/ && \
37+
useradd -m -u 1000 -U -s /bin/sh -d /plug plug && \
38+
mkdir -p /plug/.local/share/plug && \
39+
chown -R plug:plug /plug/.local && \
40+
ln -s /plug/.local/share/plug /data
41+
42+
COPY --from=builder /plug/target/$PROFILE/plug /usr/local/bin
43+
COPY --from=builder /plug/target/$PROFILE/subkey /usr/local/bin
44+
COPY --from=builder /plug/target/$PROFILE/node-rpc-client /usr/local/bin
45+
COPY --from=builder /plug/target/$PROFILE/chain-spec-builder /usr/local/bin
46+
47+
# checks
48+
RUN ldd /usr/local/bin/plug && \
49+
/usr/local/bin/plug --version
50+
51+
# Shrinking
52+
RUN rm -rf /usr/lib/python* && \
53+
rm -rf /usr/bin /usr/sbin /usr/share/man
54+
55+
USER plug
56+
EXPOSE 30333 9933 9944 9615
57+
VOLUME ["/data"]
58+
59+
ENTRYPOINT ["/usr/local/bin/plug"]

.plug/docker-compose.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
version: "3.7"
2+
3+
x-default:
4+
&plug-image
5+
plugnet/plugblockchain:latest
6+
7+
services:
8+
alice:
9+
image: *plug-image
10+
container_name: alice
11+
command:
12+
- --alice
13+
- --base-path=/tmp/node
14+
- --chain=local
15+
- --no-telemetry
16+
- --rpc-cors=all
17+
- --unsafe-rpc-external
18+
- --unsafe-ws-external
19+
ports:
20+
- 9615:9615 # prometheus
21+
- 9933:9933 # rpc
22+
- 9944:9944 # ws
23+
- 30333:30333 # p2p
24+
volumes:
25+
- ./data/alice:/tmp/node
26+
27+
bob:
28+
image: *plug-image
29+
container_name: bob
30+
command:
31+
- --bob
32+
- --base-path=/tmp/node
33+
- --chain=local
34+
- --no-telemetry
35+
- --rpc-cors=all
36+
- --unsafe-rpc-external
37+
- --unsafe-ws-external
38+
volumes:
39+
- ./data/bob:/tmp/node
40+
41+
charlie:
42+
image: *plug-image
43+
container_name: charlie
44+
command:
45+
- --charlie
46+
- --base-path=/tmp/node
47+
- --chain=local
48+
- --no-telemetry
49+
- --rpc-cors=all
50+
- --unsafe-rpc-external
51+
- --unsafe-ws-external
52+
volumes:
53+
- ./data/charlie:/tmp/node
54+
55+
prometheus:
56+
image: prom/prometheus
57+
container_name: prometheus
58+
ports:
59+
- 9090:9090
60+
volumes:
61+
- ./prometheus/:/etc/prometheus/
62+
links:
63+
- alice:alice
64+
- bob:bob
65+
- charlie:charlie
66+
restart: always
67+
68+
grafana:
69+
image: grafana/grafana
70+
container_name: grafana
71+
depends_on:
72+
- prometheus
73+
ports:
74+
- 3001:3000
75+
volumes:
76+
- ./grafana/provisioning/:/etc/grafana/provisioning
77+
restart: always
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: 1
2+
3+
deleteDatasources:
4+
- name: Prometheus
5+
6+
datasources:
7+
- name: Prometheus
8+
type: prometheus
9+
access: proxy
10+
url: http://localhost:9090

.plug/logger.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7+
export TERM=${TERM:-xterm}
8+
79
bold=$(tput bold)
810
red=$(tput setaf 1)
911
green=$(tput setaf 2)

.plug/prometheus/prometheus.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
global:
2+
scrape_interval: 15s
3+
scrape_configs:
4+
- job_name: plug-nodes
5+
static_configs:
6+
- targets: ['alice:9615']
7+
labels:
8+
network: local
9+
- targets: ['bob:9615']
10+
labels:
11+
network: local
12+
- targets: ['charlie:9615']
13+
labels:
14+
network: local

0 commit comments

Comments
 (0)