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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/BestPractices.md
Expand Up @@ -10,6 +10,7 @@
- [CMD](#cmd)
- [Docker Run](#docker-run)
- [Security](#security)
- [node-gyp in apline variant](#node-gyp-alpine)

## Environment Variables

Expand Down Expand Up @@ -153,3 +154,30 @@ $ docker run \
## Security

The Docker team has provided a tool to analyze your running containers for potential security issues. You can download and run this tool from here: https://github.com/docker/docker-bench-security

## node-gyp alpine

Here is an example of how you would install dependencies for packages that require node-gyp support on the alpine variant:

```Dockerfile
FROM node:alpine

RUN apk add --no-cache --virtual .gyp python make g++ \
dcohenb marked this conversation as resolved.
Show resolved Hide resolved
&& npm install [ your npm dependencies here ] \
&& apk del .gyp
```

And Here's a multistage build example

```Dockerfile
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++ \
RUN 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 .
```