@dooer/dooer-test-env 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/command/service.js +19 -2
- package/package.json +1 -1
package/lib/command/service.js
CHANGED
|
@@ -5,6 +5,7 @@ const yaml = require('js-yaml')
|
|
|
5
5
|
const chalk = require('chalk')
|
|
6
6
|
const rt = require('../runtime')
|
|
7
7
|
const discovery = require('../discovery/client')
|
|
8
|
+
const bankid = require('../bankid')
|
|
8
9
|
const { imageFor } = require('../compose/manifests')
|
|
9
10
|
|
|
10
11
|
// Per-service control in a running env. `local`/`unlocal`/`deploy` update the discovery router so peers
|
|
@@ -21,8 +22,17 @@ function localEnv(name, port) {
|
|
|
21
22
|
} catch (_) {
|
|
22
23
|
/* compose not generated yet — fall back to the minimum below */
|
|
23
24
|
}
|
|
25
|
+
// Compose interpolates `${VAR:-default}` when it starts a container; a HOST process would otherwise get
|
|
26
|
+
// the literal string (service-accounts died with `Malformed boolean: "${DOOER_BANK_ID_IS_PRODUCTION:-false}"`).
|
|
27
|
+
// Resolve them the same way compose does, against the host env + the injected bankid values.
|
|
28
|
+
const injected = bankid.loadEnv()
|
|
29
|
+
const interpolate = (v) =>
|
|
30
|
+
String(v).replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g, (_m, key, fallback) => {
|
|
31
|
+
const val = injected[key] !== undefined ? injected[key] : process.env[key]
|
|
32
|
+
return val !== undefined && val !== '' ? val : fallback || ''
|
|
33
|
+
})
|
|
24
34
|
const rw = (v) =>
|
|
25
|
-
|
|
35
|
+
interpolate(v)
|
|
26
36
|
.replace(/\bpostgres:/g, 'localhost:')
|
|
27
37
|
.replace(/(^|@)postgres\b/g, `$1localhost`)
|
|
28
38
|
.replace(/\bredis:/g, 'localhost:')
|
|
@@ -32,7 +42,9 @@ function localEnv(name, port) {
|
|
|
32
42
|
for (const k of Object.keys(env)) env[k] = rw(env[k])
|
|
33
43
|
// guaranteed minimum wiring (also covers the no-compose fallback)
|
|
34
44
|
env.DOOER_SQL_HOST = 'localhost'
|
|
35
|
-
|
|
45
|
+
// Postgres is published on 55432, NOT 5432 — the compose value (5432) is the in-container port, and a
|
|
46
|
+
// dev's brew Postgres usually squats 5432, so a host process would silently talk to the wrong database.
|
|
47
|
+
env.DOOER_SQL_PORT = process.env.DOOER_TEST_ENV_PG_PORT || '55432'
|
|
36
48
|
env.DOOER_SQL_DATABASE = env.DOOER_SQL_DATABASE || 'dooer'
|
|
37
49
|
env.DOOER_IS_ONEPLATFORMER = 'false'
|
|
38
50
|
env.CONSUL_HTTP_ADDR = 'localhost:8500'
|
|
@@ -40,6 +52,11 @@ function localEnv(name, port) {
|
|
|
40
52
|
env.DOOER_SERVICE_NAME = env.DOOER_SERVICE_NAME || name
|
|
41
53
|
env.DOOER_ENVIRONMENT_NAME = env.DOOER_ENVIRONMENT_NAME || 'local'
|
|
42
54
|
env.NODE_ENV = env.NODE_ENV || 'development'
|
|
55
|
+
// SELF-calls: the router advertises this service as host.docker.internal:<port> so CONTAINERS can reach
|
|
56
|
+
// the host process — but that name does not resolve ON the host, so the process fails calling itself
|
|
57
|
+
// (service-accounts → /api/v1/token-invalidation/all → ENOTFOUND, which broke every HQ navigation query).
|
|
58
|
+
// @dooer/service checks DOOER_HOST_<NAME> before Consul, so point the service at its own localhost port.
|
|
59
|
+
env[`DOOER_HOST_${name.toUpperCase().replace(/-/g, '_')}`] = `localhost:${port}`
|
|
43
60
|
return env
|
|
44
61
|
}
|
|
45
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooer/dooer-test-env",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Run the whole Dooer backend locally (staging DB minus customers), copy/purge customers between environments, and shred — one CLI.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": "Dooer/cli-dooer-test-env",
|