Implement package build with `--template` flag
dappnodedev opened this issue · 4 comments
In order to allow repository unification, we need to implement a solution in the SDK that allows the developer to build a package in a generic repository, like https://github.com/dappnode/DAppNodePackage-geth-generic, by passing an argument that differentiates the variant of the package desired to be built.
The command will receive --template
flag, and also a (probably compulsory) argument flag, like --arg NETWORK=prater
or even an array like --args NETWORK=[mainnet, prater]
The build command should do the following tasks:
- Generate the definitive manifest (
dappnode_package.json
) by joining the fields included indappnode_package_template.json
to the ones defined in/package_variants/<variant>/dappnode_package.json
- Take the field
ports
from the template manifest and include it in the compose file, as package variants will need to map different ports in order to avoid conflicts - Take the fields
arg
andargInServices
from the template manifest and include thearg
in the compose file below the services defined inargInServices
- (Optional) If the build command is run with flag like
--args NETWORK=[prater, mainnet]
both packages need to be built and published to IPFS node, and the command output should show it
To be considered: Is it worth to support passing more than 1 arg?
Instead of arg
we could call it buildEnv
We have decided that any specific config will need to be set inside each variant. The manifest file schema should not be modified and we can just create a compose file in each of the variants that will extend the root compose file, following: https://docs.docker.com/compose/multiple-compose-files/extends/
The final directory tree for each package will look like this one:
.
├── avatar.png
├── dappnode_package.json
├── docker-compose.yml
├── geth
│ ├── Dockerfile
│ ├── entrypoint.sh
│ └── ...
├── LICENSE
├── package_variants
│ ├── goerli
│ │ ├── dappnode_package.json
│ │ └── docker-compose.yml
│ ├── mainnet
│ │ ├── dappnode_package.json
│ │ └── docker-compose.yml
│ └── sepolia
│ ├── dappnode_package.json
│ └── docker-compose.yml
└── releases.json
The docker-compose merge
feature allows to put together the common compose file and the specific one for each of the variants. A similar process is done to merge the common manifest with the specific ones