Skip to content

Commit 0f998f1

Browse files
committed
chore: Added documentation for musl libc systems
1 parent 34eff77 commit 0f998f1

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

README.md

+56
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,62 @@ $ npm install @newrelic/native-metrics --build-from-source
4747

4848
For more information, please see the agent [installation guide][install-node] and [compatibility and requirements][compatibility].
4949

50+
### Musl Libc Systems
51+
52+
As noted above, this module ships pre-built binaries for most standard systems,
53+
i.e. systems based on the [GNU C Library](https://en.wikipedia.org/wiki/Glibc).
54+
As of August 2024, Node.js does not provide "official" releases that are based
55+
on [musl libc](https://en.wikipedia.org/wiki/Musl); such builds are only
56+
available via the [unofficial builds](https://github.com/nodejs/unofficial-builds)
57+
project. Therefore, if deploying to musl based systems, e.g. Alpine Linux, you
58+
must provide a [node-gyp](https://github.com/nodejs/node-gyp) compatible build
59+
environment.
60+
61+
As an example, to install and use this module on an Alpine Linux based Docker
62+
image, we can utilize the [multi-stage build](https://docs.docker.com/build/building/multi-stage/)
63+
pattern to build a compatible image:
64+
65+
**package.json**:
66+
```json
67+
{
68+
"dependencies": {
69+
"@newrelic/native-metrics": "^11.0.0"
70+
}
71+
}
72+
```
73+
74+
**index.js**:
75+
```js
76+
'use strict'
77+
78+
const metrics = require('@newrelic/native-metrics')
79+
console.log("gcEnabled:", metrics().gcEnabled)
80+
```
81+
82+
**Dockerfile**:
83+
```Dockerfile
84+
FROM node:20-alpine AS builder
85+
86+
WORKDIR /app
87+
COPY index.js package.json .
88+
89+
RUN apk add g++ make py3-pip
90+
RUN npm install --production
91+
92+
FROM node:20-alpine
93+
COPY --from=builder app/ /app/
94+
WORKDIR /app
95+
CMD node index.js
96+
```
97+
98+
With those files in place, we can build and run the image:
99+
100+
```sh
101+
$ docker build --tag demo .
102+
$ docker run --rm -it demo
103+
gcEnabled: true
104+
```
105+
50106
## Usage
51107

52108
```js

0 commit comments

Comments
 (0)