diff --git a/.pnp.cjs b/.pnp.cjs index b1d8b99428d..127b2eb8ad1 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -2504,6 +2504,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "SOFT", }] ]], + ["@dashevo/docker-compose", [ + ["npm:0.24.1", { + "packageLocation": "./.yarn/cache/@dashevo-docker-compose-npm-0.24.1-e4dc7f3c5e-7792e09b5d.zip/node_modules/@dashevo/docker-compose/", + "packageDependencies": [ + ["@dashevo/docker-compose", "npm:0.24.1"], + ["yaml", "npm:1.10.2"] + ], + "linkType": "HARD", + }] + ]], ["@dashevo/dp-services-ctl", [ ["https://github.com/dashevo/js-dp-services-ctl.git#commit=3976076b0018c5b4632ceda4c752fc597f27a640", { "packageLocation": "./.yarn/cache/@dashevo-dp-services-ctl-https-a393167701-0325823966.zip/node_modules/@dashevo/dp-services-ctl/", @@ -7680,6 +7690,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@dashevo/dashcore-lib", "npm:0.19.39"], ["@dashevo/dashd-rpc", "npm:2.3.2"], ["@dashevo/dashpay-contract", "workspace:packages/dashpay-contract"], + ["@dashevo/docker-compose", "npm:0.24.1"], ["@dashevo/dpns-contract", "workspace:packages/dpns-contract"], ["@dashevo/dpp", "workspace:packages/js-dpp"], ["@dashevo/feature-flags-contract", "workspace:packages/feature-flags-contract"], @@ -7693,7 +7704,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["bls-signatures", "npm:0.2.5"], ["chalk", "npm:4.1.2"], ["dash", "workspace:packages/js-dash-sdk"], - ["docker-compose", "npm:0.23.3"], ["dockerode", "npm:3.3.1"], ["dot", "npm:1.1.3"], ["dotenv", "npm:8.6.0"], @@ -8251,15 +8261,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], - ["docker-compose", [ - ["npm:0.23.3", { - "packageLocation": "./.yarn/cache/docker-compose-npm-0.23.3-00a13d5b3c-3d2bd5e4cb.zip/node_modules/docker-compose/", - "packageDependencies": [ - ["docker-compose", "npm:0.23.3"] - ], - "linkType": "HARD", - }] - ]], ["docker-modem", [ ["npm:3.0.3", { "packageLocation": "./.yarn/cache/docker-modem-npm-3.0.3-5736be136e-4ad495d17a.zip/node_modules/docker-modem/", @@ -19292,6 +19293,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], + ["yaml", [ + ["npm:1.10.2", { + "packageLocation": "./.yarn/cache/yaml-npm-1.10.2-0e780aebdf-ce4ada136e.zip/node_modules/yaml/", + "packageDependencies": [ + ["yaml", "npm:1.10.2"] + ], + "linkType": "HARD", + }] + ]], ["yamljs", [ ["npm:0.3.0", { "packageLocation": "./.yarn/cache/yamljs-npm-0.3.0-b0b262e524-76b770d34c.zip/node_modules/yamljs/", diff --git a/.yarn/cache/@dashevo-docker-compose-npm-0.24.1-e4dc7f3c5e-7792e09b5d.zip b/.yarn/cache/@dashevo-docker-compose-npm-0.24.1-e4dc7f3c5e-7792e09b5d.zip new file mode 100644 index 00000000000..2637e740d02 Binary files /dev/null and b/.yarn/cache/@dashevo-docker-compose-npm-0.24.1-e4dc7f3c5e-7792e09b5d.zip differ diff --git a/.yarn/cache/docker-compose-npm-0.23.3-00a13d5b3c-3d2bd5e4cb.zip b/.yarn/cache/docker-compose-npm-0.23.3-00a13d5b3c-3d2bd5e4cb.zip deleted file mode 100644 index 9db93559b8e..00000000000 Binary files a/.yarn/cache/docker-compose-npm-0.23.3-00a13d5b3c-3d2bd5e4cb.zip and /dev/null differ diff --git a/.yarn/cache/yaml-npm-1.10.2-0e780aebdf-ce4ada136e.zip b/.yarn/cache/yaml-npm-1.10.2-0e780aebdf-ce4ada136e.zip new file mode 100644 index 00000000000..bb28507cd0f Binary files /dev/null and b/.yarn/cache/yaml-npm-1.10.2-0e780aebdf-ce4ada136e.zip differ diff --git a/README.md b/README.md index a167eadcc2d..c866b695796 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,6 @@ this repository may be used on the following networks: - Install prerequisites: - [node.js](https://nodejs.org/) v16.10.0+ - [docker](https://docs.docker.com/get-docker/) v20.10+ - - [docker-compose](https://docs.docker.com/compose/install/) v1.29.2+ - Run `corepack enable` to enable [corepack](https://nodejs.org/dist/latest/docs/api/corepack.html) and install yarn - Run `yarn setup` to install dependencies and configure and build all packages - Run `yarn start` to start the local dev environment built from the sources diff --git a/packages/dashmate/README.md b/packages/dashmate/README.md index 303805c2197..4d5d67717b2 100644 --- a/packages/dashmate/README.md +++ b/packages/dashmate/README.md @@ -30,14 +30,11 @@ Distribution package for Dash Masternode installation ### Dependencies -* [Docker](https://docs.docker.com/engine/installation/) (v18.06.0+) -* [Docker Compose](https://docs.docker.com/compose/install/) (v1.25.0+) +* [Docker](https://docs.docker.com/engine/installation/) (v20.10+) * [Node.js](https://nodejs.org/en/download/) (v16.0+, NPM v8.0+) For Linux installations you may optionally wish to follow the [post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/) to manage Docker as a non-root user, otherwise you will have to run CLI and Docker commands with `sudo`. -**Note that Docker Compose v2 is not yet supported. Docker Desktop will automatically enable Docker Compose v2 under Windows and macOS, please go to "Settings -> General -> Use Docker Compose V2" and disable the checkbox to use Dashmate.** - ### Distribution package Use NPM to install dashmate globally in your system: @@ -379,10 +376,10 @@ If you want to use Docker Compose directly, you will need to pass a configuratio $ dashmate config envs --config=testnet --output-file .env.testnet ``` -Then specify the created dotenv file as an option for the `docker-compose` command: +Then specify the created dotenv file as an option for the `docker compose` command: ```bash -$ docker-compose --env-file=.env.testnet up -d +$ docker compose --env-file=.env.testnet up -d ``` ## Contributing diff --git a/packages/dashmate/package.json b/packages/dashmate/package.json index 8680edd2487..2ae7096363a 100644 --- a/packages/dashmate/package.json +++ b/packages/dashmate/package.json @@ -49,6 +49,7 @@ "@dashevo/dashcore-lib": "~0.19.39", "@dashevo/dashd-rpc": "^2.3.2", "@dashevo/dashpay-contract": "workspace:~", + "@dashevo/docker-compose": "^0.24.1", "@dashevo/dpns-contract": "workspace:~", "@dashevo/dpp": "workspace:~", "@dashevo/feature-flags-contract": "workspace:~", @@ -62,7 +63,6 @@ "bls-signatures": "^0.2.5", "chalk": "^4.1.0", "dash": "workspace:~", - "docker-compose": "0.23.3", "dockerode": "^3.2.0", "dot": "^1.1.3", "dotenv": "^8.6.0", diff --git a/packages/dashmate/src/docker/DockerCompose.js b/packages/dashmate/src/docker/DockerCompose.js index 53a400d33a8..ec6c1c7ccb8 100644 --- a/packages/dashmate/src/docker/DockerCompose.js +++ b/packages/dashmate/src/docker/DockerCompose.js @@ -1,12 +1,11 @@ const path = require('path'); -const dockerCompose = require('docker-compose'); +const dockerCompose = require('@dashevo/docker-compose'); const hasbin = require('hasbin'); const semver = require('semver'); const { exec } = require('child_process'); -const { promisify } = require('util'); const DockerComposeError = require('./errors/DockerComposeError'); const ServiceAlreadyRunningError = require('./errors/ServiceAlreadyRunningError'); @@ -15,8 +14,6 @@ const ContainerIsNotPresentError = require('./errors/ContainerIsNotPresentError' const { HOME_DIR_PATH } = require('../constants'); -const execAsync = promisify(exec); - class DockerCompose { /** * @param {Docker} docker @@ -109,14 +106,10 @@ class DockerCompose { await this.throwErrorIfNotInstalled(); try { - if (process.env.DOCKER_COMPOSE_V2) { - await execAsync( - 'docker compose up --no-build -d', - this.getOptions(envs), - ); - } else { - await dockerCompose.upAll(this.getOptions(envs)); - } + await dockerCompose.upAll({ + ...this.getOptions(envs), + commandOptions: ['--no-build'], + }); } catch (e) { throw new DockerComposeError(e); } @@ -260,6 +253,10 @@ class DockerCompose { commandOptions, })); } catch (e) { + if (e.err && e.err.startsWith('no such service:')) { + return []; + } + throw new DockerComposeError(e); } @@ -377,22 +374,17 @@ class DockerCompose { throw new Error(`Update Docker to version ${DockerCompose.DOCKER_MIN_VERSION} or higher`); } + let version + // Check docker compose - if (process.env.DOCKER_COMPOSE_V2) { - try { - await execAsync('docker compose'); - } catch (e) { - throw new Error('Docker Compose V2 is not installed'); - } - } else { - if (!hasbin.sync('docker-compose')) { - throw new Error('Docker Compose is not installed'); - } + try { + ({out: version} = await dockerCompose.version()); + } catch (e) { + throw new Error('Docker Compose V2 is not available in your system'); + } - const { out: version } = await dockerCompose.version(); - if (semver.lt(version.trim(), DockerCompose.DOCKER_COMPOSE_MIN_VERSION)) { - throw new Error(`Update Docker Compose to version ${DockerCompose.DOCKER_COMPOSE_MIN_VERSION} or higher`); - } + if (semver.lt(version.trim(), DockerCompose.DOCKER_COMPOSE_MIN_VERSION)) { + throw new Error(`Update Docker Compose to version ${DockerCompose.DOCKER_COMPOSE_MIN_VERSION} or higher`); } } @@ -415,7 +407,7 @@ class DockerCompose { } } -DockerCompose.DOCKER_COMPOSE_MIN_VERSION = '1.25.0'; +DockerCompose.DOCKER_COMPOSE_MIN_VERSION = '2.0.0'; DockerCompose.DOCKER_MIN_VERSION = '20.10.0'; module.exports = DockerCompose; diff --git a/yarn.lock b/yarn.lock index afa39bc45ad..cfc4a6194f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1505,6 +1505,15 @@ __metadata: languageName: unknown linkType: soft +"@dashevo/docker-compose@npm:^0.24.1": + version: 0.24.1 + resolution: "@dashevo/docker-compose@npm:0.24.1" + dependencies: + yaml: ^1.10.2 + checksum: 7792e09b5d2d216eb883d0fe2d54e422a4cf277e17af99dd108078ca41aab9b66eccf9eddb2716e752b6cfe183a6c45d2292b42cce881c658afdcb6cd0d5ca3a + languageName: node + linkType: hard + "@dashevo/dp-services-ctl@github:dashevo/js-dp-services-ctl#v0.19-dev": version: 0.19.0-dev.1 resolution: "@dashevo/dp-services-ctl@https://github.com/dashevo/js-dp-services-ctl.git#commit=3976076b0018c5b4632ceda4c752fc597f27a640" @@ -5807,6 +5816,7 @@ __metadata: "@dashevo/dashcore-lib": ~0.19.39 "@dashevo/dashd-rpc": ^2.3.2 "@dashevo/dashpay-contract": "workspace:~" + "@dashevo/docker-compose": ^0.24.1 "@dashevo/dpns-contract": "workspace:~" "@dashevo/dpp": "workspace:~" "@dashevo/feature-flags-contract": "workspace:~" @@ -5820,7 +5830,6 @@ __metadata: bls-signatures: ^0.2.5 chalk: ^4.1.0 dash: "workspace:~" - docker-compose: 0.23.3 dockerode: ^3.2.0 dot: ^1.1.3 dotenv: ^8.6.0 @@ -6230,13 +6239,6 @@ __metadata: languageName: node linkType: hard -"docker-compose@npm:0.23.3": - version: 0.23.3 - resolution: "docker-compose@npm:0.23.3" - checksum: 3d2bd5e4cb1b73ee5f61cfa8447f1bef9040126b43bd63e1109e2c7d5a3e21df11003a49dbb52e7eb3b3f657cda50b47b604b1c58c48233d8166a206e3f89f18 - languageName: node - linkType: hard - "docker-modem@npm:^3.0.0": version: 3.0.3 resolution: "docker-modem@npm:3.0.3" @@ -15557,6 +15559,13 @@ typescript@^3.9.5: languageName: node linkType: hard +"yaml@npm:^1.10.2": + version: 1.10.2 + resolution: "yaml@npm:1.10.2" + checksum: ce4ada136e8a78a0b08dc10b4b900936912d15de59905b2bf415b4d33c63df1d555d23acb2a41b23cf9fb5da41c256441afca3d6509de7247daa062fd2c5ea5f + languageName: node + linkType: hard + "yamljs@npm:^0.3.0": version: 0.3.0 resolution: "yamljs@npm:0.3.0"