-
Notifications
You must be signed in to change notification settings - Fork 608
Expand file tree
/
Copy pathDockerfile
More file actions
29 lines (23 loc) · 1.67 KB
/
Dockerfile
File metadata and controls
29 lines (23 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# To build one auto-instrumentation image for Node.js, please:
# - Ensure the packages are installed in the `/autoinstrumentation` directory. This is required as when instrumenting the pod,
# one init container will be created to copy all the content in `/autoinstrumentation` directory to your app's container. Then
# update the `NODE_OPTIONS` environment variable accordingly. To achieve this, you can mimic the one in `autoinstrumentation/nodejs/Dockerfile`
# by using multi-stage builds. In the first stage, install all the required packages in one custom directory.
# Then in the second stage, copy the directory to `/autoinstrumentation`.
# - Ensure you have `@opentelemetry/api`, `@opentelemetry/auto-instrumentations-node`, and `@opentelemetry/sdk-node` or your customized
# alternatives installed.
# - Grant the necessary access to `/autoinstrumentation` directory. `chmod -R go+r /autoinstrumentation`
# - For auto-instrumentation by container injection, the Linux command cp is
# used and must be available in the image.
# - By default a file named autoinstrumentation.js is loaded using `require`, but the UseImport configuration option
# overrides this default behaviour and loads it autoinstrumentation.mjs using `import`.
FROM node:20 AS build
WORKDIR /operator-build
COPY . .
RUN npm install
FROM busybox
COPY --from=build /operator-build/build/workspace /autoinstrumentation
RUN chmod -R go+r /autoinstrumentation
# Backward compatibility with old operator version
RUN cp -r /autoinstrumentation/node_modules/@opentelemetry/auto-instrumentations-node/build/src/. /autoinstrumentation
RUN ln /autoinstrumentation/register.js /autoinstrumentation/autoinstrumentation.js