@@ -3,7 +3,7 @@ FROM $image as builder
33ARG image
44
55# Create the directory structure required for AWS Lambda Layer
6- RUN mkdir -p /nodejs/node_modules/
6+ RUN mkdir -p /opt/ nodejs/node_modules/
77
88# Install dev dependencies
99COPY . datadog-lambda-js
@@ -12,10 +12,10 @@ RUN yarn install
1212
1313# Build the lambda layer
1414RUN yarn build
15- RUN cp -r dist /nodejs/node_modules/datadog-lambda-js
16- RUN cp ./src/runtime/module_importer.js /nodejs/node_modules/datadog-lambda-js/runtime
15+ RUN cp -r dist /opt/ nodejs/node_modules/datadog-lambda-js
16+ RUN cp ./src/runtime/module_importer.js /opt/ nodejs/node_modules/datadog-lambda-js/runtime
1717
18- RUN cp ./src/handler.mjs /nodejs/node_modules/datadog-lambda-js
18+ RUN cp ./src/handler.mjs /opt/ nodejs/node_modules/datadog-lambda-js
1919RUN rm -rf node_modules
2020
2121# Move dd-trace from devDependencies to production dependencies
@@ -25,44 +25,44 @@ RUN mv package-new.json package.json
2525# Install dependencies
2626RUN yarn install --production=true
2727# Copy the dependencies to the modules folder
28- RUN cp -rf node_modules/* /nodejs/node_modules
28+ RUN cp -rf node_modules/* /opt/ nodejs/node_modules
2929
3030# Remove the AWS SDK, which is installed in the lambda by default
31- RUN rm -rf /nodejs/node_modules/aws-sdk
32- RUN rm -rf /nodejs/node_modules/aws-xray-sdk-core/node_modules/aws-sdk
31+ RUN rm -rf /opt/ nodejs/node_modules/aws-sdk
32+ RUN rm -rf /opt/ nodejs/node_modules/aws-xray-sdk-core/node_modules/aws-sdk
3333
3434# Remove heavy files from dd-trace which aren't used in a lambda environment
35- RUN rm -rf /nodejs/node_modules/dd-trace/prebuilds
36- RUN rm -rf /nodejs/node_modules/dd-trace/dist
37- RUN rm -rf /nodejs/node_modules/@datadog/libdatadog
38- RUN rm -rf /nodejs/node_modules/@datadog/native-appsec
39- RUN rm -rf /nodejs/node_modules/@datadog/native-metrics
40- RUN rm -rf /nodejs/node_modules/hdr-histogram-js/build
41- RUN rm -rf /nodejs/node_modules/protobufjs/dist
42- RUN rm -rf /nodejs/node_modules/protobufjs/cli
43- RUN rm -rf /nodejs/node_modules/@datadog/pprof/prebuilds/linux-arm
44- RUN rm -rf /nodejs/node_modules/@datadog/pprof/prebuilds/darwin-arm64
45- RUN rm -rf /nodejs/node_modules/@datadog/pprof/prebuilds/darwin-x64
46- RUN rm -rf /nodejs/node_modules/@datadog/pprof/prebuilds/win32-ia32
47- RUN rm -rf /nodejs/node_modules/@datadog/pprof/prebuilds/win32-x64
48- RUN rm -rf /nodejs/node_modules/@datadog/native-iast-taint-tracking
49- RUN rm -rf /nodejs/node_modules/@datadog/native-iast-rewriter
50- RUN rm -rf /nodejs/node_modules/@datadog/pprof/prebuilds/linuxmusl-x64
51- RUN rm -rf /nodejs/node_modules/jsonpath-plus/src/jsonpath.d.ts
52- RUN rm -rf /nodejs/node_modules/jsonpath-plus/src/jsonpath-browser.js
53- RUN rm -rf /nodejs/node_modules/jsonpath-plus/src/dist/index-browser-umd.min.cjs
54- RUN rm -rf /nodejs/node_modules/jsonpath-plus/src/dist/index-browser-umd.cjs
55- RUN rm -rf /nodejs/node_modules/jsonpath-plus/src/dist/index-browser-esm.min.js
56- RUN rm -rf /nodejs/node_modules/jsonpath-plus/src/dist/index-browser-esm.js
57- RUN find /nodejs/node_modules -name "*.d.ts" -delete
58- RUN find /nodejs/node_modules -name "*.js.map" -delete
59- RUN find /nodejs/node_modules -name "*.mjs.map" -delete
60- RUN find /nodejs/node_modules -name "*.cjs.map" -delete
61- RUN find /nodejs/node_modules -name "*.ts.map" -delete
62- RUN find /nodejs/node_modules -name "*.md" -delete
35+ RUN rm -rf /opt/ nodejs/node_modules/dd-trace/prebuilds
36+ RUN rm -rf /opt/ nodejs/node_modules/dd-trace/dist
37+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/libdatadog
38+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/native-appsec
39+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/native-metrics
40+ RUN rm -rf /opt/ nodejs/node_modules/hdr-histogram-js/build
41+ RUN rm -rf /opt/ nodejs/node_modules/protobufjs/dist
42+ RUN rm -rf /opt/ nodejs/node_modules/protobufjs/cli
43+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/pprof/prebuilds/linux-arm
44+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/pprof/prebuilds/darwin-arm64
45+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/pprof/prebuilds/darwin-x64
46+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/pprof/prebuilds/win32-ia32
47+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/pprof/prebuilds/win32-x64
48+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/native-iast-taint-tracking
49+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/native-iast-rewriter
50+ RUN rm -rf /opt/ nodejs/node_modules/@datadog/pprof/prebuilds/linuxmusl-x64
51+ RUN rm -rf /opt/ nodejs/node_modules/jsonpath-plus/src/jsonpath.d.ts
52+ RUN rm -rf /opt/ nodejs/node_modules/jsonpath-plus/src/jsonpath-browser.js
53+ RUN rm -rf /opt/ nodejs/node_modules/jsonpath-plus/src/dist/index-browser-umd.min.cjs
54+ RUN rm -rf /opt/ nodejs/node_modules/jsonpath-plus/src/dist/index-browser-umd.cjs
55+ RUN rm -rf /opt/ nodejs/node_modules/jsonpath-plus/src/dist/index-browser-esm.min.js
56+ RUN rm -rf /opt/ nodejs/node_modules/jsonpath-plus/src/dist/index-browser-esm.js
57+ RUN find /opt/ nodejs/node_modules -name "*.d.ts" -delete
58+ RUN find /opt/ nodejs/node_modules -name "*.js.map" -delete
59+ RUN find /opt/ nodejs/node_modules -name "*.mjs.map" -delete
60+ RUN find /opt/ nodejs/node_modules -name "*.cjs.map" -delete
61+ RUN find /opt/ nodejs/node_modules -name "*.ts.map" -delete
62+ RUN find /opt/ nodejs/node_modules -name "*.md" -delete
6363
6464# Warm up v8 compile cache
65- RUN node -e "require('/nodejs/node_modules/datadog-lambda-js/runtime/module_importer').initTracer()"
65+ RUN node -e "require('/opt/ nodejs/node_modules/datadog-lambda-js/runtime/module_importer').initTracer()"
6666
6767FROM scratch
68- COPY --from=builder /nodejs /
68+ COPY --from=builder /opt/ nodejs /
0 commit comments