I have checked the issue Error while building a docker image in the node.bcrypt.js repository and the Stack Overflow topic Docker Failed - bcrypt_lib.node: Exec format error. Altgough some solutions has been suggested there, none of them has satisfied me, and also it is still unclear WHY bcrypt packages causes this error.
Please do not copy node_modules inside Docker. It decreases your build time and prevents this kind of errors from happening.
https://github.com/kelektiv/node.bcrypt.js/issues/824#issuecomment-677485592
does not answer this question because all other packages I installed works fine (I'll list them in the appendix). And, it is not the solution - it running away from the problem because it is something wrong with the bcrypt package.
That is why I have started my own investigation and myfirst question is WHY bcrypt package requies the special attention to itself? What exacly wrong with it? Why it as the bad comatibility with the Docker?
docker.compose.yaml
Unlike the Docker Failed - bcrypt_lib.node: Exec format error topic, I have no Dockerfile (for the local development mode). Also, need to start the Nodemon from the FrontServer service.
version: "3.5"
services:
FrontServer:
image: node:18-alpine
container_name: Example-Local-FrontServer
ports: [ "8080:8080" ]
# [ Theory ] Nodemon will not be found if invoke just "nodemon". See https://linuxpip.org/nodemon-not-found/
# [ Theory ] About -L flag: https://github.com/remy/nodemon/issues/1802
command: sh -c "cd var/www/example.com && node_modules/.bin/nodemon -L 03-LocalDevelopmentBuild/FrontServerEntryPoint.js --environment local"
depends_on: [ Database ]
volumes:
- type: bind
source: .
target: /var/www/example.com
Database:
image: postgres
container_name: Example-Local-Database
ports: [ "${DATABASE_PORT}:${DATABASE_PORT}" ]
environment:
- "POSTGRES_PASSWORD=${DATABASE_PASSWORD}"
volumes:
- DatabaseData:/var/lib/postgresql/data
volumes:
DatabaseData:
name: Example-Local-DatabaseData
driver: local
Other Node.js dependencies
Unlike the bcrypt, below dependencies does not cause the Exec format error:
{
"private": "true",
"dependencies": {
"@yamato-daiwa/es-extensions": "1.7.0-alpha.4",
"@yamato-daiwa/es-extensions-nodejs": "1.7.0-alpha.4",
"body-parser": "1.20.2",
"class-transformer": "0.5.1",
"class-validator": "0.14.0",
"cors": "2.8.5",
"express": "4.18.2",
"express-handlebars": "7.1.2",
"jsonwebtoken": "9.0.2",
"morgan": "1.10.0",
"multer": "1.4.5-lts.1",
"passport": "0.6.0",
"passport-jwt": "4.0.1",
"pg": "8.11.3",
"qs": "6.11.2",
"reflect-metadata": "0.1.13",
"routing-controllers": "0.10.4",
"typeorm": "0.3.17"
}
}