I'm trying to install node canvas (https://github.com/Automattic/node-canvas) on Alpine within docker.
These are (parts of) my Dockerfile:
# Use node/alpine image for final build
FROM keymetrics/pm2:latest-alpine as app
# install dependencies for canvas
RUN apk --no-cache --virtual .build-deps add \
python \
make \
g++ \
gcc \
&& apk --no-cache --virtual .canvas-build-deps add \
build-base \
cairo-dev \
jpeg-dev \
pango-dev \
giflib-dev \
pixman-dev \
pangomm-dev \
libjpeg-turbo-dev \
freetype-dev \
&& apk --no-cache add \
pixman \
cairo \
pango \
giflib
RUN apk add --update --repository http://dl-3.alpinelinux.org/alpine/edge/testing libmount ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family fontconfig
# Install dependencies
RUN npm install --prod
RUN npm rebuild canvas --build-from-source
When I try to boot my docker container the following error appears:
Error: Error relocating /var/www/app/node_modules/canvas/build/Release/canvas.node: FcConfigGetCurrent: symbol not found
at Object.Module._extensions..node (internal/modules/cjs/loader.js:775:18)
at Module.load (internal/modules/cjs/loader.js:626:32)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
at Function.Module._load (internal/modules/cjs/loader.js:558:3)
at Module.require (internal/modules/cjs/loader.js:663:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/var/www/app/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:734:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
at Module.load (internal/modules/cjs/loader.js:626:32)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
at Function.Module._load (internal/modules/cjs/loader.js:558:3)
at Module.require (internal/modules/cjs/loader.js:663:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/var/www/app/node_modules/canvas/lib/canvas.js:9:18)
at Module._compile (internal/modules/cjs/loader.js:734:30)
I'm guessing that it has something to do with the fact that Alpine uses musl instead of glibc but I thought that rebuilding canvas from source npm rebuild canvas --build-from-source
would be enough.
I've already tried most suggestions from https://github.com/Automattic/node-canvas/issues but none is working for me.
Any suggestions ?