I'm creating a docker for the Back-End server, but everything is fine until I create a volumes, so I have my .yml configured docker-compose.yml
version: "3.7"
services:
my-api:
container_name: backend
build: ./
command: npm start
working_dir: /usr/src/my-api
ports:
- "3000:3000"
volumes:
- ./:/usr/src/my-api
and this is my Dockerfile
FROM node:10
WORKDIR /usr/src/my-api
COPY ./ ./
RUN npm install
CMD ["/bin/bash"]
Considering that I created my .dockerignore
node_modules
From what I have analyzed, the problem is that when creating the volumes, the modules are copied directly and that causes the problem shown below.
Successfully built e1dfb81dd4c4
Successfully tagged facial-api_smart-brain-api:latest
Creating backend ... done
Attaching to backend
backend |
backend | > facial-api@1.0.0 start /usr/src/Facial-api
backend | > nodemon server.js
backend |
backend | [nodemon] 1.18.4
backend | [nodemon] to restart at any time, enter `rs`
backend | [nodemon] watching: *.*
backend | [nodemon] starting `node server.js`
backend | internal/modules/cjs/loader.js:718
backend | return process.dlopen(module, path.toNamespacedPath(filename));
backend | ^
backend |
backend | Error: /usr/src/Facial-api/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
backend | at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
backend | at Module.load (internal/modules/cjs/loader.js:599:32)
backend | at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
backend | at Function.Module._load (internal/modules/cjs/loader.js:530:3)
backend | at Module.require (internal/modules/cjs/loader.js:637:17)
backend | at require (internal/modules/cjs/helpers.js:20:18)
backend | at Object.<anonymous> (/usr/src/Facial-api/node_modules/bcrypt/bcrypt.js:6:16)
backend | at Module._compile (internal/modules/cjs/loader.js:689:30)
backend | at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
backend | at Module.load (internal/modules/cjs/loader.js:599:32)
backend | [nodemon] app crashed - waiting for file changes before starting...
Any idea, recommendation to solve it?