-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working in node:alpine Docker base image #47
Comments
+1 |
@kachkaev I have been able to resolve this issue. On investigating I found that imagemin-mozjpeg installs mozjpeg-bin but in absence of autoconf, automake, libtool, make, gcc, musl-dev and nasm cannot build mozjpeg-bin from source and pulls in a GLIBC linked binary from github. Since alpine linux has musl-dev, the cjpeg cannot run without rebuilding/relinking with musl libc. Just install the above packages with apk add and then do npm install and it should work. |
Great news @divick! Feel free to share the dockerfile recipe. I probably won’t change my setup for now, but people coming here from search will definitely be happy to see the solution! |
Additionally you may need zlib-dev, pkgconf and file packages to be installed in alpine image. |
Here is the recipe for docker image based on node:10-15-alpine, which has node v10 and yarn already installed. One can use alpine-3.9 image too but would need to add build steps to install node and yarn/npm.
|
Want to extend what @divick wrote. - name: npm install
image: node:alpine
commands:
- apk add autoconf automake libtool make tiff jpeg zlib zlib-dev pkgconf nasm file gcc musl-dev
- npm install |
As above, we need to install appropriate dependencies for mozjpeg to use it on any platform including alpine. |
I've got an app that relies on
mozjpeg-bin
the following way:Things work locally on macOS and in Docker, when an image is based on
node:10.15.3
(Debian). However, when I switch tonode:10.15.3-alpine
, the following error shows up for each attempt to optimize an image:I tried a few workaround including installing libjpeg-turbo and libjpeg-turbo-utils packages and even tried some crazy things like swapping the binary in
node_modules/mozjpeg/vendor/cjpeg
, but no result after hours of hacking. The only solution was to switch back to Debian at a cost of a large added container size.What can be done to make
mozjpeg
work in Alpine? Happy to switch back, but unfortunately can't manage this myself.The text was updated successfully, but these errors were encountered: