Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit dev deps when installing Auspice #165

Merged
merged 2 commits into from
Jun 23, 2023
Merged

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented Jun 22, 2023

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.

Testing

  • Checks pass

@tsibley
Copy link
Member Author

tsibley commented Jun 23, 2023

I think this is getting skunked by the old version of npm (v6) in the image, which I only noted because I saw this warning float by:

npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

@victorlin
Copy link
Member

I think this is getting skunked by the old version of npm (v6) in the image

#122, hopefully to be merged soon, will bring a newer version of npm.

@tsibley
Copy link
Member Author

tsibley commented Jun 23, 2023

Confirmed that with newer npm in the container this works fine.

commit d38eb85c003fb738cec4a7df7aabc768ec610149
Author: Thomas Sibley <tsibley@fredhutch.org>
Date:   Fri Jun 23 10:11:25 2023 -0700

    wip! upgrade npm

diff --git a/Dockerfile b/Dockerfile
index 569bfd7..e248fdf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -35,7 +35,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
 # Install a specific Node.js version
 # https://github.com/nodesource/distributions/blob/0d81da75/README.md#installation-instructions
 RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
- && apt-get update && apt-get install -y nodejs
+ && apt-get update && apt-get install -y nodejs && npm install -g npm@8
 
 # Used for platform-specific instructions
 ARG TARGETPLATFORM

Will test some more locally, clean up, and then mark for review.

@tsibley tsibley changed the base branch from master to trs/existing-registry-container June 23, 2023 18:44
@tsibley tsibley force-pushed the trs/existing-registry-container branch from 75e2680 to bbda96b Compare June 23, 2023 20:52
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.

¹ <#21 (comment)>

² 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.
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.
@tsibley
Copy link
Member Author

tsibley commented Jun 23, 2023

Dropped the npm install -g npm@8 bit since #122 is in now and repushed.

@tsibley tsibley marked this pull request as ready for review June 23, 2023 21:10
@tsibley tsibley requested a review from a team June 23, 2023 21:11
Base automatically changed from trs/existing-registry-container to master June 23, 2023 22:57
@tsibley tsibley merged commit d47b7e8 into master Jun 23, 2023
@tsibley tsibley deleted the trs/omit-auspice-dev-deps branch June 23, 2023 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

2 participants