Alpine Linux: Failed at the mediasoup@3.8.0 postinstall script

Hey there, trying to play around with mediaoup in alpine linux (run in a docker container) to figure out the right docker deployment but here’s a problem on installation:


I’ve already made sure about the prerequisites (make, python3, build-essential)

This will happen if you’re running in a container environment or environment that otherwise doesn’t have kernel headers.

1 minute search says that if you install linux-headers package the error should go away.

Issue solved.
Thanks for the help and the quick respone.

Some people (including myself) have had some very difficult to debug networking issues with mediasoup on alpine-linux. I think it has something to do with UDP support in libuv on alpine. I’m not sure if the bug is with libuv or alpine, but switching to the standard ubuntu-based docker image for node fixes it.

It’s possible this doesn’t happen anymore, but wanted to give you a heads up just in case. There’s more information in these threads:

1 Like

I’m build docker image on Mac using ubuntu-20.04 base image, trying use a alternative linux-header version, but still get the error:

# npm install
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)

> mediasoup@3.8.3 postinstall /webrtc_server/node_modules/mediasoup
> node npm-scripts.js postinstall

npm-scripts.js [INFO] running task "postinstall"
npm-scripts.js [INFO] executing command: make -C worker
make: Entering directory '/webrtc_server/node_modules/mediasoup/worker'
python3 ./scripts/configure.py -R mediasoup-worker
/webrtc_server/node_modules/mediasoup/worker/./deps/gyp/pylib/gyp/input.py:1186: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if the_dict_key is 'variables' and variable_name in the_dict:
['-R', 'mediasoup-worker', '/webrtc_server/node_modules/mediasoup/worker/mediasoup-worker.gyp', '-I', '/webrtc_server/node_modules/mediasoup/worker/common.gypi', '--depth=.', '-f', 'make', '-Goutput_dir=/webrtc_server/node_modules/mediasoup/worker/out', '--generator-output', '/webrtc_server/node_modules/mediasoup/worker/out', '-Dgcc_version=93', '-Dclang=0', '-Dhost_arch=x64', '-Dtarget_arch=x64', '-Dopenssl_fips=', '-Dmediasoup_asan=false', '-Dnode_byteorder=little']
Traceback (most recent call last):
  File "./scripts/configure.py", line 114, in <module>
    run_gyp(gyp_args)
  File "./scripts/configure.py", line 52, in run_gyp
    rc = gyp.main(args)
  File "/webrtc_server/node_modules/mediasoup/worker/./deps/gyp/pylib/gyp/__init__.py", line 545, in main
    return gyp_main(args)
  File "/webrtc_server/node_modules/mediasoup/worker/./deps/gyp/pylib/gyp/__init__.py", line 530, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "/webrtc_server/node_modules/mediasoup/worker/./deps/gyp/pylib/gyp/generator/make.py", line 2147, in GenerateOutput
    root_makefile = open(makefile_path, 'w')
FileNotFoundError: [Errno 2] No such file or directory: '/webrtc_server/node_modules/mediasoup/worker/out/Makefile'
make: *** [Makefile:24: default] Error 1
make: Leaving directory '/webrtc_server/node_modules/mediasoup/worker'

I just tried build docker image on native Ubuntu-20.04 host, not Mac, but still get the same error, My Dockerfile:

FROM ubuntu:20.04 AS devtime

ENV LANG C.UTF-8
WORKDIR /
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update --fix-missing \
  && apt-get install -y xz-utils unzip gcc g++ git cmake clang-8 pkg-config \
  python3-pip python3-dev python3-setuptools build-essential libtinfo-dev zlib1g-dev

WORKDIR /
RUN git clone --recursive --depth 1 https://github.com/FFmpeg/FFmpeg
WORKDIR /FFmpeg
RUN ./configure --prefix=/usr/local --enable-gpl --enable-nonfree --disable-everything --enable-demuxer=h264 --enable-parser=h264 --enable-decoder=h264 --enable-muxer=rtp --enable-muxer=tee --enable-filter=copy --enable-protocol=rtp --enable-protocol=tcp --disable-x86asm && make

ADD node-v14.17.6-linux-x64.tar.xz /
ENV PATH="/node-v14.17.6-linux-x64/bin:${PATH}"
ADD webrtc_server.tar /
#https://mediasoup.discourse.group/t/alpine-linux-failed-at-the-mediasoup-3-8-0-postinstall-script/3153
RUN apt update && apt install -y linux-headers-$(uname -r)
RUN cd /webrtc_server && npm install
#Note: mediasoup package needs C++ compile;

Does the error relate to node-v14.17.6-linux-x64.tar.xz which i download from nodejs site?

RUN apt-get update && apt-get install -y nodejs npm

After i switch the nodejs version to apt installed package, everything works fine.