Skip to content
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

How to use in docker environment? #2815

Closed
edrichhans opened this issue Jul 27, 2021 · 8 comments
Closed

How to use in docker environment? #2815

edrichhans opened this issue Jul 27, 2021 · 8 comments

Comments

@edrichhans
Copy link

My apologies for my ignorance, this is my first time setting this up in a docker environment.

When I tried to dockerize my application that used the sharp library, I encountered
ERR! sharp Use with glibc 2.24 requires manual installation of libvips >= 8.10.0

I found this issue which should solve the problem, but I am having trouble following this and understanding which script to use and how to install it. I tried running the cross-platform compatible build script in docker, but I'm getting something like

 > [ 5/10] RUN bash -c ./sharp-libvips-8.10.6/build/lin.sh:
lovell/sharp-libvips#8 0.420 mkdir: missing operand
lovell/sharp-libvips#8 0.420 Try 'mkdir --help' for more information

This is my dockerfile:

FROM node:12

RUN curl -OL -o v8.10.6.tar.gz https://github.com/lovell/sharp-libvips/archive/refs/tags/v8.10.6.tar.gz
RUN tar -xzf v8.10.6.tar.gz && rm v8.10.6.tar.gz
RUN chmod +x sharp-libvips-8.10.6/build/lin.sh
RUN ./sharp-libvips-8.10.6/build/lin.sh

# Create app directory
WORKDIR /usr/src/my-app

COPY package.json .
COPY package-lock.json .

RUN npm ci

COPY . .

EXPOSE 3030

CMD [ "npm", "start" ]

I appreciate any help. Thank you!

@lovell
Copy link
Owner

lovell commented Jul 27, 2021

What is the target device, CPU, OS? Is this on ARMv7 or ARM64v8?

I recommend using the latest version of an up-to-date base OS that matches the minimum glibc/musl requirements at https://sharp.pixelplumbing.com/install#prebuilt-binaries and then you don't need to worry about compiling anything.

@lovell lovell transferred this issue from lovell/sharp-libvips Jul 27, 2021
@edrichhans
Copy link
Author

What is the target device, CPU, OS? Is this on ARMv7 or ARM64v8?

I recommend using the latest version of an up-to-date base OS that matches the minimum glibc/musl requirements at https://sharp.pixelplumbing.com/install#prebuilt-binaries and then you don't need to worry about compiling anything.

Hi @lovell, thanks for your reply. What do you mean by base OS? If I'm using a docker container, there's no OS involved, right? Sorry I'm a bit new to this 🙏

@aimon7

This comment has been minimized.

@lovell
Copy link
Owner

lovell commented Aug 2, 2021

@edrichhans Please can you create a standalone repo with a complete Dockerfile that demonstrates what you're trying to achieve.

EDIT: I just saw you're using FROM node:12 - I think this is based on Debian Linux. If you still need help, please can you answer my questions about CPU/device.

@malt03
Copy link

malt03 commented Aug 3, 2021

I had the same situation, but it was solved.
The version of glibc in buster, which is the stable version of debian, is 2.28.
The only official Docker images for Node.js are the ones that use the stable debian version, and you need to compile libvips and sharp to use sharp directly.

The testing version of debian, bullseye, contains glibc version 2.31.
So I created a Node.js image from bullseye and was able to install sharp.

Note that before installing sharp, you need to run npm install -g npm to increase the version of npm.

https://github.com/malt03/docker-node/tree/main/14/bullseye-slim
https://hub.docker.com/repository/docker/malt03/node

@lovell
This seems to be a problem that many people who use sharp in their Docker images run into.
Can you please add this issue to the README or documentation?

@lovell
Copy link
Owner

lovell commented Aug 3, 2021

@malt03 Are you using an ARM64 CPU?

The libc (glibc, musl) requirements for the prebuilt binaries are listed at https://sharp.pixelplumbing.com/install#prebuilt-binaries

@malt03
Copy link

malt03 commented Aug 3, 2021

Yes, I am using ARM64.
Thank you. I understood about the requirements document.
It was somewhat difficult to find out what version of glibc in debian and to discover that I can use bullseye to solve it.

However, I just checked and bullseye is scheduled to be released on August 14, 2021, and I think the official Node.js image will be released accordingly, so I felt there was no need to add it to the README or documentation.

@lovell
Copy link
Owner

lovell commented Sep 5, 2021

@edrichhans Closing due to inactivity but please feel free to reopen with the requested details if further help is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants