Skip to content

Commit 05cebb2

Browse files
committed
Remove nodejs autoinstrumentation dev dependencies from image
The autoinstrumentation has several build-time dependencies which aren't necessary for the final image, like typescript. Comparison of builds without typescript, typescript + rimraf, and finally all dev dependencies: ``` $ docker image ls --format 'table {{.Repository}} {{.Tag}} {{.Size}}' autoinstrumentation-nodejs 60d37e1 272MB autoinstrumentation-nodejs no-ts 208MB autoinstrumentation-nodejs no-ts-rmrf 201MB autoinstrumentation-nodejs no-dev 200MB ``` We extend the existing `postcompile` script. After building into `build/workspace`, we `prune` to remove extraneous packages. Doing that requires the `package.json` in the build directory.
1 parent 60d37e1 commit 05cebb2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.chloggen/js-build-remove-dev.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: auto-instrumentation
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: "Remove NodeJS autoinstrumentation dev dependencies to reduce image size"
9+
10+
# One or more tracking issues related to the change
11+
issues: [2802]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

autoinstrumentation/nodejs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"clean": "rimraf build/*",
77
"prepare": "npm run compile",
88
"compile": "tsc -p .",
9-
"postcompile": "copyfiles -f 'build/src/**' build/workspace/ && copyfiles 'node_modules/**' build/workspace/"
9+
"postcompile": "copyfiles -f 'build/src/**' build/workspace/ && copyfiles 'node_modules/**' package.json build/workspace/ && npm -C build/workspace prune --omit=dev --no-package-lock"
1010
},
1111
"devDependencies": {
1212
"copyfiles": "^2.4.1",

0 commit comments

Comments
 (0)