PNPM + Docker + turborepo ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL
#4863
-
|
👋 => ERROR [installer 11/11] RUN pnpm turbo run build
------
> [installer 11/11] RUN pnpm turbo run build:
#20 0.654 undefined
#20 0.654 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command failed with ENOENT: turbo run build
#20 0.654 spawn turbo ENOENT
------
executor failed running [/bin/sh -c pnpm turbo run build]: exit code: 1I'd highly appreciate any input on this! In case someone figured out a working way to use pnpm with docker and turborepo I'd love to take a look at that as well 🙏 # TODO: Remove dev deps from prod build
# BUILDER - Stage 1
FROM node:alpine as builder
WORKDIR /app
RUN apk update && yarn global add turbo
COPY . .
# Add a build argument for the project scope
RUN turbo prune --scope="my-app" --docker
# INSTALLER - Stage 2
FROM node:alpine as installer
WORKDIR /app
RUN apk update && apk add g++ make py3-pip && yarn global add pnpm
# First install dependencies (as they change less often)
COPY --from=builder /app/out/full/.gitignore ./.gitignore
COPY --from=builder /app/out/full/turbo.json ./turbo.json
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm fetch
# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
RUN pnpm install -r --offline --ignore-scripts
RUN pnpm turbo run build
# # RUNNER - Stage 3
FROM node:alpine AS runner
WORKDIR /app
# # Don't run production as root
RUN addgroup --system --gid 1001 app
RUN adduser --system --uid 1001 app
USER app
COPY --from=installer /app .
CMD ["node", "apps/my-app/dist/index.mjs"] |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Did you find a solution here? We are facing the same issue. |
Beta Was this translation helpful? Give feedback.
-
|
This Dockerfile which uses pnpm works for me: # Builder
FROM node:alpine AS builder
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=appname --docker
# Installer
FROM node:alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
RUN yarn global add pnpm
RUN yarn global add turbo
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
RUN pnpm install
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
# Uncomment and use build args to enable remote caching
# ARG TURBO_TEAM
# ENV TURBO_TEAM=$TURBO_TEAM
# ARG TURBO_TOKEN
# ENV TURBO_TOKEN=$TURBO_TOKEN
RUN turbo build --filter=appname...
# Runner
FROM node:alpine AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/apps/appname/next.config.js .
COPY --from=installer /app/apps/appname/package.json .
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/appname/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/appname/.next/static ./apps/appname/.next/static
# COPY --from=installer --chown=nextjs:nodejs /app/apps/appname/public ./apps/appname/public
CMD node apps/appname/server.js |
Beta Was this translation helpful? Give feedback.
This Dockerfile which uses pnpm works for me: