a year ago
Hey y'all, I'm trying to build a react app but I'm not able to install node-gyp for some reason. I saw there's responses about using Nix, but I'd rather use Docker.
I've tried a bunch of different apk scripts but still no luck. I've also tried using different node versions, any ideas?
Dockerfile:
FROM node:lts-alpine3.17 AS builder
# Install dependencies including Python
RUN apk add --no-cache python3 py3-pip make g++ \
&& ln -sf python3 /usr/bin/python \
&& ln -sf pip3 /usr/bin/pip
# set the working directory
WORKDIR /app
# copy the package.json and package-lock.json files
COPY package.json .
COPY package-lock.json .
# install the dependencies
RUN npm ci
# copy the rest of the files
COPY . .
# build the app
RUN npm run build
# set the command to run the app
CMD ["npm", "run", "start"]Error
#10 44.93 npm ERR! code 1
#10 44.93 npm ERR! path /app/node_modules/usb
#10 44.93 npm ERR! command failed
#10 44.93 npm ERR! command sh -c node-gyp-build
#10 44.93 npm ERR! make: Entering directory '/app/node_modules/usb/build'
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/core.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/io.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/events_posix.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o
#10 44.94 npm ERR! make: Leaving directory '/app/node_modules/usb/build'
#10 44.94 npm ERR! gyp info it worked if it ends with ok
#10 44.94 npm ERR! gyp info using node-gyp@10.2.0
#10 44.94 npm ERR! gyp info using node@20.10.0 | linux | x64
#10 44.94 npm ERR! gyp info find Python using Python version 3.10.15 found at "/usr/bin/python3"
#10 44.94 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
#10 44.94 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz
#10 44.94 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v20.10.0/SHASUMS256.txt
#10 44.94 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v20.10.0/SHASUMS256.txt13 Replies
I was able to build it using a full image, as the alpine builds are lightweight:
https://github.com/nodejs/docker-node/issues/384
It's a workaround but still curious how I'd do this manually through an alpine image
a year ago
why does the react app need node-gyp?
a year ago
what is your start script?
a year ago
is this some kind of express / frontend jumble?
a year ago
then that seens like a good solution, we don't charge for build or image storage
a year ago
no prblem!