Merge pull request #24 from Permissionless-Software-Foundation/ct-unstable

fix(production): Updating Docker container
This commit is contained in:
Chris Troutner
2021-08-26 10:29:01 -07:00
committed by GitHub
12 changed files with 147 additions and 61 deletions
+10 -1
View File
@@ -39,11 +39,17 @@ class Server {
// Connect to the Mongo Database.
mongoose.Promise = global.Promise
mongoose.set('useCreateIndex', true) // Stop deprecation warning.
console.log(
`Connecting to MongoDB with this connection string: ${config.database}`
)
await mongoose.connect(config.database, {
useUnifiedTopology: true,
useNewUrlParser: true
})
console.log(`Starting environment: ${config.env}`)
console.log(`Debug level: ${config.debugLevel}`)
// MIDDLEWARE START
app.use(convert(logger()))
@@ -65,7 +71,7 @@ class Server {
// Attach REST API and JSON RPC controllers to the app.
const Controllers = require('../src/controllers')
const controllers = new Controllers()
await controllers.attachControllers(app)
await controllers.attachRESTControllers(app)
app.controllers = controllers
@@ -85,6 +91,9 @@ class Server {
const success = await this.adminLib.createSystemUser()
if (success) console.log('System admin user created.')
// Attach the other IPFS controllers
await controllers.attachControllers(app)
return app
} catch (err) {
console.error('Could not start server. Error: ', err)
+6 -1
View File
@@ -71,5 +71,10 @@ module.exports = {
// IPFS Ports
ipfsTcpPort: process.env.IPFS_TCP_PORT ? process.env.IPFS_TCP_PORT : 4001,
ipfsWsPort: process.env.IPFS_WS_PORT ? process.env.IPFS_WS_PORT : 4003
ipfsWsPort: process.env.IPFS_WS_PORT ? process.env.IPFS_WS_PORT : 4003,
// BCH Mnemonic for generating encryption keys and payment address
mnemonic: process.env.MNEMONIC ? process.env.MNEMONIC : '',
debugLevel: process.env.DEBUG_LEVEL ? parseInt(process.env.DEBUG_LEVEL) : 2
}
+4 -1
View File
@@ -10,6 +10,9 @@
module.exports = {
session: 'secret-boilerplate-token',
token: 'secret-jwt-token',
database: 'mongodb://172.17.0.1:5555/ipfs-service-prod',
// database: 'mongodb://172.17.0.1:5555/ipfs-service-prod',
database: process.env.DBURL
? process.env.DBURL
: 'mongodb://172.17.0.1:5555/ipfs-service-prod',
env: 'prod'
}
-25
View File
@@ -1,25 +0,0 @@
# Start the testnet server with the command 'docker-compose up -d'
koa-mongodb:
image: mongo
container_name: mongo-koa
ports:
- "5555:27017" # <host port>:<container port>
volumes:
- ./database:/data/db
command: mongod --smallfiles --logpath=/dev/null # -- quiet
restart: always
koa:
build: ./production/
dockerfile: Dockerfile
container_name: koa
links:
- koa-mongodb
ports:
- "5001:5001" # <host port>:<container port>
volumes:
# - ./logs:/home/coinjoin/consolidating-coinjoin/logs
- ./keys:/home/safeuser/keys
restart: always
+57 -24
View File
@@ -13,7 +13,7 @@
"bcryptjs": "^2.4.3",
"glob": "^7.1.6",
"ipfs": "0.55.4",
"ipfs-coord": "^6.1.4",
"ipfs-coord": "^6.1.8",
"jsonrpc-lite": "^2.2.0",
"jsonwebtoken": "^8.5.1",
"jwt-bch-lib": "^1.3.0",
@@ -10028,9 +10028,9 @@
}
},
"node_modules/ipfs-coord": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.1.4.tgz",
"integrity": "sha512-uWSNJIp5JapAlLLaLczcsfZw8UO4jMu+ObA97u0otlU6eA5x2SLJj1nKnl5u1+hpRfBSiMqWGOLNifjThjdTIA==",
"version": "6.1.8",
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.1.8.tgz",
"integrity": "sha512-vzRbtBw+4X3r+mgJtcHkVb7tQek1SaeVOGOEX+xUgyCMrUKetD9BcIaCy7OvdUppqiZnJQHBMv6oQgSdcxJNLw==",
"dependencies": {
"bch-encrypt-lib": "^2.0.0",
"orbit-db": "^0.26.1"
@@ -10701,14 +10701,22 @@
}
},
"node_modules/ipfs-log/node_modules/ipld-dag-cbor/node_modules/multicodec": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/multicodec/-/multicodec-3.1.0.tgz",
"integrity": "sha512-f6d4DhbQ9a8WiJ/wpbKgeJSeR0/juP/1wnjbKdZ0KAWDkC/z7Lb3xOegMUG+uTcfwSYf6j1eTvFf8HDgqPRGmQ==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/multicodec/-/multicodec-3.1.1.tgz",
"integrity": "sha512-q29htEIgHglgxEcD0SvTmf1er68nfhm87rMKPqpClequHOTJknDCX5xA8QHBwBstgj+niO2KrsJeFzpsMZj2DQ==",
"dependencies": {
"uint8arrays": "^2.1.5",
"uint8arrays": "^3.0.0",
"varint": "^6.0.0"
}
},
"node_modules/ipfs-log/node_modules/ipld-dag-cbor/node_modules/multicodec/node_modules/uint8arrays": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.0.0.tgz",
"integrity": "sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==",
"dependencies": {
"multiformats": "^9.4.2"
}
},
"node_modules/ipfs-log/node_modules/ipld-dag-pb": {
"version": "0.20.0",
"resolved": "https://registry.npmjs.org/ipld-dag-pb/-/ipld-dag-pb-0.20.0.tgz",
@@ -21888,17 +21896,24 @@
"integrity": "sha512-LPzSaBYp/TcbuSlpGwqT5jR9kvJ3Zp5ic2N5c2ybx6XB/lSfEHq2D7ja8AgoxHoMD91wXFALJoXsvshKPuXyew=="
},
"node_modules/protons": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/protons/-/protons-2.0.2.tgz",
"integrity": "sha512-EIPoT9ftVirJ9QJ3oFoueYUiBhmPqE1AoSBPypLSqbbvHvx+OcUeK9z84YIsk6jda+N3FL58dU1LcWmfGCZGHA==",
"deprecated": "This module is no longer maintained",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/protons/-/protons-2.0.3.tgz",
"integrity": "sha512-j6JikP/H7gNybNinZhAHMN07Vjr1i4lVupg598l4I9gSTjJqOvKnwjzYX2PzvBTSVf2eZ2nWv4vG+mtW8L6tpA==",
"dependencies": {
"protocol-buffers-schema": "^3.3.1",
"signed-varint": "^2.0.1",
"uint8arrays": "^2.1.3",
"uint8arrays": "^3.0.0",
"varint": "^5.0.0"
}
},
"node_modules/protons/node_modules/uint8arrays": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.0.0.tgz",
"integrity": "sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==",
"dependencies": {
"multiformats": "^9.4.2"
}
},
"node_modules/protons/node_modules/varint": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz",
@@ -34345,9 +34360,9 @@
}
},
"ipfs-coord": {
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.1.4.tgz",
"integrity": "sha512-uWSNJIp5JapAlLLaLczcsfZw8UO4jMu+ObA97u0otlU6eA5x2SLJj1nKnl5u1+hpRfBSiMqWGOLNifjThjdTIA==",
"version": "6.1.8",
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-6.1.8.tgz",
"integrity": "sha512-vzRbtBw+4X3r+mgJtcHkVb7tQek1SaeVOGOEX+xUgyCMrUKetD9BcIaCy7OvdUppqiZnJQHBMv6oQgSdcxJNLw==",
"requires": {
"bch-encrypt-lib": "^2.0.0",
"orbit-db": "^0.26.1"
@@ -34922,12 +34937,22 @@
},
"dependencies": {
"multicodec": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/multicodec/-/multicodec-3.1.0.tgz",
"integrity": "sha512-f6d4DhbQ9a8WiJ/wpbKgeJSeR0/juP/1wnjbKdZ0KAWDkC/z7Lb3xOegMUG+uTcfwSYf6j1eTvFf8HDgqPRGmQ==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/multicodec/-/multicodec-3.1.1.tgz",
"integrity": "sha512-q29htEIgHglgxEcD0SvTmf1er68nfhm87rMKPqpClequHOTJknDCX5xA8QHBwBstgj+niO2KrsJeFzpsMZj2DQ==",
"requires": {
"uint8arrays": "^2.1.5",
"uint8arrays": "^3.0.0",
"varint": "^6.0.0"
},
"dependencies": {
"uint8arrays": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.0.0.tgz",
"integrity": "sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==",
"requires": {
"multiformats": "^9.4.2"
}
}
}
}
}
@@ -43471,16 +43496,24 @@
"integrity": "sha512-LPzSaBYp/TcbuSlpGwqT5jR9kvJ3Zp5ic2N5c2ybx6XB/lSfEHq2D7ja8AgoxHoMD91wXFALJoXsvshKPuXyew=="
},
"protons": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/protons/-/protons-2.0.2.tgz",
"integrity": "sha512-EIPoT9ftVirJ9QJ3oFoueYUiBhmPqE1AoSBPypLSqbbvHvx+OcUeK9z84YIsk6jda+N3FL58dU1LcWmfGCZGHA==",
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/protons/-/protons-2.0.3.tgz",
"integrity": "sha512-j6JikP/H7gNybNinZhAHMN07Vjr1i4lVupg598l4I9gSTjJqOvKnwjzYX2PzvBTSVf2eZ2nWv4vG+mtW8L6tpA==",
"requires": {
"protocol-buffers-schema": "^3.3.1",
"signed-varint": "^2.0.1",
"uint8arrays": "^2.1.3",
"uint8arrays": "^3.0.0",
"varint": "^5.0.0"
},
"dependencies": {
"uint8arrays": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.0.0.tgz",
"integrity": "sha512-HRCx0q6O9Bfbp+HHSfQQKD7wU70+lydKVt4EghkdOvlK/NlrF90z+eXV34mUd48rNvVJXwkrMSPpCATkct8fJA==",
"requires": {
"multiformats": "^9.4.2"
}
},
"varint": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/varint/-/varint-5.0.2.tgz",
+1 -1
View File
@@ -28,7 +28,7 @@
"bcryptjs": "^2.4.3",
"glob": "^7.1.6",
"ipfs": "0.55.4",
"ipfs-coord": "^6.1.4",
"ipfs-coord": "^6.1.8",
"jsonrpc-lite": "^2.2.0",
"jsonwebtoken": "^8.5.1",
"jwt-bch-lib": "^1.3.0",
+5 -5
View File
@@ -29,18 +29,18 @@ RUN echo 'abcd8765' | sudo -S pwd
# Clone the rest.bitcoin.com repository
WORKDIR /home/safeuser
RUN git clone https://github.com/christroutner/koa-api-boilerplate
RUN mv koa-api-boilerplate koa
RUN mkdir keys
RUN git clone https://github.com/Permissionless-Software-Foundation/ipfs-service-provider
# Switch to the desired branch. `master` is usually stable,
# and `stage` has the most up-to-date changes.
WORKDIR /home/safeuser/koa
WORKDIR /home/safeuser/ipfs-service-provider
# For development: switch to unstable branch
# RUN git checkout unstable
RUN git checkout ct-unstable
# Install dependencies
RUN mkdir .ipfsdata
RUN npm install -g @mapbox/node-pre-gyp
RUN npm install
# Generate the API docs
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
# Remove all untagged docker images.
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
+26
View File
@@ -0,0 +1,26 @@
# Start the testnet server with the command 'docker-compose up -d'
mongo-ipfs-service:
image: mongo
container_name: mongo-ipfs-service
ports:
- '5555:27017' # <host port>:<container port>
volumes:
- ./database:/data/db
command: mongod --logpath=/dev/null # -- quiet
restart: always
ipfs-service:
build: .
dockerfile: Dockerfile
container_name: ipfs-service
links:
- mongo-ipfs-service
ports:
- '5001:5001' # <host port>:<container port>
volumes:
# - ./logs:/home/coinjoin/consolidating-coinjoin/logs
#- ./keys:/home/safeuser/keys
- ../.ipfsdata:/home/safeuser/ipfs-service-provider/.ipfsdata
restart: always
+30 -1
View File
@@ -1,3 +1,32 @@
#!/bin/bash
export KOA_ENV=production
# BEGIN: Optional configuration settings
# This mnemonic is used to set up persistent public key for e2ee
# Replace this with your own 12-word mnemonic.
export MNEMONIC="olive two muscle bottom coral ancient wait legend bronze useful process session"
# The human readable name this IPFS node identifies as.
export COORD_NAME=ipfs-service-provider-generic
# Allow this node to function as a circuit relay. It must not be behind a firewall.
#export ENABLE_CIRCUIT_RELAY=true
# Debug level. 0 = minimal info. 2 = max info.
export DEBUG_LEVEL=2
# END: Optional configuration settings
# Production database connection string.
export DBURL=mongodb://172.17.0.1:5555/ipfs-service-prod
# Configure IPFS ports
export IPFS_TCP_PORT=4001
export IPFS_WS_PORT=4003
# Configure REST API port
export PORT=5001
export SVC_ENV=production
npm start
+2 -1
View File
@@ -46,7 +46,8 @@ class IpfsCoordAdapter {
privateLog: console.log, // Default to console.log
isCircuitRelay: this.config.isCircuitRelay,
apiInfo: this.config.apiInfo,
announceJsonLd: this.config.announceJsonLd
announceJsonLd: this.config.announceJsonLd,
debugLevel: this.config.debugLevel
})
// Wait for the ipfs-coord library to signal that it is ready.
+1 -1
View File
@@ -30,7 +30,7 @@ class Controllers {
await this.adapters.start()
// Attach the REST controllers to the Koa app.
this.attachRESTControllers(app)
// this.attachRESTControllers(app)
this.attachRPCControllers()
}