From d20eff75bd6026de6c0641e2ec7a214ae470f3a1 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Fri, 23 Jun 2023 11:04:36 -0700 Subject: [PATCH 1/2] Remove unnecessary and unwarranted `npm update` during Auspice install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was introduced incidentally, and seemingly unintentionally¹, in "Replace Alpine-based image with a Debian-based image" (ce07dad), but no one noticed. `npm update` is unwarranted because it's intended for maintainers of a package, not downstream user installs, which is the role we have here. Its effect was to bump the minimum versions in Auspice's package.json to the latest available (while still respecting SemVer constraints) and then install all of Auspice's deps into node_modules/.² That's unnecessary because we then run `npm install`, which unlike `npm update`, also runs pre/post-installation steps Auspice includes. ¹ ² Notably, `npm update` was added when the image had npm v5, which updates both package.json and package-lock.json. We currently have npm v6, which does the same. Subsequent versions, e.g. npm v8, stopped updating package.json and only update package-lock.json. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0e3570e1..1c40a361 100644 --- a/Dockerfile +++ b/Dockerfile @@ -214,7 +214,7 @@ RUN curl -fsSL -o /final/bin/nextclade2 https://github.com/nextstrain/nextclade/ # ⁴ https://github.com/mapbox/node-pre-gyp/blob/v1.0.10/lib/node-pre-gyp.js#L186 WORKDIR /nextstrain/auspice RUN /builder-scripts/download-repo https://github.com/nextstrain/auspice release . \ - && npm update && npm install && npm link + && npm install && npm link # Add NCBI Datasets command line tools for access to NCBI Datsets Virus Data Packages RUN curl -fsSL -o /final/bin/datasets https://ftp.ncbi.nlm.nih.gov/pub/datasets/command-line/v2/linux-${TARGETARCH}/datasets From d5d1662dd69867f574e06eab2604e4ceaabf3d60 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Thu, 22 Jun 2023 16:26:02 -0700 Subject: [PATCH 2/2] Omit dev deps when installing Auspice This avoids disk-heavy deps like Puppeteer, which bundle a whole Chromium install. Based on some rough comparisons, I expected this to shave about 600MB from the uncompressed image size and a local test build bore that out. The node_modules/ tree is infamously large and bloated. The usual culprits are non-source files that are commonly included in package distributions but not needed at run time. So there is surely more we could shave off here, but this is a huge easy start. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1c40a361..75e59b34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -214,7 +214,7 @@ RUN curl -fsSL -o /final/bin/nextclade2 https://github.com/nextstrain/nextclade/ # ⁴ https://github.com/mapbox/node-pre-gyp/blob/v1.0.10/lib/node-pre-gyp.js#L186 WORKDIR /nextstrain/auspice RUN /builder-scripts/download-repo https://github.com/nextstrain/auspice release . \ - && npm install && npm link + && npm install --omit dev && npm link # Add NCBI Datasets command line tools for access to NCBI Datsets Virus Data Packages RUN curl -fsSL -o /final/bin/datasets https://ftp.ncbi.nlm.nih.gov/pub/datasets/command-line/v2/linux-${TARGETARCH}/datasets