mojaloop-simulator docker image show a .env not found error on startup
Summary: When starting mojaloop-simulator docker image, the following error is displayed in the log:
> [email protected] start
> node ./src/index.js
{
error: Error: ENOENT: no such file or directory, open '/opt/app/.env'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at Object.config (/opt/app/node_modules/dotenv/lib/main.js:72:42)
at module.exports (/opt/app/src/lib/config.js:33:30)
at start (/opt/app/src/index.js:85:32)
at Object.<anonymous> (/opt/app/src/index.js:350:2)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/opt/app/.env'
}
}
However, the docker container starts and runs fine....
This is purely to stop any red-herrings issues being opened when another error causes the docker image to fail on startup. This was the case when trying to investigate this issue: https://github.com/mojaloop/project/issues/2992.
Severity: Low
Priority: Low
Expected Behavior
Docker image should start without .env missing error.
Steps to Reproduce
N/a
Specifications
- Component (if known): mojaloop/mojaloop-simulator
- Version: v13.0.1
- Platform: Docker
- Subsystem: Kubernetes
- Type of testing: n/a
- Bug found/raised by: @orcr, @mdebarros
Notes:
- Severity when opened: low
- Priority when opened: low
The .env not found error is caused by default .env file name in this function: https://github.com/mojaloop/mojaloop-simulator/blob/main/src/lib/config.js#L34
This function was used to override env variables at run time using additional env file specified using another env variable CONFIG_OVERRIDE(default .env)
But the latest change to the repo has removed this feature.
We can either go back and add that functionality with an additional check here : https://github.com/mojaloop/mojaloop-simulator/blob/main/src/index.js#L88 Or completely remove these 2 lines https://github.com/mojaloop/mojaloop-simulator/blob/main/src/index.js#L88-L90 and this file https://github.com/mojaloop/mojaloop-simulator/blob/main/src/lib/config.js