-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implementing turbo prune command for pnpm workspaces #534
Comments
I face the same problem with pnpm In the meantime, I'd love to update the docs stating that this feature is missing for pnpm if that's fine. |
can be based on this solution |
Currently the prune command isn't implemented for pnpm, but the docs don't mention that. (See this issue: vercel#534)
Can't wait to have this feature. |
@jaredpalmer can you please put this issue at a higher priority? It would make working with pnpm and turbo very easy. |
DISCLAIMER: This might be terrible advice. In the meantime while we wait for
Potential Drawbacks: |
Push. Would be nice so see this added soon as more and more people are changing to pnpm. |
This is something that is on our list however we have not prioritized doing this work at this time. The existing implementation is narrowly focused on an individual Yarn use case and is not easily generalizable, so it's not a trivial task. |
Is there a way around in the meantime? :) |
@Manubi I haven't explicitly tested it, but in general the thing proposed here should work: #534 (comment) (Use Yarn to generate docker images, and whatever package manager you want for general use.) |
@Manubi This is what I'm using for now:
|
@ivoilic can you maybe post the full docker file? :) thanks |
this doesn't appear to currently work due to various type errors neither on linux or windows |
I need this so bad 👍 |
I am using with great succes: https://pnpm.io/cli/deploy |
Hey @weyert, is there any example repo ? |
my solution for nextjs, hope can help someone: # 1. Generate a sparse/partial monorepo with a pruned lockfile for a target workspace. https://turborepo.org/docs/reference/command-line-reference#turbo-prune---scopetarget
# Refer to this original https://github.com/vercel/turborepo/blob/main/examples/with-docker/apps/web/Dockerfile
FROM node:alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
# pnpm cannot support turbo prune yet. so need manual create isolated folder https://github.com/vercel/turborepo/issues/534
# RUN pnpm global add turbo
# COPY . .
# RUN turbo prune --scope=web --docker
# Need to change to correct app folder name for each flow [ deps, builder, runner ]
# set your APP_NAME
ENV APP_NAME=web
# Create apps folder
RUN mkdir -p apps
# Copy related packages and apps, warning: this solution can't copy package that only needed for the build.
COPY ./packages /app/packages
COPY ./apps/$APP_NAME /app/apps/$APP_NAME
# Copy nextjs env, comment out if you don't have .env
COPY ./apps/$APP_NAME/.env.staging.sample /app/apps/$APP_NAME/.env.production
# Copy clean root files to root folder
COPY ./turbo.json /app/turbo.json
COPY ./.gitignore /app/.gitignore
COPY ./.npmrc /app/.npmrc
# Add lockfile and package.json's of isolated subworkspace
COPY ./package.json /app/package.json
COPY ./pnpm-lock.yaml /app/pnpm-lock.yaml
COPY ./pnpm-workspace.yaml /app/pnpm-workspace.yaml
# 2. Rebuild the source code only when needed
FROM node:alpine AS builder
WORKDIR /app
# Build the project and its dependencies
ENV NEXT_TELEMETRY_DISABLED 1
# set your APP_NAME
ENV APP_NAME=web
COPY --from=deps /app/ .
RUN corepack enable
RUN pnpm install
RUN pnpm turbo run build --filter=$APP_NAME...
# 3. Production image, copy all the files and run next
FROM node:alpine AS runner
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV=production
# set your APP_NAME
ENV APP_NAME=web
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
# comment out below if you don't have public folder
COPY --from=builder /app/apps/$APP_NAME/public public
COPY --from=builder --chown=nextjs:nodejs /app/apps/$APP_NAME/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/$APP_NAME/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD node apps/$APP_NAME/server.js remember enable standalone and set root path at const withTM = require('next-transpile-modules')(['ui'])
const path = require('path')
module.exports = withTM({
reactStrictMode: true,
output: 'standalone',
experimental: {
outputFileTracingRoot: path.join(__dirname, '../../'),
},
}) |
With #1819 prune is now supported for repos using |
@chris-olszewski you forget to update the docs |
Will update the docs when it is released. 🎉 |
Looks like it is :-) Can you update doc ? ahah |
Resolves some comments on #534 requesting a docs update.
@nathanhammond Have the docs been updated for pnpm examples? |
@trm217 There is basically no material difference between each of the package managers. Remove the lockfile, create pnpm-workspace.yml, change * to workspace:*, and then do a global s/yarn/pnpm/g. If you have particular problems open a new issue including details of the error message that you're encountering. |
I think my previous message sounded too demanding, so I made a PR in the hopes that we solve the issue using the second option (Provide an example of using pnpm) |
In case someone's use case is not covered by @nicu-chiciuc's example, or you just want to look at more examples, you can get pretty specific with sourcegraph's search. |
What version of Turborepo are you using?
1.0.24
What package manager are you using / does the bug impact?
pnpm
What operating system are you using?
Linux
Describe the Bug
I was running the command
turbo prune --scope=web
for a pnpm workspace using turborepoAnd it returns this error message:
Expected Behavior
It should have trimmed the workspace with relation to the scope declared which would make it easier for me to build the container image for that particular app.
To Reproduce
You can create a simple turborepo that uses pnpm as the package manager like the pnpm example https://github.com/vercel/turborepo/tree/main/examples/with-pnpm
and try to run the command:
I am running the pnpm version
6.24.4
node versionv17.3.0
turbo version1.0.24
The text was updated successfully, but these errors were encountered: