Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(devnet): add substrate docker images to dockerfile #2263

Merged
merged 38 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6139712
feat: include substrate docker image
EclesioMeloJunior Jan 31, 2022
8c3fb1d
chore: add substrate docker images
EclesioMeloJunior Feb 2, 2022
c0be6dc
chore: formatting and add depends on yaml key
EclesioMeloJunior Feb 2, 2022
eda4e4a
chore: add datadog stuff again
EclesioMeloJunior Feb 2, 2022
dae59e2
chore: use alice peer id
EclesioMeloJunior Feb 2, 2022
6ccf8fb
chore: split substrate docker compose services into another file
EclesioMeloJunior Feb 2, 2022
1407b3a
chore: enable prometheus external and add datadog
EclesioMeloJunior Feb 2, 2022
0d59fac
Merge branch 'development' into eclesio/substrate-docker-image
EclesioMeloJunior Feb 4, 2022
5108412
chore: keep substrate ports same as gossamer node ports
EclesioMeloJunior Feb 4, 2022
9fa7ffb
chore: expose rpc and ws calls in substrate docker file
EclesioMeloJunior Feb 4, 2022
71a8f5e
chore: use same dns name and p2p id
EclesioMeloJunior Feb 4, 2022
f1fea2d
chore: use same key for both alice gossamer and substrate nodes
EclesioMeloJunior Feb 4, 2022
9b485f6
chore: fix dd golang cmd
EclesioMeloJunior Feb 4, 2022
cff9c8c
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
262b329
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
012b4b9
chore: update `substrate_alice` readme info
EclesioMeloJunior Feb 7, 2022
1d158a3
Update devnet/README.md
EclesioMeloJunior Feb 7, 2022
f0689ee
chore: add `/tcp` to expose ports
EclesioMeloJunior Feb 7, 2022
604ce4b
Merge branch 'eclesio/substrate-docker-image' of github.com:ChainSafe…
EclesioMeloJunior Feb 7, 2022
237647a
chore: adjust args and envs
EclesioMeloJunior Feb 7, 2022
ae0429e
chore: pin prometheus version, add read only volume and add trailing …
EclesioMeloJunior Feb 7, 2022
843d361
chore: improve README.md
EclesioMeloJunior Feb 7, 2022
bcb134e
Merge branch 'development' into eclesio/substrate-docker-image
EclesioMeloJunior Feb 7, 2022
579136c
chore: add port 7001 explicitly
EclesioMeloJunior Feb 7, 2022
c49bcf0
chore: remove prometheus `--config.file` flag
EclesioMeloJunior Feb 8, 2022
f03093a
chore: use env to chain
EclesioMeloJunior Feb 8, 2022
25946ca
update substrate_bob.Dockerfile
EclesioMeloJunior Feb 8, 2022
e8c1e9d
Merge branch 'development' into eclesio/substrate-docker-image
EclesioMeloJunior Feb 9, 2022
15f1377
chore: add datadog-agent start to gssmr alice node
EclesioMeloJunior Feb 9, 2022
94c6a87
Merge branch 'eclesio/substrate-docker-image' of github.com:ChainSafe…
EclesioMeloJunior Feb 9, 2022
17fd1f2
chore: add comment about different but same node keys
EclesioMeloJunior Feb 16, 2022
aacb438
chore: update substrate docker images to version 0.9.17
EclesioMeloJunior Mar 2, 2022
a382561
chore: include license header
EclesioMeloJunior Mar 2, 2022
ca63faa
Merge branch 'development' into eclesio/substrate-docker-image
EclesioMeloJunior Mar 3, 2022
a4bd83c
chore: make image smaller, start dd agent at entrypoint
EclesioMeloJunior Mar 3, 2022
e476e23
chore: use only one genesis
EclesioMeloJunior Mar 3, 2022
e12686d
chore: be more descriptive at genesis.json folder
EclesioMeloJunior Mar 4, 2022
03c89c6
chore: update image to use arg polkadot version
EclesioMeloJunior Mar 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion devnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ docker-compose up --abort-on-container-exit
docker-compose down
```

>> optional: you can add the flag `-f` followed by the path to the docker-compose.yml file

> **_NOTE:_** The devnet is not stateful, so subsequent runs will start from the genesis block.

## Prometheus Datadog Integration
Expand All @@ -39,7 +41,13 @@ export $DD_API_KEY=YourKey

### Dockerfiles

There are two Docker files used in the devnet. `alice.Dockerfile` is the lead node and is intiated with the `babe-lead` flag to build the first block. `bob.Dockerfile` is used for both `bob` and `charlie`.
There are four Docker files used in the devnet.
- `alice.Dockerfile` is the lead node and is intiated with the `babe-lead` flag to build the first block.
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
- `bob.Dockerfile` is used for both `bob` and `charlie` and shares the same genesis as alice docker file.
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
- `substrate_alice.Dockerfile` is the alice node initiated with the all 0s node key to keep an deterministic peer id
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
- `substrate_bob.Dockerfile` is used for `bob` and `charlie` and shares the same genesis as alice docker file.
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved

> **_NOTE:_**: It is possible to use substrate alice node with bob and charlie gossamer nodes or any combination since the nodes in the network contains different keys
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved

### cmd/update-dd-agent-confd

Expand Down
4 changes: 2 additions & 2 deletions devnet/alice.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY . .
RUN go install -trimpath github.com/ChainSafe/gossamer/cmd/gossamer

# use modified genesis-spec.json with only 3 authority nodes
RUN cp -f devnet/chain/gssmr/genesis-spec.json chain/gssmr/genesis-spec.json
RUN cp -f devnet/chain/gssmr/genesis-raw.json chain/gssmr/genesis-spec.json

RUN gossamer --key=alice init

Expand All @@ -34,4 +34,4 @@ WORKDIR /gossamer

ENTRYPOINT service datadog-agent start && gossamer --key=alice --babe-lead --publish-metrics --rpc --rpc-external=true --pubdns=alice

EXPOSE 7001/tcp 8545/tcp 8546/tcp 8540/tcp 9876/tcp
EXPOSE 7001/tcp 8545/tcp 8546/tcp 8540/tcp 9876/tcp 6060/tcp
qdm12 marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 8 additions & 3 deletions devnet/bob.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY . .
RUN go install -trimpath github.com/ChainSafe/gossamer/cmd/gossamer

# use modified genesis-spec.json with only 3 authority nodes
RUN cp -f devnet/chain/gssmr/genesis-spec.json chain/gssmr/genesis-spec.json
RUN cp -f devnet/chain/gssmr/genesis-raw.json chain/gssmr/genesis-spec.json

ARG key
RUN test -n "$key"
Expand All @@ -33,6 +33,11 @@ RUN go run cmd/update-dd-agent-confd/main.go -n=${METRICS_NAMESPACE} -t=key:${ke

WORKDIR /gossamer

ENTRYPOINT service datadog-agent start && gossamer --key=${key} --bootnodes=/dns/alice/tcp/7001/p2p/12D3KooWMER5iow67nScpWeVqEiRRx59PJ3xMMAYPTACYPRQbbWU --publish-metrics --rpc --pubdns=${key}
ENTRYPOINT service datadog-agent start && \
gossamer --key=${key} \
--bootnodes=/dns/alice/tcp/7001/p2p/12D3KooWMER5iow67nScpWeVqEiRRx59PJ3xMMAYPTACYPRQbbWU \
--publish-metrics \
--rpc \
--pubdns=${key}

EXPOSE 7001/tcp 8545/tcp 8546/tcp 8540/tcp 9876/tcp
EXPOSE 7001/tcp 8545/tcp 8546/tcp 8540/tcp 9876/tcp 6060/tcp
157 changes: 157 additions & 0 deletions devnet/chain/gssmr/genesis-raw.json

Large diffs are not rendered by default.

298 changes: 0 additions & 298 deletions devnet/chain/gssmr/genesis-spec.json

This file was deleted.

197 changes: 197 additions & 0 deletions devnet/chain/gssmr/genesis.json

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions devnet/docker-compose-substrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
services:
prometheus:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we running prometheus in this docker-compose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added Prometheus while testing the exported metric data from authority nodes, I decided to keep it in the same file to easily start a Prometheus server with authorities nodes, should I remove it?

image: prom/prometheus
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
volumes:
- ./../prometheus.yml:/etc/prometheus/prometheus.yml
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
command:
- '--config.file=/etc/prometheus/prometheus.yml'
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- 9090:9090
restart: always

alice:
platform: linux/amd64
build:
context: ./..
dockerfile: devnet/substrate_alice.Dockerfile
ports:
- 30333
- 9933
- 9944
- 9615:9615
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 9615:9615
- 9615

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make these exposed ports the same as gossamer? Or we should at least comment what the diff ports do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is possible!


bob:
platform: linux/amd64
build:
context: ./..
dockerfile: devnet/substrate_bob.Dockerfile
args:
key: bob
ports:
- 30333
- 9933
- 9944
- 9615
depends_on:
- alice

charlie:
platform: linux/amd64
build:
context: ./..
dockerfile: devnet/substrate_bob.Dockerfile
args:
key: charlie
ports:
- 30333
- 9933
- 9944
- 9615
depends_on:
- alice
7 changes: 6 additions & 1 deletion devnet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
alice:
platform: linux/amd64
build:
context: ./..
dockerfile: devnet/alice.Dockerfile
Expand All @@ -11,8 +12,10 @@ services:
- 8546
- 8540
- 9876
- 6060
qdm12 marked this conversation as resolved.
Show resolved Hide resolved

bob:
platform: linux/amd64
build:
context: ./..
dockerfile: devnet/bob.Dockerfile
Expand All @@ -25,10 +28,12 @@ services:
- 8546
- 8540
- 9876
- 6060
depends_on:
- alice

charlie:
platform: linux/amd64
build:
context: ./..
dockerfile: devnet/bob.Dockerfile
Expand All @@ -42,4 +47,4 @@ services:
- 8540
- 9876
depends_on:
- alice
- alice
26 changes: 26 additions & 0 deletions devnet/substrate_alice.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM parity/polkadot:v0.9.10 as polkadot
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
FROM golang:1.17

ARG VERSION=v0.9.10
ARG DD_API_KEY=somekey
ENV DD_API_KEY=${DD_API_KEY}
ARG METRICS_NAMESPACE=substrate.local.devnet

RUN apt-get update

RUN DD_AGENT_MAJOR_VERSION=7 DD_INSTALL_ONLY=true DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"

COPY --from=polkadot /usr/bin/polkadot /usr/bin/polkadot
COPY devnet/chain/gssmr/genesis-raw.json genesis-spec.json

RUN go run cmd/update-dd-agent-confd/main.go -n=${METRICS_NAMESPACE} -t=key:alice > /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what port is prometheus running on? update-dd-agent-config is currently expecting the prometheus endpoint to be http://127.0.0.1:9876/metrics.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed substrate nodes to expose Prometheus at port 9876

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What port does substrate uses? Shouldn't we use the standard 9090 port for Gossamer as well 🤔

Copy link
Member Author

@EclesioMeloJunior EclesioMeloJunior Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default the port 9090 is the one Prometheus docker image prom/prometheus uses to bootstrap its own server to collect metrics. I just standardized the port which substrate and gossamer will expose metrics

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but by default what's the port substrate/polkadot uses for Prometheus? We force it to 9876 here it seems. I'm thinking we should change it in Gossamer (for end users experience).

As far as I know, applications usually have their Prom registry server listening on 9090, so maybe we want to use that instead? Although if polkadot uses 9876 for whatever weird reason, then sure we can match it as well I guess.


ENTRYPOINT ./polkadot \
--chain genesis-spec.json \
--alice \
--node-key 0000000000000000000000000000000000000000000000000000000000000000 \
--tmp \
--prometheus-external


EXPOSE 30333 9933 9944 9615
27 changes: 27 additions & 0 deletions devnet/substrate_bob.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This is the build stage for Substrate. Here we create the binary.
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
FROM parity/polkadot:v0.9.10
FROM docker.io/library/ubuntu:20.04

ARG key
ARG DD_API_KEY=somekey
ARG METRICS_NAMESPACE=substrate.local.devnet

ENV key=${key}
ENV DD_API_KEY=${DD_API_KEY}
qdm12 marked this conversation as resolved.
Show resolved Hide resolved

RUN test -n "$key"
RUN DD_AGENT_MAJOR_VERSION=7 DD_INSTALL_ONLY=true DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"

COPY --from=polkadot /usr/bin/polkadot /usr/bin/polkadot
COPY devnet/chain/gssmr/genesis-raw.json genesis-spec.json

RUN go run cmd/update-dd-agent-confd/main.go -n=${METRICS_NAMESPACE} -t=key:${key} > /etc/datadog-agent/conf.d/openmetrics.d/conf.yaml

ENTRYPOINT service datadog-agent start && /usr/bin/polkadot \
--bootnodes=/dns/substrate-alice/tcp/30333/p2p/12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I were to use this Dockerfile to connect to a gossamer alice how would this work? If I wanted to connect substrate non-lead nodes to a gossamer lead node how would that work?

The libp2p id would have to be the same for both substrate and gossamer alice nodes.

Copy link
Member Author

@EclesioMeloJunior EclesioMeloJunior Feb 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now both substrate and gossamer alice nodes use the same node key so if you spin up a gossamer alice container and spin up bob and charlie substrate nodes they will connect without modifications to the image.

--chain genesis-spec.json \
--${key} \
--tmp \
--prometheus-external

EXPOSE 30333 9933 9944 9615
5 changes: 4 additions & 1 deletion prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ scrape_configs:
- job_name: gossamer
metrics_path: /metrics
static_configs:
- targets: ['host.docker.internal:9876']
- targets: ['host.docker.internal:9876']
- job_name: substrate
static_configs:
- targets: ['alice:9615']