From 1bc4005abf4274ad59fc5cd0678db08602b426a0 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 16 May 2022 13:15:35 -0700 Subject: [PATCH] fix: use npm v8 in expressapp container to workaround slow npm install from github (#1484) 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": "*" + } +}