Closed ausir0726 closed 6 months ago
Libvips should be installed for sharp to work. Are you using a docker-compose file and bind mounting node_modules etc, if you have a docker-compose file can you share it please.
here is my docker-compose file and dockerfile when I remove install vips-dev , it's work fine.
docker-compse.yml
version: '3'
services:
weitech:
container_name: weitech
build:
context: .
dockerfile: Dockerfile
image: weitech:latest
restart: unless-stopped
env_file: .env
environment:
DATABASE_CLIENT: ${DATABASE_CLIENT}
DATABASE_HOST: weitechDB
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USERNAME: ${DATABASE_USERNAME}
DATABASE_PORT: ${DATABASE_PORT}
JWT_SECRET: ${JWT_SECRET}
ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
NODE_ENV: ${NODE_ENV}
volumes:
- ./config:/opt/app/config
- ./src:/opt/app/src
- ./package.json:/opt/package.json
- ./yarn.lock:/opt/yarn.lock
- ./.env:/opt/app/.env
- ./public/uploads:/opt/app/public/uploads
ports:
- '1337:1337'
networks:
- weitech
depends_on:
- weitechDB
weitechDB:
container_name: weitechDB
platform: linux/amd64 #for platform error on Apple M1 chips
restart: unless-stopped
env_file: .env
image: postgres:14.5-alpine
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- weitech-data:/var/lib/postgresql/data/ #using a volume
#- ./data:/var/lib/postgresql/data/ # if you want to use a bind folder
ports:
- '5432:5432'
networks:
- weitech
weitechAdminer:
container_name: weitechAdminer
image: adminer
restart: unless-stopped
ports:
- '9090:8080'
environment:
- ADMINER_DEFAULT_SERVER=weitechDB
networks:
- weitech
depends_on:
- weitechDB
volumes:
weitech-data:
networks:
weitech:
name: Weitech
driver: bridge
Dockerfile
FROM node:18-alpine
# Installing libvips-dev for sharp Compatibility
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev nasm bash vips-dev
ARG NODE_ENV=development
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/
COPY package.json yarn.lock ./
RUN yarn config set network-timeout 600000 -g && yarn install
WORKDIR /opt/app
COPY . .
ENV PATH /opt/node_modules/.bin:$PATH
RUN chown -R node:node /opt/app
USER node
RUN ["yarn", "build"]
EXPOSE 1337
CMD ["yarn", "develop"]
Same issue here. Dockerfile and docker-compose are generated by the tool. Removing vips-dev
from apk add line solves the problem. Is this needed?
My build also fails since a few weeks (on the same commit which worked earlier) with sharp-related issue:
#14 54.35 [5/5] Building fresh packages... #14 67.67 error /opt/node_modules/sharp: Command failed. #14 67.67 Exit code: 1 #14 67.67 Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy) #14 67.67 Arguments: #14 67.67 Directory: /opt/node_modules/sharp #14 67.67 Output: #14 67.67 sharp: Detected globally-installed libvips v8.15.0 #14 67.67 sharp: Building from source via node-gyp #14 67.67 gyp info it worked if it ends with ok #14 67.67 gyp info using node-gyp@10.0.1 #14 67.67 gyp info using node@18.19.0 | linux | x64 #14 67.67 gyp info find Python using Python version 3.11.6 found at "/usr/bin/python3" #14 67.67 #14 67.67 gyp http GET https://unofficial-builds.nodejs.org/download/release/v18.19.0/node-v18.19.0-headers.tar.gz #14 67.67 gyp http 200 https://unofficial-builds.nodejs.org/download/release/v18.19.0/node-v18.19.0-headers.tar.gz #14 67.67 gyp http GET https://unofficial-builds.nodejs.org/download/release/v18.19.0/SHASUMS256.txt #14 67.67 gyp http 200 https://unofficial-builds.nodejs.org/download/release/v18.19.0/SHASUMS256.txt #14 67.67 gyp info spawn /usr/bin/python3 #14 67.67 gyp info spawn args [ #14 67.67 gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', #14 67.67 gyp info spawn args 'binding.gyp', #14 67.67 gyp info spawn args '-f', #14 67.67 gyp info spawn args 'make', #14 67.67 gyp info spawn args '-I', #14 67.67 gyp info spawn args '/opt/node_modules/sharp/build/config.gypi', #14 67.67 gyp info spawn args '-I', #14 67.67 gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', #14 67.67 gyp info spawn args '-I', #14 67.67 gyp info spawn args '/root/.cache/node-gyp/18.19.0/include/node/common.gypi', #14 67.67 gyp info spawn args '-Dlibrary=shared_library', #14 67.67 gyp info spawn args '-Dvisibility=default', #14 67.67 gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/18.19.0', #14 67.67 gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp', #14 67.67 gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/18.19.0/<(target_arch)/node.lib', #14 67.67 gyp info spawn args '-Dmodule_root_dir=/opt/node_modules/sharp', #14 67.67 gyp info spawn args '-Dnode_engine=v8', #14 67.67 gyp info spawn args '--depth=.', #14 67.67 gyp info spawn args '--no-parallel', #14 67.67 gyp info spawn args '--generator-output', #14 67.67 gyp info spawn args 'build', #14 67.67 gyp info spawn args '-Goutput_dir=.' #14 67.67 gyp info spawn args ] #14 67.67 gyp info spawn make #14 67.67 gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] #14 67.67 make: Entering directory '/opt/node_modules/sharp/build' #14 67.67 CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o #14 67.67 rm -f Release/obj.target/../node-addon-api/nothing.a Release/obj.target/../node-addon-api/nothing.a.ar-file-list; mkdir -p `dirname Release/obj.target/../node-addon-api/nothing.a` #14 67.67 ar crs Release/obj.target/../node-addon-api/nothing.a @Release/obj.target/../node-addon-api/nothing.a.ar-file-list #14 67.67 COPY Release/nothing.a #14 67.67 TOUCH Release/obj.target/libvips-cpp.stamp #14 67.67 CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/common.o #14 67.67 CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/metadata.o #14 67.67 CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/stats.o #14 67.67 CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/operations.o #14 67.67 CXX(target) Release/obj.target/sharp-linuxmusl-x64/src/pipeline.o #14 67.67 ../src/pipeline.cc: In member function 'virtual void PipelineWorker::OnOK()': #14 67.67 ../src/pipeline.cc:1230:30: error: aggregate 'PipelineWorker::OnOK()::stat64 st' has incomplete type and cannot be defined #14 67.67 1230 | struct STAT64_STRUCT st; #14 67.67 | ^~ #14 67.67 ../src/pipeline.cc:1231:55: error: invalid use of incomplete type 'struct PipelineWorker::OnOK()::stat64' #14 67.67 1231 | if (STAT64_FUNCTION(baton->fileOut.data(), &st) == 0) { #14 67.67 | ^ #14 67.67 ../src/pipeline.cc:33:23: note: forward declaration of 'struct PipelineWorker::OnOK()::stat64' #14 67.67 33 | #define STAT64_STRUCT stat64 #14 67.67 | ^~~~~~ #14 67.67 ../src/pipeline.cc:1230:16: note: in expansion of macro 'STAT64_STRUCT' #14 67.67 1230 | struct STAT64_STRUCT st; #14 67.67 | ^~~~~~~~~~~~~ #14 67.67 make: *** [sharp-linuxmusl-x64.target.mk:167: Release/obj.target/sharp-linuxmusl-x64/src/pipeline.o] Error 1 #14 67.67 make: Leaving directory '/opt/node_modules/sharp/build' #14 67.67 gyp ERR! build error #14 67.67 gyp ERR! stack Error: `make` failed with exit code: 2 #14 67.67 gyp ERR! stack at ChildProcess.(/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23) #14 67.67 gyp ERR! System Linux 5.4.109+ #14 67.67 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" #14 67.67 gyp ERR! cwd /opt/node_modules/sharp #14 67.67 gyp ERR! node -v v18.19.0 #14 67.67 gyp ERR! node-gyp -v v10.0.1 #14 67.67 gyp ERR! not ok #14 67.68 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. #14 ERROR: process "/bin/sh -c yarn config set network-timeout 600000 -g && yarn install --production" did not complete successfully: exit code: 1 ------ > [build 5/8] RUN yarn config set network-timeout 600000 -g && yarn install --production: 67.67 gyp ERR! build error 67.67 gyp ERR! stack Error: `make` failed with exit code: 2 67.67 gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23) 67.67 gyp ERR! System Linux 5.4.109+ 67.67 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 67.67 gyp ERR! cwd /opt/node_modules/sharp 67.67 gyp ERR! node -v v18.19.0 67.67 gyp ERR! node-gyp -v v10.0.1 67.67 gyp ERR! not ok 67.68 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. ------ Dockerfile.prod:9 -------------------- 7 | WORKDIR /opt/ 8 | COPY package.json yarn.lock ./ 9 | >>> RUN yarn config set network-timeout 600000 -g && yarn install --production 10 | ENV PATH /opt/node_modules/.bin:$PATH 11 | WORKDIR /opt/app -------------------- error: failed to solve: process "/bin/sh -c yarn config set network-timeout 600000 -g && yarn install --production" did not complete successfully: exit code: 1
Fixed it - I think by updating npm dependencies (i.e. strapi)
🐛 Bug Report
seems like have some issue with libvips when install sharp.
🤷♀️ What did you do
execute
docker compose up --build
⛔️ Error log
🙇♀️ Expected behavior/code
A clear and concise description of what you expected to happen (or code).
👩💻 Environment
💡 Possible Solution
remove vips-dev on Dockfile and Dockerfile.prod