Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application Crash with bcrypt's compare function on node:alpine #1040

Open
alissoncorsair opened this issue Jun 10, 2024 · 4 comments
Open

Comments

@alissoncorsair
Copy link

Title:

Application Crash with bcrypt's compare function on node:alpine

Description:

I encountered an issue where my application crashes when using the compare function from bcrypt on the node:alpine Docker image. I tried switching to the latest Node.js version, which resolved the problem, but it persists on Alpine. Here are the details:

Steps to Reproduce:

  1. Use the node:alpine Docker image in a Node.js application.
  2. Utilize bcrypt's compare function to compare hashed passwords.
  3. Observe the application crash upon invoking the compare function.

Expected Behavior:

The application should successfully execute the compare function without crashing.

Actual Behavior:

The application crashes when calling the compare function, specifically on the node:alpine image.

Additional Details:

  • Dockerfile:
    FROM node:latest
    WORKDIR /usr/src/app
    COPY package*.json ./
    RUN npm install
    COPY . .
    RUN npm run build
    EXPOSE 3000
    CMD ["npm", "start"]
    
  • compose.yaml:
services:
  db:
    image: mongo
    container_name: mongo
    ports:
      - "27017:27017"
    volumes:
      - mongo_data:/data/db
  app:
    build: .
    command: npm run dev
    ports:
      - "3000:3000"
    volumes:
      - .:/usr/src/app
      - /usr/src/app/node_modules
      - /usr/src/app/dist
    depends_on:
      - db  
volumes:
  mongo_data:

@loresclement
Copy link

Hello,
Same issue out there. Let me know if you find out why

@recrsn
Copy link
Collaborator

recrsn commented Jun 11, 2024

Usually happens due to a libc mismatch, check that the copy step isn't copying node_modules from the host into the container you just built

@rubemarjrtech
Copy link

rubemarjrtech commented Jul 4, 2024

Usually happens due to a libc mismatch, check that the copy step isn't copying node_modules from the host into the container you just built

Hello.

I have the same problem, this is my dockerfile:

FROM node

WORKDIR /home/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 4000

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

and this is my docker-compose.yml:

version: '3'

networks:
   local:

services:
   mysql:
      container_name: mysqldb
      image: mysql:8
      environment:
         MYSQL_DATABASE:
         MYSQL_USER:
         MYSQL_PASSWORD:
         MYSQL_ROOT_PASSWORD:
      networks:
         - local
      ports:
         - '3306:3306'

   app:
      depends_on:
         - mysql
      container_name: blog-api
      build:
         context: .
         dockerfile: Dockerfile
      environment:
         DB_HOST:
         DB_USERNAME:
         DB_PASSWORD:
         DB_DATABASE:
      volumes:
         - ./:/home/app
      ports:
         - '4000:4000'
      networks:
         - local

I tried using a .dockerignore file to ignore node_modules, but nothing changed, any suggestions?

I dont know if this changes anything, but I use WSL.

@kopax
Copy link

kopax commented Sep 24, 2024

same problem here node:20-alpine, any workaround please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants