-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Sharp 0.33 does not create binaries for alpine linux / docker #3900
Comments
Hi, this sounds like an installation issue. It might be faster if you provide answers to all of the questions in https://github.com/lovell/sharp/issues/new?labels=installation&template=installation.md Please ensure you've read the installation documentation, especially when upgrading to v0.33.0:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
@gtwilliams03 The |
As per the docs in https://sharp.pixelplumbing.com/install#cross-platform I tried: Instead of building sharp like
I installed the platform specific version
For sharp 0.32.6 this generates the binaries in node_js/sharp, sharp just works fine
for 0.33 this does not generate the binaries. My app then complains that it could not find sharp.
|
The binaries live in packages under the
You have probably run into the npm lockfile bug npm/cli#4828 that is linked to in the documentation. |
@lovell Thank you! I updated the first line of the Dockerfile to:
and all is well. I had been using alpine 3.15 and hadn't realized I had not upgraded it in a while... I'll show myself out and stop hijacking the ticket :) |
Hmm, seems to be different for 0.32.6 and 0.33. I don't know too much about the details of where npm stores binaries but that's what I see: 0.32.6 seems to install the binaries in node_modules/vendor This is regardless of whether I delete package-lock.json before running npm i ... I am just a plain user of NextJs next/image and I am not aware of how they are using sharp. Can it be that the changes of where the binaries are stored affects them? 0.32.6:
0.33:
|
Found a solution here: https://flinect.com/blog/nextjs-standalone-docker-sharp-installation, it boils down to: Install sharp globally via |
This is expected and correct, please see #3750 for all the details.
Please avoid installing sharp globally, it will only lead to further problems later. If doing so appears to fix a problem then I suspect you have multiple, conflicting versions of sharp within the same installation tree or you had previously installed sharp globally and were seeing the effects of having done so. The issue installation template asks the question: What is the output of running |
I totally agree, installing sharp globally is not best practice in the first place. On the other hand, it is installed in a docker container that runs one NextJS app only, so it might be not that bad. My guess on the whole thing is: When deploying a NextJS app on vercel, they provide sharp for the app. No need to include sharp in package.json. So when creating a docker container that runs on a non-Vercel system, it might be OK to install sharp globally on this container and think of it as an infrastructure component. |
@rhufsky If you still require help, the best thing to do is provide a complete, minimal, standalone repo including a Dockerfile that allows someone else to reproduce. @tinrab The advice in your https://flinect.com/blog/nextjs-standalone-docker-sharp-installation article is somewhat misguided (e.g. installing a release candidate globally is going to end in tears). it looks like you are using Next.js standalone mode and therefore have very likely hit a known Vercel bug - see vercel/nft#371 - I'd very much appreciate it if you could edit your article to reflect this so others are not confused by it. |
This was a Vercel bug, now fixed - see vercel/nft#371 and #3870 (comment) |
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of
sharp
that is not the latest, please open an issue against that package instead.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?System:
OS: Linux 5.4 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz
Memory: 29.95 GB / 31.33 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 20.5.1 - /usr/bin/node
npm: 10.2.3 - /usr/bin/npm
npmPackages:
sharp: ^0.33 => 0.33.1
What are the steps to reproduce?
After a lot of tinkering with docker I narrowed it down to:
I want to use Alpine Linux and I guess I have to rebuild sharp for that so I do:
For Sharp 0.33 I get:
No binaries are generated. Hence, no binaries are moved to the docker image and sharp does not work in the resulting container.
What is the expected behaviour?
For Sharp 0.32.6 I get:
The vendor folder seems to contain the generated binaries. As a consequence, the generated image and the container works as desired.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Tested on Ubuntu 22.04 as a base system for my Docker builds.
Please provide sample image(s) that help explain this problem
The text was updated successfully, but these errors were encountered: