dockerode/lib/docker.js required './session' at module scope, which pulls in @grpc/grpc-js and @grpc/proto-loader - 112 files. Its single call site is inside Docker.prototype.buildImage, the BuildKit path. Homarr lists, starts and stops containers and never builds images, so every install with a Docker widget paid for a gRPC stack it cannot reach. Measured with a forced GC, in context rather than in a bare process: requiring dockerode goes from +26.6 MiB RSS / 5.2 MiB heap to +20.6 MiB / 2.7 MiB, with grpc and protobufjs files going 63 and 49 to zero. The bare-process figure was +24.1 MiB, and quoting that would have overstated the win by 4x - most of it overlaps with what dockerode loads anyway. The patch comment records the in-context number.
26 lines
1.1 KiB
Diff
26 lines
1.1 KiB
Diff
diff --git a/lib/docker.js b/lib/docker.js
|
|
index 4951f8db867b1b12b75af79be2ebae6165534960..b333e65e99a9ef420826c0b1a908d4923dffc2f6 100644
|
|
--- a/lib/docker.js
|
|
+++ b/lib/docker.js
|
|
@@ -12,7 +12,6 @@ var EventEmitter = require('events').EventEmitter,
|
|
Node = require('./node'),
|
|
Exec = require('./exec'),
|
|
util = require('./util'),
|
|
- withSession = require('./session'),
|
|
extend = util.extend;
|
|
|
|
var Docker = function(opts) {
|
|
@@ -301,6 +300,12 @@ Docker.prototype.buildImage = function(file, opts, callback) {
|
|
|
|
function dialWithSession(callback) {
|
|
if (opts?.version === "2") {
|
|
+ // Loaded here rather than at module scope: './session' pulls in @grpc/grpc-js and
|
|
+ // @grpc/proto-loader (112 files), which cost +6.0 MiB RSS on top of dockerode itself.
|
|
+ // Only the BuildKit image-build path reaches this branch, so listing or starting
|
|
+ // containers paid for a gRPC stack it never used. require() is cached, so builds behave
|
|
+ // exactly as before.
|
|
+ var withSession = require('./session');
|
|
withSession(self, optsf.authconfig,(err, sessionId, done) => {
|
|
if (err) {
|
|
return callback(err);
|