opencred icon indicating copy to clipboard operation
opencred copied to clipboard

Docker container fails to initialize db

Open namelessmasses opened this issue 1 year ago • 3 comments

HEAD https://github.com/stateofca/opencred/tree/06142d839abc74826222de66cf90e5b412d56cb4

Reproduction Steps

  1. docker build . -t opencred-platform
  2. docker run -i -p 22443:22443 -v $PWD/configs:/etc/app-config opencred-platform

Output

opencred: [prototype-experiment-1 ≡ +4 ~1 -0 !]
 1079ms 2025-01-05 06:43:07 PS7> docker build . -t opencred-platform
[+] Building 70.8s (14/14) FINISHED                                                                                                                                      docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                                                     0.0s
 => => transferring dockerfile: 843B                                                                                                                                                     0.0s 
 => WARN: SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "NODE_AUTH_TOKEN") (line 14)                                                                 0.0s 
 => [internal] load metadata for docker.io/library/node:20-alpine                                                                                                                        0.0s 
 => [internal] load .dockerignore                                                                                                                                                        0.0s 
 => => transferring context: 76B                                                                                                                                                         0.0s 
 => [internal] load build context                                                                                                                                                        0.1s 
 => => transferring context: 85.76kB                                                                                                                                                     0.1s 
 => [base 1/3] FROM docker.io/library/node:20-alpine@sha256:426f843809ae05f324883afceebaa2b9cab9cb697097dbb1a2a7a41c5701de72                                                             0.0s 
 => => resolve docker.io/library/node:20-alpine@sha256:426f843809ae05f324883afceebaa2b9cab9cb697097dbb1a2a7a41c5701de72                                                                  0.0s
 => CACHED [base 2/3] RUN mkdir -p /home/node/app && chown -R node:node /home/node/app                                                                                                   0.0s 
 => CACHED [base 3/3] WORKDIR /home/node/app                                                                                                                                             0.0s 
 => CACHED [build-setup 1/1] RUN apk add --no-cache git bash                                                                                                                             0.0s
 => [build 1/4] COPY --chown=node:node . .                                                                                                                                               0.1s 
 => [build 2/4] RUN mv dev.js index.js                                                                                                                                                   0.3s 
 => [build 3/4] RUN npm i --omit=dev --package-lock                                                                                                                                     17.5s 
 => [build 4/4] RUN node index.js bundle --webpack-mode production --bundle-mode production                                                                                             21.7s 
 => [release 1/1] COPY --from=test --chown=node:node /home/node/app ./                                                                                                                   6.7s 
 => exporting to image                                                                                                                                                                  20.5s 
 => => exporting layers                                                                                                                                                                 13.5s 
 => => exporting manifest sha256:2ea70b48bd18ec442e3cf20f174d2075513b8f9abee55bb1d10770239557eb93                                                                                        0.0s 
 => => exporting config sha256:679e65bf564b39a963db3f77bf8351b102f81691850b9e7fb8845d1c3f86a638                                                                                          0.0s 
 => => exporting attestation manifest sha256:57dd49ec79142abb36f0286f497517342d8a39c89416482a61406e4318e0965a                                                                            0.0s 
 => => exporting manifest list sha256:9fa06b5adca0c7022948b34014ea5a6fbc3b7436008d59b8ec682d1695180158                                                                                   0.0s 
 => => naming to docker.io/library/opencred-platform:latest                                                                                                                              0.0s 
 => => unpacking to docker.io/library/opencred-platform:latest                                                                                                                           6.8s 

View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/0qc00srv4v7j0dtltgcxnahta

 1 warning found (use docker --debug to expand):
 - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "NODE_AUTH_TOKEN") (line 14)

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview 

opencred: [config-example-aligns-with-schema ≡ +4 ~0 -0 !]
 147ms 2025-01-05 06:45:55 PS7> docker run -i -p 22443:22443 -v $PWD/configs:/etc/app-config opencred-platform
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"opencred-platform","message":"Loading config from /home/node/app/configs/combined.yaml","level":"info"}
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"opencred-platform","message":"Loaded config from /home/node/app/configs/combined.yaml","level":"info"}
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"bedrock-config-yaml","message":"Attempting to apply the \"core\" configuration from environment variable.","level":"debug"}
2025-01-05T14:48:17.673Z - info: [bedrock/primary] starting process "opencred" workerPid=undefined, workerId=undefined, details={
  "pid": 1
}
2025-01-05T14:48:17.680Z - info: [bedrock/primary] started workerPid=undefined, workerId=undefined, details={
  "timeMs": 38
}
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"bedrock-config-yaml","message":"Attempting to apply the \"core\" configuration from environment variable.","level":"debug"}
2025-01-05T14:48:19.295Z - info: [bedrock/worker] starting process "opencred-worker" workerPid=18, workerId=2b391b7114647e26
2025-01-05T14:48:19.301Z - debug: [bedrock-config-yaml] Attempting to apply the "app" configuration from environment variable. workerPid=18, workerId=2b391b7114647e26
2025-01-05T14:48:19.305Z - debug: [bedrock-config-yaml] "app" configuration found. workerPid=18, workerId=2b391b7114647e26
2025-01-05T14:48:19.350Z - info: [opencred-platform] OpenCred Config Successfully Validated. workerPid=18, workerId=2b391b7114647e26
2025-01-05T14:48:19.352Z - info: [bedrock-mongodb] initializing database workerPid=18, workerId=2b391b7114647e26, details={
  "url": "mongodb://localhost:27017/opencred_localhost"
}
2025-01-05T14:48:47.424Z - error: [bedrock-mongodb] could not initialize database workerPid=18, workerId=2b391b7114647e26, details={
  "error": {
    "message": "Could not initialize database.",
    "stack": "DatabaseError: Could not initialize database.\n    at _initDatabase (file:///home/node/app/node_modules/@bedrock/mongodb/lib/index.js:196:13)\n    at async Module.runOnce (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:222:5)\n    at async _init (file:///home/node/app/node_modules/@bedrock/mongodb/lib/index.js:154:5)\n    at async EventEmitter.emit (file:///home/node/app/node_modules/@digitalbazaar/async-node-events/lib/index.js:146:20)\n    at async _runWorker (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:570:3)\n    at async Module.start (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:160:5)",
    "name": "DatabaseError",
    "details": {
      "url": "mongodb://localhost:27017/opencred_localhost"
    },
    "cause": {
      "name": "MongoServerSelectionError",
      "reason": {
        "type": "Single",
        "setName": null,
        "maxSetVersion": null,
        "maxElectionId": null,
        "servers": {},
        "stale": false,
        "compatible": true,
        "compatibilityError": null,
        "logicalSessionTimeoutMinutes": null,
        "heartbeatFrequencyMS": 10000,
        "localThresholdMS": 15,
        "commonWireVersion": null
      }
    }
  }
}
2025-01-05T14:48:47.425Z - critical: [bedrock/worker] unhandled promise rejection workerPid=18, workerId=2b391b7114647e26, details={
  "error": {
    "message": "Could not initialize database.",
    "stack": "DatabaseError: Could not initialize database.\n    at _init (file:///home/node/app/node_modules/@bedrock/mongodb/lib/index.js:169:11)\n    at async EventEmitter.emit (file:///home/node/app/node_modules/@digitalbazaar/async-node-events/lib/index.js:146:20)\n    at async _runWorker (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:570:3)\n    at async Module.start (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:160:5)",
    "name": "DatabaseError",
    "details": {
      "url": "mongodb://localhost:27017/opencred_localhost"
    },
    "cause": {
      "name": "DatabaseError",
      "message": "Could not initialize database.",
      "details": {
        "url": "mongodb://localhost:27017/opencred_localhost"
      },
      "cause": {
        "name": "MongoServerSelectionError",
        "reason": {
          "type": "Single",
          "setName": null,
          "maxSetVersion": null,
          "maxElectionId": null,
          "servers": {},
          "stale": false,
          "compatible": true,
          "compatibilityError": null,
          "logicalSessionTimeoutMinutes": null,
          "heartbeatFrequencyMS": 10000,
          "localThresholdMS": 15,
          "commonWireVersion": null
        }
      }
    }
  }
}
2025-01-05T14:48:47.437Z - info: [bedrock/primary] worker "18" exited on purpose with code "0" and signal "null"; exiting primary process. workerPid=undefined, workerId=undefined
2025-01-05T14:48:47.438Z - info: [bedrock/primary] primary process exiting with code "0". workerPid=undefined, workerId=undefined, details={
  "code": 0
}

namelessmasses avatar Jan 05 '25 15:01 namelessmasses

Perhaps related: https://github.com/stateofca/opencred/pull/3

davidlehn avatar Jan 06 '25 19:01 davidlehn

@davidlehn I did see that issue as well.

Do any contributors run the container? Seems odd that it reliably fails on a commit with the message "Release 8.6.0".

namelessmasses avatar Jan 06 '25 21:01 namelessmasses

@davidlehn confirmed same error when running with mapping configs to /etc/bedrock-config

opencred: [prototype-experiment-1 ≡ +5 ~1 -0 ! (1)]
 122ms 2025-01-06 17:59:49 PS7> docker run -i -p 22443:22443 -v $PWD/configs:/etc/bedrock-config opencred-platform
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"opencred-platform","message":"Loading config from /home/node/app/configs/combined.yaml","level":"info"}
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"opencred-platform","message":"Loaded config from /home/node/app/configs/combined.yaml","level":"info"}
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"bedrock-config-yaml","message":"Attempting to apply the \"core\" configuration from environment variable.","level":"debug"}  
2025-01-07T02:00:07.284Z - info: [bedrock/primary] starting process "opencred" workerPid=undefined, workerId=undefined, details={
  "pid": 1
}
2025-01-07T02:00:07.291Z - info: [bedrock/primary] started workerPid=undefined, workerId=undefined, details={
  "timeMs": 37
}
[winston] Attempt to write logs with no transports, which can increase memory usage: {"module":"bedrock-config-yaml","message":"Attempting to apply the \"core\" configuration from environment variable.","level":"debug"}
2025-01-07T02:00:08.781Z - info: [bedrock/worker] starting process "opencred-worker" workerPid=18, workerId=cbedbfccecd1a4bd
2025-01-07T02:00:08.786Z - debug: [bedrock-config-yaml] Attempting to apply the "app" configuration from environment variable. workerPid=18, workerId=cbedbfccecd1a4bd
2025-01-07T02:00:08.788Z - debug: [bedrock-config-yaml] "app" configuration found. workerPid=18, workerId=cbedbfccecd1a4bd
2025-01-07T02:00:08.830Z - info: [opencred-platform] OpenCred Config Successfully Validated. workerPid=18, workerId=cbedbfccecd1a4bd
2025-01-07T02:00:08.832Z - info: [bedrock-mongodb] initializing database workerPid=18, workerId=cbedbfccecd1a4bd, details={
  "url": "mongodb://localhost:27017/opencred_localhost"
}
2025-01-07T02:00:37.958Z - error: [bedrock-mongodb] could not initialize database workerPid=18, workerId=cbedbfccecd1a4bd, details={
  "error": {
    "message": "Could not initialize database.",
    "stack": "DatabaseError: Could not initialize database.\n    at _initDatabase (file:///home/node/app/node_modules/@bedrock/mongodb/lib/index.js:196:13)\n    at async Module.runOnce (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:222:5)\n    at async _init (file:///home/node/app/node_modules/@bedrock/mongodb/lib/index.js:154:5)\n    at async EventEmitter.emit (file:///home/node/app/node_modules/@digitalbazaar/async-node-events/lib/index.js:146:20)\n    at async _runWorker (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:570:3)\n    at async Module.start (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:160:5)",
    "name": "DatabaseError",
    "details": {
      "url": "mongodb://localhost:27017/opencred_localhost"
    },
    "cause": {
      "name": "MongoServerSelectionError",
      "reason": {
        "type": "Single",
        "setName": null,
        "maxSetVersion": null,
        "maxElectionId": null,
        "servers": {},
        "stale": false,
        "compatible": true,
        "compatibilityError": null,
        "logicalSessionTimeoutMinutes": null,
        "heartbeatFrequencyMS": 10000,
        "localThresholdMS": 15,
        "commonWireVersion": null
      }
    }
  }
}
2025-01-07T02:00:37.959Z - critical: [bedrock/worker] unhandled promise rejection workerPid=18, workerId=cbedbfccecd1a4bd, details={
  "error": {
    "message": "Could not initialize database.",
    "stack": "DatabaseError: Could not initialize database.\n    at _init (file:///home/node/app/node_modules/@bedrock/mongodb/lib/index.js:169:11)\n    at async EventEmitter.emit (file:///home/node/app/node_modules/@digitalbazaar/async-node-events/lib/index.js:146:20)\n    at async _runWorker (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:570:3)\n    at async Module.start (file:///home/node/app/node_modules/@bedrock/core/lib/index.js:160:5)",
    "name": "DatabaseError",
    "details": {
      "url": "mongodb://localhost:27017/opencred_localhost"
    },
    "cause": {
      "name": "DatabaseError",
      "message": "Could not initialize database.",
      "details": {
        "url": "mongodb://localhost:27017/opencred_localhost"
      },
      "cause": {
        "name": "MongoServerSelectionError",
        "reason": {
          "type": "Single",
          "setName": null,
          "maxSetVersion": null,
          "maxElectionId": null,
          "servers": {},
          "stale": false,
          "compatible": true,
          "compatibilityError": null,
          "logicalSessionTimeoutMinutes": null,
          "heartbeatFrequencyMS": 10000,
          "localThresholdMS": 15,
          "commonWireVersion": null
        }
      }
    }
  }
}
2025-01-07T02:00:37.972Z - info: [bedrock/primary] worker "18" exited on purpose with code "0" and signal "null"; exiting primary process. workerPid=undefined, workerId=undefined
2025-01-07T02:00:37.973Z - info: [bedrock/primary] primary process exiting with code "0". workerPid=undefined, workerId=undefined, details={
  "code": 0
}

opencred: [prototype-experiment-1 ≡ +5 ~1 -0 ! (1)]
 118ms 2025-01-06 18:00:38 PS7>

namelessmasses avatar Jan 07 '25 02:01 namelessmasses