Skip to content
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

Adds documentation for using node-gyp in alpine release #907

Merged
merged 2 commits into from Dec 2, 2018
Merged

Adds documentation for using node-gyp in alpine release #907

merged 2 commits into from Dec 2, 2018

Conversation

dcohenb
Copy link
Contributor

@dcohenb dcohenb commented Nov 14, 2018

Continuing the conversation on:
#282

This PR adds code sample to the docs on how to use node-gyp dependencies on the alpine variant

@LaurentGoderre
Copy link
Member

@dcohenb could you have an example also with multi-stage build?

@NicholasGWK
Copy link

NicholasGWK commented Nov 27, 2018

Here's a multistage example if I understand things correctly!

FROM node:alpine as builder

## Install build toolchain, install node deps and compile native add-ons
RUN apk add --no-cache --virtual .gyp python make g++ \
    && npm install [ your npm dependencies here ] 

FROM node:alpine as app

## Copy built node modules and binaries without including the toolchain
COPY --from=builder node_modules .

@dcohenb
Copy link
Contributor Author

dcohenb commented Dec 1, 2018

Updated with @NicholasGWK example
thanks!

docs/BestPractices.md Outdated Show resolved Hide resolved
@SimenB SimenB merged commit 7db40ed into nodejs:master Dec 2, 2018
@SimenB
Copy link
Member

SimenB commented Dec 2, 2018

Thanks!

@dcohenb dcohenb deleted the alpine-node-gyp-docs branch December 2, 2018 10:46
@moltar
Copy link

moltar commented May 11, 2019

This no longer seems to work. Fails with a huge error dump.

FROM node:alpine

RUN  apk update \
  && apk upgrade \
  && apk --no-cache --virtual build-dependencies add \
    python make g++ \
  && npm install -g --unsafe pty.js \
  && apk del build-dependencies

@moltar
Copy link

moltar commented May 11, 2019

A modified example from the docs fails differently:

FROM node:alpine

RUN apk add --no-cache --virtual .gyp python make g++ \
  && npm install -g pty.js \
  && apk del .gyp
gyp WARN EACCES user "undefined" does not have permission to access the dev dir "/root/.node-gyp/12.2.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/pty.js/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install

@dcohenb
Copy link
Contributor Author

dcohenb commented May 12, 2019

@moltar this is due to a new change in the base alpine image removing the default root user from base alpine image
you can read more about it here:
https://threatpost.com/alpine-linux-docker-images-unlocked/144542/
And here:
https://git.alpinelinux.org/aports/commit/?id=7a2566ec8260ceacae81088ebe2ffe6526c3809e

I'm looking into a solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants