Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 22 additions & 24 deletions Dockerfile.Packages
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,27 @@ RUN npm i --nodedir="/usr/src/node/node-install/usr/local" bcrypt@5.1.0
RUN npm i --nodedir="/usr/src/node/node-install/usr/local" cld@2.9.1
RUN npm i --nodedir="/usr/src/node/node-install/usr/local" unix-dgram@2.0.6

# Build @datadog/pprof from source against Asana custom Node.
# The npm package ships with "install: exit 0" and no C++ source (only prebuilts),
# so we clone from GitHub to build the native binding against our pointer-compressed V8.
# The standard prebuilts are ABI-incompatible with --experimental-enable-pointer-compression.
RUN npm i @datadog/pprof@5.8.0 --ignore-scripts
RUN git clone --branch v5.8.0 --depth 1 https://github.com/DataDog/pprof-nodejs.git /usr/src/pprof-source
WORKDIR /usr/src/pprof-source
RUN npm install --unsafe-perm --build-from-source
RUN npm install --unsafe-perm node-gyp
RUN node_modules/.bin/node-gyp rebuild --jobs=max --nodedir=/usr/src/node/node-install/usr/local
# Replace the linux prebuilt with our pointer-compression-compatible binary.
# NODE_MODULE_VERSION and arch are read dynamically from the custom Node binary.
# Use find to locate the built .node file since the exact name may vary by version.
WORKDIR /usr/src/node
RUN ARCH=$(node -e "process.stdout.write(process.arch)") && \
MODULES_VER=$(node -e "process.stdout.write(process.versions.modules)") && \
PROFILER_NODE=$(find /usr/src/pprof-source/build/Release -name "*.node" | head -1) && \
echo "Using profiler binary: $PROFILER_NODE" && \
test -f "$PROFILER_NODE" && \
cp "$PROFILER_NODE" \
node_modules/@datadog/pprof/prebuilds/linuxglibc-${ARCH}/node-${MODULES_VER}.node

RUN ls
RUN ls node_modules
# Build the pprof version required by dd-trace 5.116.0.
# Build native bindings against the existing pointer-compressed Node binary and headers.
RUN set -eu; \
version=5.15.1; \
package_root="/usr/src/pprof-packages/@datadog+pprof@${version}"; \
install_root="/usr/src/pprof-install-${version}"; \
npm install --prefix "$install_root" --ignore-scripts "@datadog/pprof@${version}"; \
mkdir -p "$package_root/node_modules/@datadog"; \
cp -a "$install_root/node_modules/@datadog/pprof" "$package_root/node_modules/@datadog/"; \
git clone --branch "v${version}" --depth 1 https://github.com/DataDog/pprof-nodejs.git "/usr/src/pprof-source-${version}"; \
cd "/usr/src/pprof-source-${version}"; \
npm install --ignore-scripts; \
npm install --ignore-scripts --no-save node-gyp@11.5.0; \
node_modules/.bin/node-gyp rebuild --jobs=2 --nodedir=/usr/src/node/node-install/usr/local; \
arch=$(node -p 'process.arch'); \
modules_ver=$(node -p 'process.versions.modules'); \
binding_path="prebuilds/linux-${arch}/dd_pprof.node.abi${modules_ver}.node"; \
test -f "$package_root/node_modules/@datadog/pprof/$binding_path"; \
cp build/Release/dd_pprof.node "$package_root/node_modules/@datadog/pprof/$binding_path"; \
NODE_PATH="$install_root/node_modules" node -e 'const assert = require("assert"); const pprof = require(process.argv[1]); pprof.time.profile({durationMillis: 100}).then(profile => pprof.encode(profile)).then(bytes => { assert(bytes.length > 0); console.log("pprof native smoke passed:", process.argv[1]); }).catch(error => { console.error(error); process.exitCode = 1; });' "$package_root/node_modules/@datadog/pprof"; \
cd /usr/src/node

WORKDIR /usr/src/node
CMD ["bash"]
Loading