Skip to content

Commit b5bd848

Browse files
authored
Merge pull request #31 from BitGo/dockerized
[BG-7752] Dockerized
2 parents e43314b + 4f52807 commit b5bd848

File tree

10 files changed

+62
-27
lines changed

10 files changed

+62
-27
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
LICENSE
2+
README.md
3+
test/*
4+
.arcconfig
5+
.dockerignore
6+
.idea
7+
.git
8+
.gitignore
9+
node_modules

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
KRSV2_DBURL=mongodb://localhost:27017/mytestdb
2+

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node
2+
3+
WORKDIR /usr/src/app
4+
5+
COPY package*.json ./
6+
7+
RUN npm install
8+
9+
COPY . .
10+
11+
EXPOSE 6833
12+
13+
CMD [ "npm", "start" ]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ The key server is BitGo's interface to the KRS service. It is responsible for st
3939

4040
Replace `[email protected]` with your email in the above example to receive an email with your backup key.
4141

42+
**To Run Server as a Docker Container**
43+
44+
1. From the KRS main repository, run `docker build -t my-image-name .` (note the period at the end)
45+
2. Run `docker run -p 6833:6833 my-image-name`
46+
3. The service should now be running - see step (7) above to test
47+
4248
Offline Environment Setup
4349
====================
4450
An offline environment is required for generating master keys, deriving hardened customer keys, and signing recovery transactions.

app/admin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ const saveKeys = co(function *(keys, type) {
216216
type: type,
217217
pub: key.pub,
218218
path: key.path,
219-
keyid: key.keyid,
220219
keyCount: 0
221220
}));
222221

app/krs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const provisionMasterKey = co(function *(coin, customerId) {
6868

6969
const availableKeys = yield MasterKey.countDocuments({ coin: null, customerId: null, type: keyType });
7070

71-
if (_.includes(process.config.lowKeyWarningLevels, availableKeys)) {
71+
if (_.includes(process.config.lowKeyWarningLevels, availableKeys) && !process.config.disableAllKRSEmail) {
7272
yield sendDatabaseLowWarning(availableKeys, keyType);
7373
}
7474

@@ -159,7 +159,7 @@ exports.provisionKey = co(function *(req) {
159159

160160
yield masterKey.update({ $inc: { keyCount: 1 } });
161161

162-
if (!req.body.disableKRSEmail) {
162+
if (!req.body.disableKRSEmail && !process.config.disableAllKRSEmail) {
163163
try {
164164
yield utils.sendMailQ(
165165
key.userEmail,

app/models/masterkey.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const masterKeySchema = new mongoose.Schema({
77
customerId: { type: String },
88
pub: { type: String },
99
path: { type: String },
10-
keyid: {type: String},
1110
keyCount: { type: Number }
1211
});
1312

config.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
"name": "Friendly Key Backup Service",
3-
"serviceurl": "http://keyrecoveryservice.yourdomain.com/",
2+
"name": "Friendly Key Recovery Service",
3+
"serviceurl": "yourdomain.com",
44
"supportedcoins": {
55
btc: 'xpub',
66
tbtc: 'xpub',
@@ -19,14 +19,14 @@ module.exports = {
1919
},
2020
"host": "0.0.0.0",
2121
"port": 6833,
22-
"adminemail": "davidcruz@bitgo.com",
23-
"mongouri": "mongodb://localhost:27017/key-recovery-service",
22+
"adminemail": "danny@bitgo.com",
23+
"mongouri": process.env.KRSV2_DBURL,
2424
"provider": {
2525
"id": "bitgo",
2626
"secret": "youshouldchangethis"
2727
},
2828
"mail": {
29-
"fromemail": "KRS.XYZ <krs@example.com>",
29+
"fromemail": "Friendly Key Recovery Service <no-reply@yourdomain.com>",
3030
"host": "smtp.mailgun.org",
3131
"port": 587,
3232
"auth": {
@@ -41,5 +41,6 @@ module.exports = {
4141
}
4242
},
4343
"neverReuseMasterKey": true,
44+
"disableAllKRSEmail": true,
4445
"lowKeyWarningLevels": [10000, 5000, 1000, 500, 100, 0]
4546
};

package-lock.json

Lines changed: 22 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "./node_modules/mocha/bin/_mocha --timeout 20000 --recursive test/",
8-
"start": "node bin/server.js"
8+
"start": "node -r dotenv/config bin/server.js"
99
},
1010
"license": "MIT",
1111
"devDependencies": {
@@ -19,6 +19,7 @@
1919
"bignumber.js": "^7.2.1",
2020
"bitgo-utxo-lib": "^1.1.2",
2121
"body-parser": "^1.18.3",
22+
"dotenv": "^6.1.0",
2223
"ethereumjs-tx": "^1.3.7",
2324
"express": "^4.16.3",
2425
"jsrender": "^0.9.90",

0 commit comments

Comments
 (0)