From 1a09fcd26f5ff577c408edaca5d6ca890da2d734 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sun, 24 Jul 2022 08:06:32 -0700 Subject: [PATCH 1/5] fix(mocks): Improvement to adapter mocks used in tests --- test/unit/mocks/adapters/index.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/unit/mocks/adapters/index.js b/test/unit/mocks/adapters/index.js index a236014..3165c92 100644 --- a/test/unit/mocks/adapters/index.js +++ b/test/unit/mocks/adapters/index.js @@ -2,12 +2,15 @@ Mocks for the Adapter library. */ -const ipfs = { - ipfsAdapter: { - ipfs: {} - }, - ipfsCoordAdapter: { - ipfsCoord: { +class IpfsAdapter { + constructor () { + this.ipfs = {} + } +} + +class IpfsCoordAdapter { + constructor () { + this.ipfsCoord = { useCases: { peer: { sendPrivateMessage: () => {} @@ -17,6 +20,11 @@ const ipfs = { } } +const ipfs = { + ipfsAdapter: new IpfsAdapter(), + ipfsCoordAdapter: new IpfsCoordAdapter() +} + const localdb = { Users: class Users { static findById () {} From fc8e160874ab5ed56790e1acd0783d66c92be95a Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Sun, 24 Jul 2022 08:14:27 -0700 Subject: [PATCH 2/5] fix(mocks): Another update to IPFS test mocks --- test/unit/mocks/adapters/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/unit/mocks/adapters/index.js b/test/unit/mocks/adapters/index.js index 3165c92..69afa38 100644 --- a/test/unit/mocks/adapters/index.js +++ b/test/unit/mocks/adapters/index.js @@ -4,7 +4,11 @@ class IpfsAdapter { constructor () { - this.ipfs = {} + this.ipfs = { + files: { + stat: () => {} + } + } } } @@ -24,6 +28,7 @@ const ipfs = { ipfsAdapter: new IpfsAdapter(), ipfsCoordAdapter: new IpfsCoordAdapter() } +ipfs.ipfs = ipfs.ipfsAdapter.ipfs const localdb = { Users: class Users { From 689c8fd8d93d52ea70950582aeeab32b650f1f8b Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 25 Jul 2022 17:40:05 -0700 Subject: [PATCH 3/5] fix(ipfs): Using config to set ports --- package-lock.json | 30 +++++++++++++--------------- package.json | 4 ++-- production/docker/docker-compose.yml | 7 ++++--- src/adapters/ipfs/index.js | 6 +++++- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index b32a725..979da13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,12 @@ "version": "2.0.0", "license": "MIT", "dependencies": { - "@psf/bch-js": "6.4.1", + "@psf/bch-js": "6.4.5", "axios": "0.27.2", "bcryptjs": "2.4.3", "glob": "7.1.6", "ipfs": "0.62.3", - "ipfs-coord": "8.0.2", + "ipfs-coord": "8.0.4", "ipfs-http-client": "55.0.0", "jsonrpc-lite": "2.2.0", "jsonwebtoken": "8.5.1", @@ -1487,10 +1487,9 @@ "license": "BSD-3-Clause" }, "node_modules/@psf/bch-js": { - "version": "6.4.1", - "resolved": "http://94.130.170.209:4873/@psf%2fbch-js/-/bch-js-6.4.1.tgz", - "integrity": "sha512-/BLGzWH02VqaDNeY05QGMhrCtYDw5bXn45Egz+L5FLcyZaOqONR4kl80T6a8xvTPcREO4R+AjGTRBpfjdikwpA==", - "license": "MIT", + "version": "6.4.5", + "resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-6.4.5.tgz", + "integrity": "sha512-sH72zbJJI5oe9EUMczFQb0jCaNQb8rc3/86E6xXKl3325HCwBqE80BX7JFvZ97Qv1gGxwp/3WROp59v6Dz2NKA==", "dependencies": { "@chris.troutner/bip32-utils": "1.0.5", "@psf/bip21": "2.0.1", @@ -8440,10 +8439,9 @@ } }, "node_modules/ipfs-coord": { - "version": "8.0.2", - "resolved": "http://94.130.170.209:4873/ipfs-coord/-/ipfs-coord-8.0.2.tgz", - "integrity": "sha512-CdUH4GLLFArUDb8LIRAXxPlhbRQ44A5PEWB4J9zzDB3by93O7DLEgjqPqLDolalzrtiQBVzoARO/exZvdxBF+w==", - "license": "MIT", + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-8.0.4.tgz", + "integrity": "sha512-jwZsrDlEWSHMnAde8PdyUScTzRlTCIvPAziChoczj5ZOZJIUbxLNkGphBI0xDj2G/LzjPrU1Ko/QZrU+oLFUnw==", "dependencies": { "axios": "0.21.4", "bch-encrypt-lib": "2.0.0", @@ -22622,9 +22620,9 @@ "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" }, "@psf/bch-js": { - "version": "6.4.1", - "resolved": "http://94.130.170.209:4873/@psf%2fbch-js/-/bch-js-6.4.1.tgz", - "integrity": "sha512-/BLGzWH02VqaDNeY05QGMhrCtYDw5bXn45Egz+L5FLcyZaOqONR4kl80T6a8xvTPcREO4R+AjGTRBpfjdikwpA==", + "version": "6.4.5", + "resolved": "https://registry.npmjs.org/@psf/bch-js/-/bch-js-6.4.5.tgz", + "integrity": "sha512-sH72zbJJI5oe9EUMczFQb0jCaNQb8rc3/86E6xXKl3325HCwBqE80BX7JFvZ97Qv1gGxwp/3WROp59v6Dz2NKA==", "requires": { "@chris.troutner/bip32-utils": "1.0.5", "@psf/bip21": "2.0.1", @@ -27780,9 +27778,9 @@ } }, "ipfs-coord": { - "version": "8.0.2", - "resolved": "http://94.130.170.209:4873/ipfs-coord/-/ipfs-coord-8.0.2.tgz", - "integrity": "sha512-CdUH4GLLFArUDb8LIRAXxPlhbRQ44A5PEWB4J9zzDB3by93O7DLEgjqPqLDolalzrtiQBVzoARO/exZvdxBF+w==", + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-8.0.4.tgz", + "integrity": "sha512-jwZsrDlEWSHMnAde8PdyUScTzRlTCIvPAziChoczj5ZOZJIUbxLNkGphBI0xDj2G/LzjPrU1Ko/QZrU+oLFUnw==", "requires": { "axios": "0.21.4", "bch-encrypt-lib": "2.0.0", diff --git a/package.json b/package.json index 0d340b2..85a49ee 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,12 @@ }, "repository": "Permissionless-Software-Foundation/ipfs-service-provider", "dependencies": { - "@psf/bch-js": "6.4.1", + "@psf/bch-js": "6.4.5", "axios": "0.27.2", "bcryptjs": "2.4.3", "glob": "7.1.6", "ipfs": "0.62.3", - "ipfs-coord": "8.0.2", + "ipfs-coord": "8.0.4", "ipfs-http-client": "55.0.0", "jsonrpc-lite": "2.2.0", "jsonwebtoken": "8.5.1", diff --git a/production/docker/docker-compose.yml b/production/docker/docker-compose.yml index fdada55..22310fe 100644 --- a/production/docker/docker-compose.yml +++ b/production/docker/docker-compose.yml @@ -4,7 +4,7 @@ version: '3.9' services: mongo-ipfs-service: - image: mongo + image: mongo:4.2.0 container_name: mongo-ipfs-service ports: - '5555:27017' # : @@ -14,7 +14,7 @@ services: restart: always ipfs: - image: ipfs/go-ipfs:v0.12.0 + image: ipfs/go-ipfs:v0.14.0 container_name: ipfs environment: MY_ENV_VAR: 'placeholder' @@ -26,11 +26,12 @@ services: mem_limit: 2000mb ports: - 4001:4001 + - 4003:4003 - 172.17.0.1:5001:5001 - 172.17.0.1:8080:8080 volumes: - ../data/go-ipfs/data:/data/ipfs - - ../../swarm.key:/data/ipfs/swarm.key + # - ../../swarm.key:/data/ipfs/swarm.key # https://docs.docker.com/compose/compose-file/compose-file-v3/#command # https://github.com/ipfs/go-ipfs/blob/91c52657166bcf86f2476926e4fe56694dc26562/Dockerfile#L115 command: diff --git a/src/adapters/ipfs/index.js b/src/adapters/ipfs/index.js index 13050d1..f150c3f 100644 --- a/src/adapters/ipfs/index.js +++ b/src/adapters/ipfs/index.js @@ -5,6 +5,7 @@ // Local libraries const IpfsAdapter = require('./ipfs') const IpfsCoordAdapter = require('./ipfs-coord') +const config = require('../../../config') class IPFS { constructor (localConfig = {}) { @@ -12,6 +13,7 @@ class IPFS { this.ipfsAdapter = new IpfsAdapter() this.IpfsCoordAdapter = IpfsCoordAdapter this.process = process + this.config = config this.ipfsCoordAdapter = {} // placeholder @@ -32,7 +34,9 @@ class IPFS { // Start ipfs-coord this.ipfsCoordAdapter = new this.IpfsCoordAdapter({ - ipfs: this.ipfs + ipfs: this.ipfs, + tcpPort: this.config.ipfsTcpPort, + wsPort: this.config.ipfsWsPort }) await this.ipfsCoordAdapter.start() console.log('ipfs-coord is ready.') From 2edd924c57dd17339c0fb4d2e5cf9646b05508dc Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 25 Jul 2022 17:56:02 -0700 Subject: [PATCH 4/5] fix(production): Adding 4003 websocket port --- production/docker/Dockerfile | 2 +- production/docker/docker-compose.yml | 5 +++-- production/docker/start-production.sh | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/production/docker/Dockerfile b/production/docker/Dockerfile index 3950749..7766679 100644 --- a/production/docker/Dockerfile +++ b/production/docker/Dockerfile @@ -69,7 +69,7 @@ VOLUME /home/safeuser/keys EXPOSE 5010 # Start the application. -COPY start-production.sh start-production.sh +#COPY start-production.sh start-production.sh CMD ["./start-production.sh"] #CMD ["npm", "start"] diff --git a/production/docker/docker-compose.yml b/production/docker/docker-compose.yml index 22310fe..07cf92c 100644 --- a/production/docker/docker-compose.yml +++ b/production/docker/docker-compose.yml @@ -44,8 +44,8 @@ services: restart: always ipfs-service: - #build: . - image: christroutner/ipfs-service-provider:v2.2.1 + build: . + #image: christroutner/ipfs-service-provider:v2.2.1 container_name: ipfs-service logging: driver: 'json-file' @@ -60,4 +60,5 @@ services: - '5010:5010' # : volumes: - ../data/ipfsdata:/home/safeuser/ipfs-service-provider/.ipfsdata + - ./start-production.sh:/home/safeuser/ipfs-service-provider/start-production.sh restart: always diff --git a/production/docker/start-production.sh b/production/docker/start-production.sh index 2e8bde6..4303889 100755 --- a/production/docker/start-production.sh +++ b/production/docker/start-production.sh @@ -33,6 +33,6 @@ export SVC_ENV=production export IPFS_HOST=172.17.0.1 export IPFS_API_PORT=5001 export IPFS_TCP_PORT=4001 -#export IPFS_WS_PORT=5269 +export IPFS_WS_PORT=4003 npm start From c71fda38ffe6c493cbcf0d58e9f29c8bba2f6483 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 25 Jul 2022 19:14:44 -0700 Subject: [PATCH 5/5] fix(production): Switching to Docker Image --- production/docker/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/production/docker/docker-compose.yml b/production/docker/docker-compose.yml index 07cf92c..6ad1188 100644 --- a/production/docker/docker-compose.yml +++ b/production/docker/docker-compose.yml @@ -44,8 +44,8 @@ services: restart: always ipfs-service: - build: . - #image: christroutner/ipfs-service-provider:v2.2.1 + #build: . + image: christroutner/ipfs-service-provider:v2.2.12 container_name: ipfs-service logging: driver: 'json-file'