Mirror of https://github.com/roostorg/coop
github.com/roostorg/coop
1# To build one auto-instrumentation image for Node.js, please:
2# - Ensure the packages are installed in the `/autoinstrumentation` directory. This is required as when instrumenting the pod,
3# one init container will be created to copy all the content in `/autoinstrumentation` directory to your app's container. Then
4# update the `NODE_OPTIONS` environment variable accordingly. To achieve this, you can mimic the one in `autoinstrumentation/nodejs/Dockerfile`
5# by using multi-stage builds. In the first stage, install all the required packages in one custom directory.
6# Then in the second stage, copy the directory to `/autoinstrumentation`.
7# - Ensure you have `@opentelemetry/api`, `@opentelemetry/auto-instrumentations-node`, and `@opentelemetry/sdk-node` or your customized
8# alternatives installed.
9# - Grant the necessary access to `/autoinstrumentation` directory. `chmod -R go+r /autoinstrumentation`
10# - For auto-instrumentation by container injection, the Linux command cp is
11# used and must be availabe in the image.
12FROM node:24.14.1 AS build
13
14WORKDIR /operator-build
15
16COPY package*.json .
17
18RUN --mount=type=cache,target=/root/.npm npm ci --prefer-offline
19
20COPY . .
21
22RUN npm run build
23
24RUN npm prune --omit=dev
25
26FROM busybox:1.37.0
27
28COPY --from=build /operator-build/node_modules /autoinstrumentation/node_modules
29COPY --from=build /operator-build/transpiled/ /autoinstrumentation
30
31RUN chmod -R go+r /autoinstrumentation
32
33# RUN adduser -D -u 1001 coop
34# RUN chown -R coop:coop /autoinstrumentation
35
36# USER 1001