Dappnode package development
Description
Dappnode packages supports two types of configuration
- Single Configuration - Used to generate a single package, tailored for a specific configuration.
- Multi-Configuration - Used to generate multiple packages with varying configurations, such as different networks or client setups.
Provided guide is focused on Multi-Configuration variant because it provides more flexibility.
The easiest way to develop the package is to use a VM and in that guide we will use Hetzner Cloud.
Server
- Run an Ubuntu VM on Hetzner -
8vCPU/16GB RAM(cx42/cpx41) - Create firewall rules based on the Cloud Providers / AWS guide
Protocol Port Service Source Comment TCP22SSH0.0.0.0/0TCP80HTTP0.0.0.0/0Required for services exposing only? TCP443HTTP0.0.0.0/0Required for services exposing only? UDP51820Wireguard0.0.0.0/0TCP1024-65535General TCP0.0.0.0/0UDP1024-65535General UDP0.0.0.0/0
Install
- We can install Dappnode on Ubuntu VM using Script installation
# Prerequisites sudo wget -O - https://prerequisites.dappnode.io | sudo bash # Dappnode sudo wget -O - https://installer.dappnode.io | sudo bash # Restart sudo reboot
Connect
Note
Please wait for 1-3 minutes after node was started.
-
Check Dappnode status
dappnode_status -
Run Dappnode if not started
dappnode_start -
Get wireguard credentials and connect to the Dappnode instance - WireGuard Access to Dappnode
dappnode_wireguard -
Open http://my.dappnode in the browser.
Considerations
- Users might run a lot of different packages, which can use some standard ports like
30303, this is why we used different default ports
Just add 10000 to every port.30303 --> 40303
Development
-
Clone GitHub repository on local machine
git clone https://github.com/codex-storage/DAppNodePackage-codex # For new package run 'init' # npx @dappnode/dappnodesdk init --use-variants --dir DAppNodePackage-codexAdd you changes to the code.
-
Copy package files to Dappnode server
local_dir="DAppNodePackage-codex" remote_dir="/opt/DAppNodePackage-codex" host="root@<server-ip>" rsync -avze ssh --rsync-path='sudo rsync --mkpath' "${local_dir}/" "${host}:${remote_dir}/" --delete -
Install Node.js on Dappnode server using nvm
# nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash # Load export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm # Node 20 nvm install 20 # Check node --version # v20.18.2 -
Install DAppNodeSDK on remote Dappnode
# Install npx -y @dappnode/dappnodesdk # Help npx @dappnode/dappnodesdk --help -
Get Dappnode IPFS IP:
Packages-->System packages-->Ipfs-->Network-->Container IP -
Build the package
# Code directory - multi-arch builds failed with --dir argument cd /opt/DAppNodePackage-codex # Use Ipfs node IP npx @dappnode/dappnodesdk build --all-variants --provider=http://172.33.0.2:5001Dappnode Package (codex.public.dappnode.eth) built and uploaded DNP name : codex.public.dappnode.eth Release hash : /ipfs/QmR7HVCpyWyDLGswF5Z1FXebrr3XjbWZeYQV2bhq5e4v1Q http://my.dappnode/installer/public/%2Fipfs%2FQmR7HVCpyWyDLGswF5Z1FXebrr3XjbWZeYQV2bhq5e4v1Q -
Install the package via DAppStore and using IPFS CID from previous step and check
Bypass only signed safe restriction
Publish
Limitations
- Dappnode packages are built on top of the Docker Compose which has limited configuration flexibility and DAppNodeSDK does not provide any workarounds.
- Docker Compose base imply the following limitations
- Variables
- If we need to pass an optional environment variable, it needs to be defined in Compose file with some default value and it anyway will be passed to the container
- If that optional variable can't accept a blank value, we should undefine it conditionally in the Docker entrypoint
- Ports
- If we need to define an optional port forwarding, it needs to be defined in Compose file with some default values and it anyway will be active and take the port on the node
- There is no way to configure "really optional" port forwarding
- A workaround would be use a separate package variant, but it is to big overhead
- Variables
- We can't have a relation between variable and port forwarding, to setup same value using a single field. User have to fill separately two fields with the same value.
- Multi-Configuration package does not provide a real flexibility, it just generate multiple separate packages and it doesn't work like a single package with multiple options during the installation.
- Using profiles with Compose is not supported.
- There is no way to setup a custom service name during package installation and it is predefined in the main
dappnode_package.json- We can set an alias like
codex.public.dappnode --> codex-app.codex.public.dappnode - That can be done for a single service in the package
- We can set an alias like
- Is there a way to adjust container port for Published ports or we can configure just host port?
- File
setup-wizard.ymlis not supported in Multi-Config Package Development which is very confusing. And same issue is with thegetting-started.md. - There is no way to setup custom service names for multiple services and they all namespaced under the
package name# Public packages geth.codex.public.dappnode codex-app.codex.public.dappnode codex-node.codex.public.dappnode - When we have Multi-Configuration package, we should define different package name for each variant, which imply different namespaces for services names and that looks not so nice, for example
If we would like to have separate packages, which would permit to use same handy URL like# Package codex codex.public.dappnode --> codex-app.codex.public.dappnode codex-app.codex.public.dappnode codex-node.codex.public.dappnode # Package codex-local-geth codex-local-geth.public.dappnode --> codex-app.codex-local-geth.public.dappnode codex-app.codex-local-geth.public.dappnode codex-node.codex-local-geth.public.dappnode geth.codex-local-geth.public.dappnodecodex.public.dappnodefor main service, and other services under that namespace, it would be required to have separate repositories(package folders) with the same package name. It can be a cosmetic point, but it highlights a limitation we have.
Known issues
- Latest Node.js LTS release 22, is not supported and we should use version 20.
- During local package build it is uploaded to the local IPFS node, but in the Dappnode UI package avatar is loaded from the https://gateway.ipfs.dappnode.io, so most probably it will not be shown and it is not so clear what is the issue. Maybe something is wrong with avatar or something else? We can use default avatar, which is known by Dappnode IPFS gateway.
- File
getting-started.mdis not specified in the official documentation, but it exists and is very usefully. - Dappnodesdk does not support
compose.yamlfile, which is default and preferred. - Often time it can be more effective to explorer existing packages configuration, than to use a documentation.
- During the package build, Docker warn that "the attribute
versionis obsolete", but dappnodesdk will fail if we remove it - that is very confusing.