Calling all Docker Experts |Error: Cannot find module for the SQLite3

Calling on Docker Experts:

I find myself facing an intriguing challenge with my Node Packaging Manager (NPM) project. This project is composed of JavaScript, CSS, HTML/EJS, and SQLite3. While exploring Docker’s documentation, I have noticed that Docker appears to optimize MongoDB applications more efficiently than SQLite3, which is a more raw database application platform. However, when I attempt to build an image of my NPM project using Docker and its volume features, I encounter an error message from the Docker command prompt. This error occurs because the Docker volume (-v) attempts to include the SQLite3 module/library in the Linux configuration, but Linux doesn’t recognize the SQLite3 module/library. The error message looks like this:

Error: Cannot find module '/ivoteballot/node_modules/sqlite3/lib/binding/napi-v6-linux-musl-arm64/node_sqlite3.node'

I am currently facing a dilemma: should I seek expert guidance on addressing the deficiency of a SQLite3 “Docker Official Image” to incorporate as a port (-p), or should I consider rewriting all of my JavaScript code, which heavily relies on SQLite3, to make it compatible with a MongoDB application? I had designed my JavaScript code around SQLite3 for enhanced security control in my development project.

I am eager to hear any suggestions and recommendations from experts in the field. Please share your insights and advice.

Dockerfile Definition:

# Use an appropriate Node.js base image

FROM node:18-alpine

RUN npm install -g nodemon

# Set the working directory in the container

WORKDIR /ivoteballot

COPY controllers /ivoteballot/

COPY models /ivoteballot/

#

# Copy the rest of your application files to the container

COPY . .

# Copy package.json and package-lock.json to the container

COPY package.json /ivoteballot/

COPY package-lock.json /ivoteballot/

# Install dependencies

RUN npm install

EXPOSE 8080

# Define the command to start your Node.js application

#CMD ["node", "index.js"]

CMD ["npm", "run", "dev"]

Here are additional photographs for your review:

You have to install all modules in the image and make sure you don’t overwrite anything as different kind of libraries could be reuired in the container than on the host machne. Don’t mount a library from the host unless you are sure the host has the same Linux distribution than in the container. For example you run ubuntu 22.04 on the host and in the container too. This is not the case as you are running Docker on Windows and the container is an alpine linux which is not compatible with an ubuntu either.

PS: I fixed your post.Please, format your posts according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

If yo send a Dockerfile without a code block that is almost unreadable except for moderators who can edit your post.