-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Document how to use alpine with dependencies that rely on node-gyp #282
Comments
How could one do this with dockers multi-stage builds instead? The above approach requires everything to be done in one run command after the app has been copied in in an earlier layer. This means the |
We should definitely have examples with multi-stage builds as well |
@dan-turner this issues pre-dates the multi stages build. We should have examples of multi stage build including how to use node-gyp. |
@SimenB @LaurentGoderre no problem! Sorry I didn’t mean to sound ungrateful, I ended using the above example today because it worked perfectly :) I had a crack at trying to work out how to do it with multi-stage builds myself but it’s beyond my expertise I’m afraid. |
Had the same issue today. Here is simplified multi-stage build example: FROM node:8-alpine AS assets
WORKDIR /app
# Install yarn and other dependencies via apk
RUN apk update && apk add yarn python g++ make && rm -rf /var/cache/apk/*
# Install node dependencies - done in a separate step so Docker can cache it.
COPY package.json yarn.lock /app/
RUN yarn install --frozen-lockfile
# Copy project files into the docker image
COPY . /app/
# Build something. Let's assume that it outputs into /app/dist/
RUN yarn build:prod
# Build an python app (or something else) and copy from the previous stage
FROM python:3.6.3
# ...
COPY --from=assets /app/dist/ /app/dist/
# ... |
I found this very helpful: https://github.com/gliderlabs/docker-alpine/blob/master/docs/usage.md My
Using |
@sepastian the multi-stage build allows for even smaller image by running a different image for building and for running so you don't inherit all the build dependencies in your runtime image. |
we are almost in 2019 and it's still not documented :-/ |
@bishoymelek it's an open source project and you can help improve it. Don't hesitate to take the lead and update the documentation 😉 |
Hey y'all! Would this be a good candidate for the label "good first issue"? Seems like the majority of the code content needed is in the OP. |
@bnb yeah! |
Is this still the correct work around for node on alpine 12.6? Am I correct that the following block replaces "RUN npm install"?
|
@sepastian works for me, but aren't you getting these warnings: I'm going to have to mix your suggestion and the ones in that thread... |
Running |
I managed to fix the error with I had to follow the errors and add the packages |
I just tried to use the command: apk --no-cache --virtual build-dependencies add \ python \ make \ g++ \ && npm i n8n-nodes-dnc-suitecrm --unsafe-perm \ && apk del build-dependencies and got this: ERROR: ' python' is not a valid child dependency, format is name([<>~=]version) maybe the pr from @xmflsct is the thing to go with? |
I believe these instructions worked for the original version of Alpine we supported but newer versions might need a different set of dependencies. |
@alexhammerschmied Have you found a fix for this issue? I've the same problem on one build right now. |
Anyone can share a working solution for this, please? I am using node14 and keep getting python error. |
When using alpine, you need to install build dependencies for some node module to be able to be built natively. It should probably be documented
The text was updated successfully, but these errors were encountered: