diff --git a/packages/dashmate/README.md b/packages/dashmate/README.md index 1508ffac5fe..b968cb0c73b 100644 --- a/packages/dashmate/README.md +++ b/packages/dashmate/README.md @@ -373,7 +373,7 @@ To start the group of nodes, ports and other required options need to be updated To start a local dash network, the `setup` command with the `local` preset can be used to generate configs, mine some dash, register masternodes and populate the nodes with the data required for local development. -To allow developers quickly test changes to DAPI and Drive, a local path for DAPI or Drive may be specified via the `platform.drive.abci.docker.build.path` and `platform.dapi.api.docker.build.path` config options. A Docker image will be built from the provided path and then used by Dashmate. +To allow developers quickly test changes to DAPI and Drive, a local path for this repository may be specified via the `platform.sourcePath` config options. A Docker image will be built from the provided path and then used by Dashmate. ### Docker Compose diff --git a/packages/dashmate/configs/migrations.js b/packages/dashmate/configs/migrations.js index 227733b09ae..7139aeaa77f 100644 --- a/packages/dashmate/configs/migrations.js +++ b/packages/dashmate/configs/migrations.js @@ -279,6 +279,21 @@ module.exports = { configFile.configs.testnet.platform.dashpay = systemConfigs.testnet.platform.dashpay; configFile.configs.testnet.platform.featureFlags = systemConfigs.testnet.platform.featureFlags; + return configFile; + }, + '0.21.7': (configFile) => { + Object.entries(configFile.configs) + .forEach(([, config]) => { + if (config.platform) { + // Remove build setting + delete config.platform.drive.abci.docker.build; + + delete config.platform.dapi.api.docker.build; + + config.platform.sourcePath = null; + } + }); + return configFile; }, }; diff --git a/packages/dashmate/configs/schema/configJsonSchema.js b/packages/dashmate/configs/schema/configJsonSchema.js index 595548b39f1..b6243e21df6 100644 --- a/packages/dashmate/configs/schema/configJsonSchema.js +++ b/packages/dashmate/configs/schema/configJsonSchema.js @@ -275,7 +275,7 @@ module.exports = { type: 'object', properties: { docker: { - $ref: '#/definitions/dockerBuild', + $ref: '#/definitions/docker', }, }, required: ['docker'], @@ -302,7 +302,7 @@ module.exports = { type: 'object', properties: { docker: { - $ref: '#/definitions/dockerBuild', + $ref: '#/definitions/docker', }, log: { type: 'object', @@ -534,8 +534,12 @@ module.exports = { required: ['contract', 'ownerId'], additionalProperties: false, }, + sourcePath: { + type: ['string', 'null'], + minLength: 1, + } }, - required: ['dapi', 'drive', 'dpns', 'dashpay', 'featureFlags'], + required: ['dapi', 'drive', 'dpns', 'dashpay', 'featureFlags', 'sourcePath'], additionalProperties: false, }, externalIp: { diff --git a/packages/dashmate/configs/system/base.js b/packages/dashmate/configs/system/base.js index d54a972f54a..cfe97c8c842 100644 --- a/packages/dashmate/configs/system/base.js +++ b/packages/dashmate/configs/system/base.js @@ -67,9 +67,6 @@ module.exports = { api: { docker: { image: 'dashpay/dapi:0.21', - build: { - path: null, - }, }, }, }, @@ -82,9 +79,6 @@ module.exports = { abci: { docker: { image: 'dashpay/drive:0.21', - build: { - path: null, - }, }, log: { stdout: { @@ -157,6 +151,7 @@ module.exports = { }, ownerId: null, }, + sourcePath: null, }, externalIp: null, network: NETWORK_TESTNET, diff --git a/packages/dashmate/docker-compose.platform.build-dapi.yml b/packages/dashmate/docker-compose.platform.build-dapi.yml deleted file mode 100644 index a1f6fb27083..00000000000 --- a/packages/dashmate/docker-compose.platform.build-dapi.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3.7' - -services: - dapi_api: - build: - context: ../../ - dockerfile: ${PLATFORM_DAPI_API_DOCKER_BUILD_PATH:?err}/Dockerfile - image: dapi:local - - dapi_tx_filter_stream: - build: - context: ../../ - dockerfile: ${PLATFORM_DAPI_API_DOCKER_BUILD_PATH:?err}/Dockerfile - image: dapi:local diff --git a/packages/dashmate/docker-compose.platform.build-drive.yml b/packages/dashmate/docker-compose.platform.build-drive.yml deleted file mode 100644 index 6a99706c5a1..00000000000 --- a/packages/dashmate/docker-compose.platform.build-drive.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3.7' - -services: - drive_abci: - build: - context: ../../ - dockerfile: ${PLATFORM_DRIVE_ABCI_DOCKER_BUILD_PATH:?err}/Dockerfile - image: drive:local diff --git a/packages/dashmate/docker-compose.platform.build.yml b/packages/dashmate/docker-compose.platform.build.yml new file mode 100644 index 00000000000..6b63fef066a --- /dev/null +++ b/packages/dashmate/docker-compose.platform.build.yml @@ -0,0 +1,20 @@ +version: '3.7' + +services: + drive_abci: + build: + context: ${PLATFORM_SOURCE_PATH:?err} + dockerfile: ${PLATFORM_SOURCE_PATH:?err}/packages/js-drive/Dockerfile + image: drive:local + + dapi_api: + build: + context: ${PLATFORM_SOURCE_PATH:?err} + dockerfile: ${PLATFORM_SOURCE_PATH:?err}/packages/dapi/Dockerfile + image: dapi:local + + dapi_tx_filter_stream: + build: + context: ${PLATFORM_SOURCE_PATH:?err} + dockerfile: ${PLATFORM_SOURCE_PATH:?err}/packages/dapi/Dockerfile + image: dapi:local diff --git a/packages/dashmate/src/config/Config.js b/packages/dashmate/src/config/Config.js index d08bb4efce3..c3cab0a8757 100644 --- a/packages/dashmate/src/config/Config.js +++ b/packages/dashmate/src/config/Config.js @@ -151,12 +151,8 @@ class Config { if (this.has('platform')) { dockerComposeFiles.push('docker-compose.platform.yml'); - if (this.get('platform.drive.abci.docker.build.path') !== null) { - dockerComposeFiles.push('docker-compose.platform.build-drive.yml'); - } - - if (this.get('platform.dapi.api.docker.build.path') !== null) { - dockerComposeFiles.push('docker-compose.platform.build-dapi.yml'); + if (this.get('platform.sourcePath') !== null) { + dockerComposeFiles.push('docker-compose.platform.build.yml'); } } diff --git a/packages/dashmate/src/docker/DockerCompose.js b/packages/dashmate/src/docker/DockerCompose.js index 07871064457..53a400d33a8 100644 --- a/packages/dashmate/src/docker/DockerCompose.js +++ b/packages/dashmate/src/docker/DockerCompose.js @@ -129,23 +129,15 @@ class DockerCompose { * @param {string} [serviceName] * @return {Promise} */ + // eslint-disable-next-line no-unused-vars async build(envs, serviceName = undefined) { await this.throwErrorIfNotInstalled(); try { - let driveArg = '-f docker-compose.platform.build-drive.yml'; - let dapiArg = '-f docker-compose.platform.build-dapi.yml'; - - if (serviceName === 'drive_abci') { - dapiArg = ''; - } else if (serviceName === 'dapi_api') { - driveArg = ''; - } - // Temporarily build with buildx bake until docker compose build selects correct builder // https://github.com/docker/compose-cli/issues/1840 const childProcess = exec( - `docker buildx bake --progress plain --load ${driveArg} ${dapiArg}`, + 'docker buildx bake --progress plain --load -f docker-compose.platform.build.yml', this.getOptions(envs), ); diff --git a/packages/dashmate/src/index.js b/packages/dashmate/src/index.js deleted file mode 100644 index 8b3c5a85d43..00000000000 --- a/packages/dashmate/src/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('@oclif/command'); diff --git a/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js b/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js index b8db0002e1c..9463ca48e8c 100644 --- a/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/buildServicesTaskFactory.js @@ -19,19 +19,7 @@ function buildServicesTaskFactory( task: async (ctx, task) => { const envs = config.toEnvs(); - const doDriveBuild = config.get('platform.drive.abci.docker.build.path'); - const doDAPIBuild = config.get('platform.dapi.api.docker.build.path'); - - let serviceName; - if (doDriveBuild && doDAPIBuild) { - serviceName = null; - } else if (!doDriveBuild) { - serviceName = 'dapi_api'; - } else if (!doDAPIBuild) { - serviceName = 'drive_abci'; - } - - const buildProcess = await dockerCompose.build(envs, serviceName); + const buildProcess = await dockerCompose.build(envs); if (ctx.isVerbose) { buildProcess.stdout.pipe(task.stdout()); diff --git a/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js b/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js index 90bbac97b91..c954b3a83c7 100644 --- a/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/startGroupNodesTaskFactory.js @@ -36,10 +36,7 @@ function startGroupNodesTaskFactory( )); const platformBuildConfig = configGroup.find((config) => ( - config.has('platform') && ( - config.get('platform.dapi.api.docker.build.path') !== null - || config.get('platform.drive.abci.docker.build.path') !== null - ) + config.has('platform.sourcePath') && config.get('platform.sourcePath') !== null )); return new Listr([ diff --git a/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js b/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js index b661ad6e56d..bc636be7d69 100644 --- a/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js +++ b/packages/dashmate/src/listr/tasks/startNodeTaskFactory.js @@ -74,11 +74,9 @@ function startNodeTaskFactory( }, }, { - enabled: (ctx) => !ctx.skipBuildServices && config.has('platform') - && ( - config.get('platform.dapi.api.docker.build.path') !== null - || config.get('platform.drive.abci.docker.build.path') !== null - ), + enabled: (ctx) => !ctx.skipBuildServices + && config.has('platform.sourcePath') + && config.get('platform.sourcePath') !== null, task: () => buildServicesTask(config), }, { diff --git a/scripts/configure_dashmate.sh b/scripts/configure_dashmate.sh index c3583436cb3..675f0289489 100755 --- a/scripts/configure_dashmate.sh +++ b/scripts/configure_dashmate.sh @@ -4,16 +4,16 @@ set -e CONFIG_NAME="local" -full_path=$(realpath "$0") -dir_path=$(dirname "$full_path") -root_path=$(dirname "$dir_path") -packages_path="$root_path/packages" +FULL_PATH=$(realpath "$0") +DIR_PATH=$(dirname "$FULL_PATH") +ROOT_PATH=$(dirname "$DIR_PATH") +PACKAGES_PATH="$ROOT_PATH/packages" -DAPI_REPO_PATH="${packages_path}/dapi" -DRIVE_REPO_PATH="${packages_path}/js-drive" +DAPI_REPO_PATH="${PACKAGES_PATH}/dapi" +DRIVE_REPO_PATH="${PACKAGES_PATH}/js-drive" -yarn dashmate config:set --config=${CONFIG_NAME} platform.dapi.api.docker.build.path "$DAPI_REPO_PATH" -yarn dashmate config:set --config=${CONFIG_NAME} platform.drive.abci.docker.build.path "$DRIVE_REPO_PATH" +# build Drive and DAPI from sources +yarn dashmate config:set --config=${CONFIG_NAME} platform.sourcePath "$ROOT_PATH" # create tenderdash blocks every 10s to speed up test suite yarn dashmate config:set --config=${CONFIG_NAME} platform.drive.tenderdash.consensus.createEmptyBlocksInterval "10s"