forked from eth-educators/eth-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be2fdce
commit bef3524
Showing
14 changed files
with
282 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
version: "3" | ||
services: | ||
beacon: | ||
expose: | ||
- 8008 | ||
command: | ||
- --metrics | ||
- --metrics-port=8008 | ||
- --metrics-address=0.0.0.0 | ||
prometheus: | ||
restart: "no" | ||
build: | ||
context: ./prometheus | ||
image: prometheus | ||
volumes: | ||
- prom-data:/prometheus | ||
environment: | ||
- CLIENT=${COMPOSE_FILE} | ||
expose: | ||
- 9090 | ||
entrypoint: choose-config.sh | ||
command: ["/bin/prometheus", "--storage.tsdb.path=/prometheus", "--web.console.libraries=/usr/share/prometheus/console_libraries", "--web.console.templates=/usr/share/prometheus/consoles"] | ||
depends_on: | ||
- beacon | ||
- node-exporter | ||
node-exporter: | ||
restart: "no" | ||
image: prom/node-exporter | ||
expose: | ||
- 9100 | ||
grafana: | ||
restart: "no" | ||
image: grafana/grafana | ||
volumes: | ||
- grafana-data:/var/lib/grafana | ||
depends_on: | ||
- prometheus | ||
ports: | ||
- ${GRAFANA_PORT}:3000/tcp | ||
eth2: | ||
depends_on: | ||
- grafana | ||
volumes: | ||
grafana-data: | ||
prom-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
version: "3" | ||
services: | ||
beacon: | ||
restart: "no" | ||
user: ${LOCAL_UID}:${LOCAL_UID} | ||
build: | ||
context: ./nimbus | ||
args: | ||
- BUILD_TARGET=${NIM_BUILD_TARGET} | ||
- USER=${NIM_USER} | ||
- UID=${LOCAL_UID} | ||
- METRICS=${NIM_METRICS} | ||
image: nimbus | ||
volumes: | ||
- nimbus-data:/var/lib/nimbus | ||
ports: | ||
- ${NIM_PORT}:19000/tcp | ||
- ${NIM_PORT}:19000/udp | ||
entrypoint: | ||
- /usr/local/bin/beacon_node | ||
- --data-dir=/var/lib/nimbus | ||
- --non-interactive | ||
- --log-file=/var/lib/nimbus/beacon_node.log | ||
- --network=${TESTNET} | ||
- --web3-url=${ETH1_NODE} | ||
- --graffiti=${GRAFFITI} | ||
- --log-level=${LOG_LEVEL} | ||
validator-import: | ||
restart: "no" | ||
user: ${LOCAL_UID}:${LOCAL_UID} | ||
image: nimbus | ||
build: | ||
context: ./nimbus | ||
args: | ||
- BUILD_TARGET=${NIM_BUILD_TARGET} | ||
- USER=${NIM_USER} | ||
- UID=${LOCAL_UID} | ||
- METRICS=${NIM_METRICS} | ||
volumes: | ||
- nimbus-data:/var/lib/nimbus | ||
- ${DEPCLI_LOCALDIR}/validator_keys:/var/lib/nimbus/validator_keys | ||
entrypoint: ["/usr/local/bin/beacon_node", "deposits", "import", "--data-dir=/var/lib/nimbus", "--log-file=/var/lib/nimbus/beacon_node.log", "--network=${TESTNET}", "/var/lib/nimbus/validator_keys"] | ||
deposit-cli: | ||
restart: "no" | ||
user: ${LOCAL_UID}:${LOCAL_UID} | ||
build: | ||
context: ./eth2.0-deposit-cli | ||
args: | ||
- BUILD_TARGET=${DEPCLI_BUILD_TARGET} | ||
- USER=${DEPCLI_USER} | ||
- UID=${LOCAL_UID} | ||
image: eth2.0-deposit-cli | ||
volumes: | ||
- ${DEPCLI_LOCALDIR}:/var/lib/depcli-data | ||
entrypoint: ${DEPCLI_ENTRYPOINT} | ||
command: | ||
- --num_validators | ||
- ${NUMVAL} | ||
- --chain | ||
- ${DEPOSIT_CHAIN} | ||
eth2: | ||
image: tianon/true | ||
restart: "no" | ||
depends_on: | ||
- beacon | ||
volumes: | ||
nimbus-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Build Nimbus in a stock debian container | ||
FROM debian:buster-slim as builder | ||
|
||
ARG BUILD_TARGET | ||
ARG METRICS | ||
|
||
RUN apt-get update && apt-get install -y build-essential git libpcre3-dev ca-certificates | ||
|
||
WORKDIR /usr/src | ||
RUN git clone https://github.com/status-im/nim-beacon-chain && cd nim-beacon-chain && git config advice.detachedHead false && git fetch --all --tags && git checkout ${BUILD_TARGET} && make ${METRICS} beacon_node | ||
|
||
# Pull all binaries into a second stage deploy debian container | ||
FROM debian:buster-slim | ||
|
||
ARG USER | ||
ARG UID | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# See https://stackoverflow.com/a/55757473/12429735RUN | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/usr/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
RUN mkdir -p /var/lib/nimbus && chown ${USER}:${USER} /var/lib/nimbus | ||
|
||
# Copy executable | ||
COPY --from=builder /usr/src/nim-beacon-chain/build/beacon_node /usr/local/bin/beacon_node | ||
|
||
# Use an unprivileged user. | ||
USER ${USER}:${USER} | ||
|
||
ENTRYPOINT ["beacon_node", "--data-dir=/var/lib/nimbus", "--web3-url=http://geth:8545", "--network=medalla", "--log-file=/var/lib/nimbus/beacon_node.log"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Docker container for Nimbus eth2 client | ||
|
||
This creates a compiled nimbus, in a debian-slim container | ||
|
||
Pass BUILD_TARGET, USER and UID during build if you are not using docker-compose, as well as METRICS | ||
which is the compile-time flag for the http metrics server | ||
|
||
Firewalling: You want 19000 tcp/udp to be exposed to "the Internet", port-forwarded if | ||
this runs behind NAT. Do NOT expose 8008/tcp to world, it is http and meant only for the dashboard | ||
to interface with to get metrics | ||
|
||
A few notes on compilation and runtime options | ||
|
||
The git branch to build should be `devel` as of Sept 2020 | ||
The validator is included with the beacon node by default. They can be separated, but the code is still experimental. | ||
Max peers default is 79, you will not likely have to adjust this. | ||
Metrics require `NIMFLAGS="-d:insecure"` during compile. This option is exposed to the user via .env so they can | ||
decide on whether to include metrics. | ||
|
||
This Dockerfile compiles for the machine it is being executed on, the resulting executable is **not** portable to | ||
other architectures. `make NIMFLAGS="-d:disableMarchNative" beacon_node` is the way to build portable binaries, | ||
but that is outside the purview of this project. See https://github.com/status-im/nim-beacon-chain/tree/devel#makefile-tips-and-tricks-for-developers | ||
|
||
A static binary can be compiled with `make NIMFLAGS="--passL:-static" beacon_node`, but running in scratch was | ||
not successful, therefore I am not doing a static compile. | ||
|
||
The following assumes Ubuntu, hence sudo to run docker. If that's not necessary in your environment, | ||
just leave sudo off the command and run directly as the logged-in user. | ||
|
||
You'd run this from the docker-compose one level up. To test build and run here, while mapping to default ports: | ||
|
||
sudo docker build -t nimbus --build-arg BUILD_TARGET=devel --build-arg USER=nimbus --build-arg UID=$UID . | ||
sudo docker volume create nimbus-data | ||
sudo docker run -d --name nimbus -v nimbus:/var/lib/nimbus -p 19000:19000 -p 19000:19000/udp nimbus | ||
|
||
Example of running on port 19010 to world: | ||
|
||
sudo docker run -d --name nimbus -v nimbus:/var/lib/nimbus -p 19010:19000 -p 19010:19000/udp nimbus | ||
|
||
Watch logs: | ||
|
||
sudo docker logs -f nimbus | ||
|
||
Prune build images - saves space if no further builds are likely: | ||
|
||
sudo docker system prune -f |
Oops, something went wrong.