GoogleCloudPlatform / buildpacks

Builders and buildpacks designed to run on Google Cloud's container platforms
Apache License 2.0
985 stars 145 forks source link

Using builder with Yarn in monorepo (workspaces) #229

Open burn2delete opened 2 years ago

burn2delete commented 2 years ago

Hello,

I am trying to run the builder from within cloud build, however I cant seem to get the builder to work for my repo.

When running from the root of the mono repo, yarn is selected however it attempts to build with the wrong location.

When I specify a path for pack, the builder doesn't find the yarn.lock an attempts to use npm instead.

Im not sure how to go about configuring the builder for a mono repo using yarn workspaces.

jama22 commented 1 year ago

Hey there, sorry for the delayed response. Not super familiar with yarn workspaces, but you might be able to get what you want by maybe only including the specific directory that you want to build your yarn app.

Part of the CNB spec allows for a project.toml descriptor that, when present at the root level of the directory, will be picked up and respected by the pack build system, even using Cloud Build. Not sure if it will help with your use case, but maybe the include parameter could be used to tell Cloud Build to only try to build your yarn workspace. If you go to the bottom of that page you'll see an example project.toml that uses the include keyword

Dante-dan commented 3 months ago

@jama22 Maybe we need the default configuration for all platform, I use pnpm workspace. I have the some issue, the subpackage miss his node_modules

I see that commands in build steps

pnpm prune --prod (CI=true)

but pnpm prune is not support workspace, we should use pnpm install --prod.