Blizzard / Blizzard/node-rdkafka
Error while run via node:femium-alpine Docker image
- Dominant language
- JavaScript
- Stars
- 2.2k
- Forks
- 403
- PR merge metrics
- No merged PRs in 30d
Description
**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](https://github.com/Blizzard/node-rdkafka/blob/master/examples/docker-alpine.md) 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.
Contributor guide
Research direction
Start by reproducing the failure with Dockerfile.local and docker-compose.yml using docker compose up. Inspect the native module at node_modules/node-rdkafka/build/Release/node-librdkafka.node and compare how npm install runs inside the node:fermium-alpine container with the mounted application. Done means the container starts without the Exec format error and node-rdkafka loads successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, javascript, kafka, node.js
- Domain
- backend, devops, distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100