The lengthy build time you observed with v22.11.0 compared with the older version may have a few contributing factors such as the difference of the base image size of both versions, and increase in delay caused by the version upgrade.
For the base image size, the one for v22.11.0 could be quite larger and have additional layers than v21.3.0. This may demand for longer download and setup times. To compare sizes of both images, you can check this page for more info. You can also consider testing things out with v22.11.0-slim while adding other required packages manually to observe if there’s any improvement.
When updating to v22.11.0, there’s a possibility that dependencies may require recompilation and existing packages may need respective updates (new dependencies can be verified by inspecting a “yarn.lock” file). This can contribute to lengthy build time in docker.
Also, does this increased build time remain constant during the next tests? You could also try exploring the use of “npm ci” in your dockerfile, compare it with “yarn install” then see if (1) it’s applicable to your use case and (2) it yields any speed improvements.
Even if caching was performed, it might be the case that the addition of new dependencies or heavier components had caused changes on “package.json” or “yarn.lock”, which makes it ineffective.
If the issue persists, I’d also recommend filing an issue in the official GitHub issue tracker for docker-node so that the development team of Node.js for Docker may conduct further analysis on these packages.