Skip to content

Commit 357555a

Browse files
committed
use couchdb host to reach the couch when running in docker
1 parent 23a5d85 commit 357555a

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ RUN ls -alt; \
1010
ls config/local.js || echo " config/local.js is required to be able to run the tests against deployed couchdb"
1111

1212
ENV DEBUG="*,-express*"
13-
ENV NODE_ENV=beta
14-
ENV NODE_OPTIONS="--dns-result-order=ipv4first"
13+
ENV NODE_ENV=localhost
1514

1615
EXPOSE 3183
1716

etc/local.ini

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
[httpd]
22
enable_cors = true
3-
bind_address = 0.0.0.0
4-
5-
[chttpd]
6-
bind_address = ::
73

84
[cors]
95
origins = *
@@ -14,6 +10,7 @@ attachments_enable = true
1410
; https://docs.couchdb.org/en/stable/cve/2021-38295.html
1511
; use nginx instead to allow only signed couchapps when on deployed server
1612
attachments_header_value = "child-src 'self' data: blob:; default-src 'self'; connect-src 'self' https://corpusdev.example.com https://localhost:3183 https://www.google-analytics.com; img-src 'self' data: https://secure.gravatar.com; font-src 'self' https://themes.googleusercontent.com; script-src 'self' 'unsafe-eval' https://www.google-analytics.com; style-src 'self' 'unsafe-inline';"
13+
1714
[couchdb]
1815
single_node=true
1916

lib/corpus.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { couchKeys } = require('config');
1+
const { couchKeys, usersDbConnection } = require('config');
22
const debug = require('debug')('lib:corpus');
33
const url = require('url');
44
const { Corpus } = require('fielddb/api/corpus/Corpus');
@@ -16,7 +16,7 @@ const contributor = 'writer';
1616
const admin = 'admin';
1717

1818
// Only create users on the same server.
19-
const parsed = url.parse('http://localhost:5984');
19+
const parsed = url.parse(usersDbConnection.url);
2020
const couchConnectUrl = `${parsed.protocol}//${couchKeys.username}:${couchKeys.password}@${parsed.host}`;
2121
debug('Using corpus url: ', couchConnectUrl);
2222

@@ -377,6 +377,7 @@ function createNewCorpus({
377377
// }
378378
// });
379379
return newDatabase.bulk({
380+
// TODO this might be using the connction rather than the config's connection about where to write the docs
380381
docs: docsNeededForAProperFieldDBCorpus,
381382
});
382383
})
@@ -421,7 +422,7 @@ function createNewCorpus({
421422
const err = {
422423
...errOriginal,
423424
};
424-
debug('createNewCorpus', err);
425+
console.log('createNewCorpus', err);
425426
// Clean the error of couchdb leaks
426427
delete err.request;
427428
delete err.headers;

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@
6262
},
6363
"scripts": {
6464
"docker:build": "docker build -t fielddb-auth .",
65-
"test:integration": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && URL=https://localhost:3183 npm run test:deprecated",
66-
"docker:test:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/local.js && docker compose build --no-cache && docker compose up -d && sleep 15 && docker compose logs && npm run setup && URL=https://localhost:3183 npm run test:deprecated",
65+
"test:integration": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/local.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && npm run test:deprecated",
66+
"docker:test:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://couchdb:5984\" } };' > config/local.js && docker compose build --no-cache && docker compose up -d && sleep 15 && docker compose logs && npm run setup && npm run test:deprecated",
6767
"coverage": "NODE_ENV=test BUNYAN_LOG_LEVEL=FATAL nyc npm test",
6868
"lint": "eslint ",
6969
"lint:ci": "eslint .",
7070
"setup": "REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} mocha --timeout 20000 test/integration/install.js",
7171
"start": "node ./bin/www.js",
7272
"test": "SOURCE_URL=${SOURCE_URL:-https://public:none@corpusdev.example.org} NODE_ENV=test NODE_TLS_REJECT_UNAUTHORIZED=0 mocha --timeout 100000 --recursive test",
7373
"test:debug": "node-debug _mocha test/integration/oauth.js",
74-
"test:deprecated": "DEBUG=${DEBUG:-lib:user} REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 nyc mocha --timeout 25000 test/routes/deprecated-spec.js",
74+
"test:deprecated": "DEBUG=${DEBUG:-lib:user} REPLAY=bloody NODE_TLS_REJECT_UNAUTHORIZED=0 URL=https://localhost:3183 nyc mocha --timeout 25000 test/routes/deprecated-spec.js",
7575
"test:fielddb": "NODE_ENV=localhost jasmine-node node_modules/fielddb/tests",
7676
"test:production": "ls config/production.js",
7777
"watch": "nodemon ./bin/www.js"

0 commit comments

Comments
 (0)