Yarn install in Docker Builds

Running Yarn install inside docker builds is a slow and tedious process. And often you hit many errors when you try to create optimized production builds.

The following bugs give you some context to issues:

Am assuming some of you have been running volto in production. Would love to hear how you are doing your production builds?

Does using Yarn 2 resolve some of the webpack hoisting issues when trying to build volto images?

There's a stale PR to replace yarn classic with pnpm. There needs to be a discussion to see if the community (current Volto in production) would be in favor of adopting pnpm.

1 Like

@tiberiuichim Am guessing using Yarn 2 is far less invasive than switching to pnpm. I am going to spend some time to see if I can play around using Yarn 2 in my dev setup.

"invasiveness" is a relative issue. When we've adopted Volto, we were actually using npm and a script that solves the workspace problem. I think it may be possible, with some small effort, to compile and use a Volto project using just npm (but only for production).

For Volto, yarn (+ mrs-developer) solves the problem of "monorepo". Javascript packages are typically published in distributed form (transpiled to "basic" javascript, minified, etc), but for development we want to have them integrated with the "language capabilities" of the development project. So we want our webpack setup to take care of transpiling and bundling some of the code, so that we can do easier development. So mrs-developer takes care of the "clone the addon, setup Volto's (necessary for webpack setup) jsconfig.json file", while yarn takes care of automatically installing an addon's dependencies, by adding a "mrs-developer checked out addon" as a workspace (basically transforming our Volto project into a monorepo).

Now, yarn in itself is nothing special. Yarn 2, npm 7, pnpm all have support for monorepos and would work fine for us. There may be (and I think I tackled those issues in the above PR) some code that relies on the specific way yarn does the "hoisting", which is "lifting up" all the dependencies up to the top level of node_modules.

I'm not a fan of the hoisting, at all. It causes all sort of issues, phantom dependencies, etc. Big fan of pnpm's algorithm and method of installing.

1 Like