node-rdkafka icon indicating copy to clipboard operation
node-rdkafka copied to clipboard

Error while run via node:femium-alpine Docker image

Open kylejw2 opened this issue 3 years ago • 1 comments

Docker Environment Information

  • OS [e.g. Mac, Arch, Windows 10]: Alpine Linux
  • Node Version [e.g. 8.2.1]: 14.19.1
  • node-rdkafka version [e.g. 2.3.3]: 2.12.0

Steps to Reproduce

  1. Copy the following files to Dockerfile.local and docker-compose.yml
  2. Run docker compose up

Dockerfile.local

FROM node:fermium-alpine

ENV NODE_ENV=production

RUN apk --no-cache add \
      bash \
      g++ \
      ca-certificates \
      lz4-dev \
      musl-dev \
      cyrus-sasl-dev \
      openssl-dev \
      make \
      python

RUN apk add --no-cache --virtual .build-deps gcc zlib-dev libc-dev bsd-compat-headers py-setuptools bash

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install --silent

docker-compose.yml

version: '3.7'

services:
  app:
    build:
      context: .
      dockerfile: ./Dockerfile.local
    command: 'npm run dev'
    env_file: .env
    volumes:
      - ./:/usr/src/app
    ports:
      - ${PORT}:${PORT}
    expose:
      - ${PORT}

Additional context I'm getting the following error: Error: Error loading shared library /usr/src/app/node_modules/node-rdkafka/build/Release/node-librdkafka.node: Exec format error. I tried downgrading my node-rdkafka version, but still experienced the error. I also tried changing the node docker image to what was recommended in the example alpine docker image that @webmakersteve created. Still experienced the same error.

Running node-rdkafka on my mac runs smoothly without any errors, but moving the same application over to Docker is when I'm seeing the issues.

kylejw2 avatar May 13 '22 15:05 kylejw2

I should also point out that this is a runtime error.

kylejw2 avatar May 13 '22 16:05 kylejw2