holepunchto / hyperswarm

A distributed networking stack for connecting peers.
https://docs.holepunch.to
MIT License
1.08k stars 87 forks source link

hyperswarm on Docker container Segmentation fault #172

Open sce9sc opened 8 months ago

sce9sc commented 8 months ago

I am not sure If hyperswarm should work on docker but when I run it in a container I got Segmentation fault just before the connection is established.

const Hyperswarm = require('hyperswarm')

const main = async ()=>{

    const topic = Buffer.alloc(32).fill('mytestopic') 
    const hyper = new Hyperswarm()
    hyper.on('connection', ()=>{console.log('connected')})
    const discovery = hyper.join(topic, { server: false, client: true })
    await discovery.flushed() // Waits for the topic to be fully announced on the DHT
}

main()

Dockerfile

FROM node:20-alpine

RUN mkdir -p /home/node/app
WORKDIR /home/node/app
COPY package*.json ./
#USER node
RUN npm set strict-ssl false
RUN npm install
COPY . .
EXPOSE 49737/udp
CMD ["node", "main.js"]
sce9sc commented 8 months ago

Using @hyperswarm/doctor has the same effect

sce9sc commented 8 months ago

I found the problem . For some reason node:20-alpine image does not work . It might be that all alpine image are not working but I am not sure . I checked it with node:21-alpine and had the same issue

I used FROM node:lts-bookworm-slim

and it worked