strapi-docker
strapi-docker copied to clipboard
docker-compose fails due to `sharp` build error: `ERR! sharp EPERM: operation not permitted`
Bug report
Describe the bug
- On OSX Catalina and Strapi
3.4.2
docker images, runningstrapi/strapi
in docker-compose fails. - The error message seems to show that symlink creation is not permitted. (Docker container to host filesystem?)
- Issue does not occur when using docker volumes
- Seems related to #267
Here is the error message:
ERR! sharp EPERM: operation not permitted, link '/srv/app/node_modules/sharp/vendor/8.10.0/include/pnglibconf.h' -> '/srv/app/node_modules/sharp/vendor/8.10.0/include/libpng16/pnglibconf.h'
Full error message:
strapi_1 | error /srv/app/node_modules/sharp: Command failed.
strapi_1 | Exit code: 1
strapi_1 | Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
strapi_1 | Arguments:
strapi_1 | Directory: /srv/app/node_modules/sharp
strapi_1 | Output:
strapi_1 | info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.0/libvips-8.10.0-linux-x64.tar.br
strapi_1 | ERR! sharp EPERM: operation not permitted, link '/srv/app/node_modules/sharp/vendor/8.10.0/include/pnglibconf.h' -> '/srv/app/node_modules/sharp/vendor/8.10.0/include/libpng16/pnglibconf.h'
strapi_1 | info sharp Attempting to build from source via node-gyp but this may fail due to the above error
strapi_1 | info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
strapi_1 | gyp info it worked if it ends with ok
strapi_1 | gyp info using [email protected]
strapi_1 | gyp info using [email protected] | linux | x64
strapi_1 | gyp info find Python using Python version 2.7.13 found at "/usr/bin/python"
strapi_1 | gyp http GET https://nodejs.org/download/release/v12.20.1/node-v12.20.1-headers.tar.gz
strapi_1 | gyp http 200 https://nodejs.org/download/release/v12.20.1/node-v12.20.1-headers.tar.gz
strapi_1 | gyp http GET https://nodejs.org/download/release/v12.20.1/SHASUMS256.txt
strapi_1 | gyp http 200 https://nodejs.org/download/release/v12.20.1/SHASUMS256.txt
strapi_1 | gyp info spawn /usr/bin/python
strapi_1 | gyp info spawn args [
strapi_1 | gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
strapi_1 | gyp info spawn args 'binding.gyp',
strapi_1 | gyp info spawn args '-f',
strapi_1 | gyp info spawn args 'make',
strapi_1 | gyp info spawn args '-I',
strapi_1 | gyp info spawn args '/srv/app/node_modules/sharp/build/config.gypi',
strapi_1 | gyp info spawn args '-I',
strapi_1 | gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
strapi_1 | gyp info spawn args '-I',
strapi_1 | gyp info spawn args '/root/.cache/node-gyp/12.20.1/include/node/common.gypi',
strapi_1 | gyp info spawn args '-Dlibrary=shared_library',
strapi_1 | gyp info spawn args '-Dvisibility=default',
strapi_1 | gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/12.20.1',
strapi_1 | gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
strapi_1 | gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/12.20.1/<(target_arch)/node.lib',
strapi_1 | gyp info spawn args '-Dmodule_root_dir=/srv/app/node_modules/sharp',
strapi_1 | gyp info spawn args '-Dnode_engine=v8',
strapi_1 | gyp info spawn args '--depth=.',
strapi_1 | gyp info spawn args '--no-parallel',
strapi_1 | gyp info spawn args '--generator-output',
strapi_1 | gyp info spawn args 'build',
strapi_1 | gyp info spawn args '-Goutput_dir=.'
strapi_1 | gyp info spawn args ]
strapi_1 | gyp info spawn make
strapi_1 | gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
strapi_1 | make: Entering directory '/srv/app/node_modules/sharp/build'
strapi_1 | CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
strapi_1 | AR(target) Release/obj.target/../node-addon-api/nothing.a
strapi_1 | COPY Release/nothing.a
strapi_1 | TOUCH Release/obj.target/libvips-cpp.stamp
strapi_1 | CXX(target) Release/obj.target/sharp/src/common.o
strapi_1 | ../src/common.cc:24:22: fatal error: vips/vips8: No such file or directory
strapi_1 | #include <vips/vips8>
strapi_1 | ^
strapi_1 | compilation terminated.
strapi_1 | make: *** [Release/obj.target/sharp/src/common.o] Error 1
strapi_1 | sharp.target.mk:139: recipe for target 'Release/obj.target/sharp/src/common.o' failed
strapi_1 | make: Leaving directory '/srv/app/node_modules/sharp/build'
strapi_1 | gyp ERR! build error
strapi_1 | gyp ERR! stack Error: `make` failed with exit code: 2
strapi_1 | gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
strapi_1 | gyp ERR! stack at ChildProcess.emit (events.js:314:20)
strapi_1 | gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
strapi_1 | gyp ERR! System Linux 4.14.154-boot2docker
strapi_1 | gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
strapi_1 | gyp ERR! cwd /srv/app/node_modules/sharp
strapi_1 | gyp ERR! node -v v12.20.1
strapi_1 | gyp ERR! node-gyp -v v5.1.0
strapi_1 | gyp ERR! not ok
strapi_1 |
strapi_1 | Keep trying!
strapi_1 |
strapi_1 | Oh, it seems that you encountered errors while installing dependencies in your project.
strapi_1 | Don't give up, your project was created correctly.
strapi_1 | Fix the issues mentionned in the installation errors and try to run the following command:
strapi_1 |
strapi_1 | cd /srv/app && yarn install
strapi_1 |
strapi_strapi_1 exited with code 1
Steps to reproduce the behavior
- Using the above
docker-compose.yaml
Expected behavior
Previously the build succeeded here.
Screenshots
N/A
Code snippets
See "Additional Context" at the end
System
- Node.js version: Using
strapi/strapi
so same version as that (unsure). Local system is running Nodev12.18.3
- NPM version: Using
strapi/strapi
so same version as that (unsure). Local system is running npmv6.14.6
- Strapi version: 3.4.2 -- actually all versions I tested, even ones previously working (
3.1.5
) - Database: MariaDB
- Operating system: OSX Catalina latest updates
Additional context
- The version pulled is
3.4.2
-
docker-compose.yaml
file:
version: '3'
services:
strapi:
image: strapi/strapi
volumes:
- ./app:/srv/app
ports:
- '1337:1337'
-
package.json
fromstrapi/strapi
:
{
"name": "app",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"devDependencies": {},
"dependencies": {
"strapi": "3.4.2",
"strapi-admin": "3.4.2",
"strapi-utils": "3.4.2",
"strapi-plugin-content-type-builder": "3.4.2",
"strapi-plugin-content-manager": "3.4.2",
"strapi-plugin-users-permissions": "3.4.2",
"strapi-plugin-email": "3.4.2",
"strapi-plugin-upload": "3.4.2",
"strapi-connector-bookshelf": "3.4.2",
"knex": "<0.20.0",
"sqlite3": "latest"
},
"author": {
"name": "A Strapi developer"
},
"strapi": {
"uuid": "1bb363b8-d150-460c-8d12-1e460b84ca56"
},
"engines": {
"node": ">=10.16.0 <=14.x.x",
"npm": ">=6.0.0"
},
"license": "MIT"
}
Cause
The original issue is regarding Docker Machine:
- Summary:
- In Linux and OSX running Docker in VirtualBox (
docker-machine
), using shared folders utilissvboxfs
. But that has a limitation that doesn’t allow creation of hard links. - Such hard link creation is required by
sharp
now while buildingstrapi
, which meansdocker-machine
running in Linux or OSX attaching shared folders to the container won't build successfully.
- In Linux and OSX running Docker in VirtualBox (
- Supporting links:
- https://github.com/docker/machine/issues/1876
- https://www.virtualbox.org/ticket/818
- https://www.virtualbox.org/ticket/818
- https://forums.virtualbox.org/viewtopic.php?f=3&t=47014
- https://github.com/nightlyone/lockfile/issues/22
Resolution
None, this is a limitation of vboxfs
Alternatively, I decided to:
- Use one
docker-compose.yaml
file to create the container using Docker volumes - After the build succeeds, then mount the files needed into the Docker volume
This is simply what I could gather. If anyone else can reproduce it to confirm, this would make it clear what kind of environments/workflows won't work with dependencies that Strapi uses.
Hi @virgil9306 thank you for all those details. Doesn't look like we can do much for now. Let me know if you find anything we can do on our side
Hi @alexandrebodin
I am not sure why I did not encounter this error before, so the only thing I can imagine is the dependency sharp
changed.
If someone else using Linux or OSX and docker-machine
using shared folders when building, or even an empty container trying to create a hard link in a shared folder, can reproduce this, it will help to confirm this issue. If confirmed maybe the most we can do is warn people about the limitation.
Perhaps others will encounter this issue as well, but maybe we can close this issue since it's not really fixable.
I have edited the original post and summarised the issue.
I ran into this problem and after trying to work through it for a couple days I ended up fixing it/avoiding it by creating a new container and volume, resetting my docker to factory settings (maybe unnecessary), adding libvips as a dependency, and rebuilding. I think the error is on sharps end honestly but I truly have no idea.
The issue first popped up for me when I tried to develop on my Mac (not M1; which some threads were suggesting) after previously working on WSL2. The issue seemed to point to a bad link between sharp and libvips.
A lot of threads I was finding on this suggest using npm install --ignore-scripts=false --verbose
but this didn't fix the issue for me.
No clue if this will help anyone but hopefully it'll give some more context to anyone in need.
Thanks @Kyle772! I can confirm that this problem exists, happens to me as well. Haven't tried your solution yet though.
Same issue here. macOS Catalina (latest) followed this guide: https://strapi.io/blog/how-to-run-a-strapi-dev-stack-with-docker-compose
Windows 10, WSL 2, docker I have the same issue with sharp. Is anybody know how to fix it?
Yesterday I'm removing all images from docker and start building again - all is work ! (windows 10, wsl2)