From 7f990a6d7202670de8bf0e11331fc0862d4fefea Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 16 May 2022 12:09:36 -0700 Subject: [PATCH] fix: use npm v8 in expressapp container to workaround slow npm install from github The switch to node v16 gets use npm v8, to workaround an issue with slow 'npm install '. See: https://github.com/npm/cli/issues/4896 In our case the github repo dependency was the command given to docker run this container: bash -c "npm install elastic-apm-node#SOME-COMMIT-SHA && node app.js" This also adds a package.json to more explicitly declare we are working with a node project workspace. Also avoid generating a package-lock file we won't use. Fixes: #1483 --- docker/nodejs/express/.npmrc | 1 + docker/nodejs/express/Dockerfile | 8 ++++---- docker/nodejs/express/package.json | 9 +++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 docker/nodejs/express/.npmrc create mode 100644 docker/nodejs/express/package.json diff --git a/docker/nodejs/express/.npmrc b/docker/nodejs/express/.npmrc new file mode 100644 index 000000000..43c97e719 --- /dev/null +++ b/docker/nodejs/express/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/docker/nodejs/express/Dockerfile b/docker/nodejs/express/Dockerfile index aaf961059..41c1bdefe 100644 --- a/docker/nodejs/express/Dockerfile +++ b/docker/nodejs/express/Dockerfile @@ -1,8 +1,8 @@ -FROM node:12.18.1 +FROM node:16.15.0 RUN mkdir -p /app -RUN npm install express - -COPY app.js /app +COPY package.json .npmrc app.js /app/ WORKDIR /app +RUN npm install + diff --git a/docker/nodejs/express/package.json b/docker/nodejs/express/package.json new file mode 100644 index 000000000..e787cdda8 --- /dev/null +++ b/docker/nodejs/express/package.json @@ -0,0 +1,9 @@ +{ + "name": "expressapp", + "version": "1.0.0", + "private": true, + "main": "app.js", + "dependencies": { + "express": "*" + } +}