I have Gridsome application/website that I would like to create Docker image for CI/CD however when try to build docker image I am facing error with sharp library that is one of dependencies of Gridsome:
my package.json is (dependencies):
"dependencies": {
"@vue-hero-icons/outline": "^1.7.2",
"gridsome": "^0.7.23",
"slugify": "^1.6.5",
"vue-carousel": "^0.18.0",
"vue-click-outside": "^1.1.0"
},
"devDependencies": {
"autoprefixer": "^9",
"axios": "^0.24.0",
"postcss": "^7",
"tailwindcss": "npm:@tailwindcss/postcss7-compat"
}
Dockerfile
FROM node:16-alpine
# Install build tools
RUN apk update && apk upgrade
RUN apk --no-cache add --virtual util-linux git\
g++ gcc libgcc libstdc++ linux-headers make python3
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/
RUN yarn --frozen-lockfile
COPY . /usr/src/app/
CMD [ "yarn", "build" ]
Error stack I faced is:
#10 50.78 [4/4] Building fresh packages...
#10 55.18 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
#10 55.18 error /usr/src/app/node_modules/sharp: Command failed.
#10 55.18 Exit code: 1
#10 55.18 Command: (node install/libvips && node install/dll-copy && prebuild-install --runtime=napi) || (node-gyp rebuild && node install/dll-copy)
#10 55.18 Arguments:
#10 55.18 Directory: /usr/src/app/node_modules/sharp
#10 55.18 Output:
#10 55.18 info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.9.1/libvips-8.9.1-linuxmusl-arm64v8.tar.gz
#10 55.18 ERR! sharp Prebuilt libvips 8.9.1 binaries are not yet available for linuxmusl-arm64v8
#10 55.18 info sharp Attempting to build from source via node-gyp but this may fail due to the above error
#10 55.18 info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
#10 55.18 gyp info it worked if it ends with ok
#10 55.18 gyp info using node-gyp@8.3.0
#10 55.18 gyp info using node@16.13.2 | linux | arm64
#10 55.18 gyp info find Python using Python version 3.9.7 found at "/usr/bin/python3"
#10 55.18 gyp http GET https://nodejs.org/download/release/v16.13.2/node-v16.13.2-headers.tar.gz
#10 55.18 gyp http 200 https://nodejs.org/download/release/v16.13.2/node-v16.13.2-headers.tar.gz
#10 55.18 gyp http GET https://nodejs.org/download/release/v16.13.2/SHASUMS256.txt
#10 55.18 gyp http 200 https://nodejs.org/download/release/v16.13.2/SHASUMS256.txt
#10 55.18 gyp info spawn /usr/bin/python3
#10 55.18 gyp info spawn args [
#10 55.18 gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
#10 55.18 gyp info spawn args 'binding.gyp',
#10 55.18 gyp info spawn args '-f',
#10 55.18 gyp info spawn args 'make',
#10 55.18 gyp info spawn args '-I',
#10 55.18 gyp info spawn args '/usr/src/app/node_modules/sharp/build/config.gypi',
#10 55.18 gyp info spawn args '-I',
#10 55.18 gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
#10 55.18 gyp info spawn args '-I',
#10 55.18 gyp info spawn args '/root/.cache/node-gyp/16.13.2/include/node/common.gypi',
#10 55.18 gyp info spawn args '-Dlibrary=shared_library',
#10 55.18 gyp info spawn args '-Dvisibility=default',
#10 55.18 gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/16.13.2',
#10 55.18 gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
#10 55.18 gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/16.13.2/<(target_arch)/node.lib',
#10 55.18 gyp info spawn args '-Dmodule_root_dir=/usr/src/app/node_modules/sharp',
#10 55.18 gyp info spawn args '-Dnode_engine=v8',
#10 55.18 gyp info spawn args '--depth=.',
#10 55.18 gyp info spawn args '--no-parallel',
#10 55.18 gyp info spawn args '--generator-output',
#10 55.18 gyp info spawn args 'build',
#10 55.18 gyp info spawn args '-Goutput_dir=.'
#10 55.18 gyp info spawn args ]
#10 55.18 gyp info spawn make
#10 55.18 gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
#10 55.18 make: Entering directory '/usr/src/app/node_modules/sharp/build'
#10 55.18 CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
#10 55.18 AR(target) Release/obj.target/../node-addon-api/nothing.a
#10 55.18 COPY Release/nothing.a
#10 55.18 TOUCH Release/obj.target/libvips-cpp.stamp
#10 55.18 CXX(target) Release/obj.target/sharp/src/common.o
#10 55.18 <command-line>: warning: "_GLIBCXX_USE_CXX11_ABI" redefined
#10 55.18 <command-line>: note: this is the location of the previous definition
#10 55.18 ../src/common.cc:23:10: fatal error: vips/vips8: No such file or directory
#10 55.18 23 | #include <vips/vips8>
#10 55.18 | ^~~~~~~~~~~~
#10 55.18 compilation terminated.
#10 55.18 make: *** [sharp.target.mk:139: Release/obj.target/sharp/src/common.o] Error 1
#10 55.18 make: Leaving directory '/usr/src/app/node_modules/sharp/build'
#10 55.18 gyp ERR! build error
#10 55.18 gyp ERR! stack Error: `make` failed with exit code: 2
#10 55.18 gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
#10 55.18 gyp ERR! stack at ChildProcess.emit (node:events:390:28)
#10 55.18 gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
#10 55.18 gyp ERR! System Linux 5.10.76-linuxkit
#10 55.18 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
#10 55.18 gyp ERR! cwd /usr/src/app/node_modules/sharp
#10 55.18 gyp ERR! node -v v16.13.2
#10 55.18 gyp ERR! node-gyp -v v8.3.0
#10 55.18 gyp ERR! not ok
------
executor failed running [/bin/sh -c yarn]: exit code: 1
what binaries I can miss? When try to add linuxmusl
I am getting error:
#6 9.736 ERROR: unable to select packages:
#6 9.770 linuxmusl (no such package):
#6 9.770 required by: util-linux-20220128.000039[linuxmusl]
Is it different image base should be used? If yes - with one? Keep in mind that Gridsome should works with yarn