Skip to content

Commit

Permalink
Mithril in container and docs (#1707)
Browse files Browse the repository at this point in the history
## Description
- The Mithril binaries and scripts were added to the container build
process.
- Changed `chown` commands to recursively make guild the owner of
`/opt/cardano/cnode`.
- Required for succes of the **mithril-client.sh** `rmdir
${CNODE_HOME}/db` and the subsequent **mithril-client** binary `mkdir
${CNODE_HOME}/db` operation.
- Combined multiple ADD steps into a single ADD per destination,
resulting in fewer individual 4KB layers.
- Updated documentation
  - **docker.md**
- Added mithril-client and mithril signer to the **Built-in Cardano
software** list.
- Added Ogmios, Cardano Hardware CLI, and Cardano Signer to the
**Built-in tools**
- Changed the multistage building and `prereqs.sh` to the single stage
currently used and `guild-depoy.sh`.
  - **run.md**
- Added a note describing how to set the **MITHRIL_DOWNLOAD**
environment variable causing mithril-client to automatically sync the
latest snapshot.

## Where should the reviewer start?
Build the container locally. Start the container with `--env
MITHRIL_DOWNLOAD=Y`. Observe in the logs:
```
NETWORK: mainnet  
NODE: 3ca9aa9b33b1 - Port:6000 - 
cardano-node 8.1.2 - linux-x86_64 - ghc-8.10
git rev d2d90b48c5577b4412d5c9c9968b55f8ab4b9767
INFO: Mithril environment file not found, creating environment file..
INFO: Mithril environment file created successfully!!
INFO: The db directory is empty..
INFO: Removing empty db directory to prepare for snapshot download..
INFO: Downloading latest mithril snapshot..
```

## Motivation and context
Provides container users similar functionality for startup of new nodes
relying on mithril-client instead of full chain synchronization via
FetchBlock.

## How has this been tested?
1. Locally building the container
2. Starting container without any additional environment variables to
observe normal chain synchronization.
3. Starting container with `--env MITHRIL_DOWNLOAD=Y` and observing the
directory gets removed (as required by mithril-client), recreated (by
mithril-client) and the snapshot synchronization occurs as expected.
  • Loading branch information
TrevorBenson authored Nov 26, 2023
1 parent 95bcf58 commit 2349b04
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
17 changes: 13 additions & 4 deletions docs/docker/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ Running your own Cardano node has never been so fast and easy.
- cardano-hw-cli
- cardano-node
- cardano-submit-api
- mithril-client
- mithril-signer

#### Mithril

### 🔔 Built-in tools

- CNTools
- gLiveView
- CNCLI
- Ogmios
- Cardano Hardware CLI
- Cardano Signer
- Monitoring ready (with EKG and Prometheus)

#### Docker Splash screen
Expand All @@ -48,11 +55,13 @@ Running your own Cardano node has never been so fast and easy.

Modular docker images based on Debian.

Based on the Guild's work we decided to build the Cardano Node images in 3 stages:
Based on the Guild's work the Cardano Node image is built in a single stage: -> [dockerfile_bin](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_bin)

- Uses `guild-deploy.sh` to:
- Install the os prerequisites
- Add the cardano software from release binaries
- Add the guild's SPO tools and the node's configuration files.

- 1st stage: it uses `prereq.sh` to prepare the development environment before compiling the node source code. -> [Stage1](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage1)
- 2nd stage: based on stage1, this stage intent is to compile and produce the binaries of the node. -> [Stage2](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage2)
- 3rd stage: based upon a minimal debian image it incorporates the node's binaries as well as all the Koios' SPO tools. -> [Stage3](https://github.com/cardano-community/guild-operators/blob/master/files/docker/node/dockerfile_stage3)

### Additional docs

Expand Down
3 changes: 2 additions & 1 deletion docs/docker/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@
!!! info "Note"
1) `--entrypoint=bash` # This option won't start the node's container but only the OS running (the node software wont actually start, you'll need to manually execute entrypoint.sh ), ready to get in (trough the command ``` docker exec -it < container name or hash > /bin/bash ```) and play/explore around with it in command line mode.
2) all guild tools env variable can be used to start a new container using custom values by using the "-e" option.
3) CPU and RAM and SHared Memory allocation option for the container can be used when you start the container (i.e. --shm-size or --memory or --cpus [official docker resource docs](https://docs.docker.com/config/containers/resource_constraints/))
3) CPU and RAM and Shared Memory allocation option for the container can be used when you start the container (i.e. --shm-size or --memory or --cpus [official docker resource docs](https://docs.docker.com/config/containers/resource_constraints/))
4) `--env MITHRIL_DOWNLOAD=Y` # This option will allow Mithril client to download the latest Mithril snapshot of the blockchain when the container starts and does not have a copy of the blockchain yet. This is useful when you want to start a new node from scratch and don't want to wait for the node to sync from the network. This option is only available for the mainnet, preprod, and preview networks.
19 changes: 11 additions & 8 deletions files/docker/node/dockerfile_bin
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ RUN set -x && apt update \
RUN set -x && export SUDO='N' \
&& export UPDATE_CHECK='N' \
&& export SKIP_DBSYNC_DOWNLOAD='Y' \
&& ./guild-deploy.sh -b master -s dcowx \
&& ./guild-deploy.sh -b master -s dcmowx \
&& cd /usr/bin \
&& wget http://www.vdberg.org/~richard/tcpping \
&& chmod 755 tcpping \
&& chown -R guild:guild $CNODE_HOME/* \
&& chown -R guild:guild $CNODE_HOME \
&& mv /root/.local/bin /home/guild/.local/ \
&& chown -R guild:guild /home/guild/.* \
&& chmod a+x /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh
Expand All @@ -89,15 +89,18 @@ RUN curl -sL -H "Accept: application/vnd.github.everest-preview+json" -H "Conte


# ENTRY SCRIPT
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh /opt/cardano/cnode/scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-client.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-signer.sh \
https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/mithril-relay.sh /opt/cardano/cnode/scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/entrypoint.sh ./

RUN sudo chmod a+rx /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh /home/guild/entrypoint.sh \
&& sudo chown -R guild:guild /home/guild/.* $CNODE_HOME/*
&& sudo chown -R guild:guild /home/guild/.* $CNODE_HOME

HEALTHCHECK --start-period=5m --interval=5m --timeout=100s CMD /home/guild/.scripts/healthcheck.sh

Expand Down

0 comments on commit 2349b04

Please sign in to comment.