这是indexloc提供的服务,不要输入任何密码
Skip to content

turbo prune --scope=web doesn't include turbo.json in out/ or out/json folder #631

@miszo

Description

@miszo

What version of Turborepo are you using?

1.1.1

What package manager are you using / does the bug impact?

Yarn v1

What operating system are you using?

Mac

Describe the Bug

When running the turbo prune --scope=web, the out/ folder has the following structure:

  • apps
  • full
  • json
  • packages
  • .gitignore
  • package.json
  • yarn.lock

since running the npx @turbo/codemod create-turbo-config codemod I have the turbo.json.

This caused some issues when building the app using docker

Here's my Dockerfile

FROM node:16-alpine AS builder
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=${APP_SCOPE} --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:16-alpine AS installer
RUN apk update && apk add --no-cache git
WORKDIR /app
#set CI variable to true
ENV CI=true
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install --immutable

FROM node:16-alpine AS sourcer
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
WORKDIR /app
COPY --from=installer /app/ .
COPY --from=builder /app/out/full/ .
COPY .gitignore .gitignore
RUN NODE_ENV=production yarn turbo run build --scope=${APP_SCOPE} --include-dependencies --no-deps

EXPOSE 3000
CMD yarn turbo run start --scope=${APP_SCOPE}

I've fixed it with

FROM node:16-alpine AS builder
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=${APP_SCOPE} --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:16-alpine AS installer
RUN apk update && apk add --no-cache git
WORKDIR /app
#set CI variable to true
ENV CI=true
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
# Add turbo.json's from the root
COPY --from=builder /app/turbo.json ./turbo.json
RUN yarn install --immutable

FROM node:16-alpine AS sourcer
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
WORKDIR /app
COPY --from=installer /app/ .
COPY --from=builder /app/out/full/ .
COPY .gitignore .gitignore
RUN NODE_ENV=production yarn turbo run build --scope=${APP_SCOPE} --include-dependencies --no-deps

EXPOSE 3000
CMD yarn turbo run start --scope=${APP_SCOPE}

Expected Behavior

turbo.json file should be included in the out/ or out/json/ folder

then my Dockerfile would look like this

FROM node:16-alpine AS builder
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=${APP_SCOPE} --docker

# Add lockfile and package.json's of isolated subworkspace
FROM node:16-alpine AS installer
RUN apk update && apk add --no-cache git
WORKDIR /app
#set CI variable to true
ENV CI=true
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/turbo.json ./turbo.json
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install --immutable

FROM node:16-alpine AS sourcer
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
WORKDIR /app
COPY --from=installer /app/ .
COPY --from=builder /app/out/full/ .
COPY .gitignore .gitignore
RUN NODE_ENV=production yarn turbo run build --scope=${APP_SCOPE} --include-dependencies --no-deps

EXPOSE 3000
CMD yarn turbo run start --scope=${APP_SCOPE}

Or just as it was already

FROM node:16-alpine AS builder
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=${APP_SCOPE} --docker

# Add lockfile, turbo.json and package.json's of isolated subworkspace
FROM node:16-alpine AS installer
RUN apk update && apk add --no-cache git
WORKDIR /app
#set CI variable to true
ENV CI=true
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install --immutable

FROM node:16-alpine AS sourcer
ARG APP_SCOPE
ENV APP_SCOPE ${APP_SCOPE}
RUN apk update && apk add --no-cache git
WORKDIR /app
COPY --from=installer /app/ .
COPY --from=builder /app/out/full/ .
COPY .gitignore .gitignore
RUN NODE_ENV=production yarn turbo run build --scope=${APP_SCOPE} --include-dependencies --no-deps

EXPOSE 3000
CMD yarn turbo run start --scope=${APP_SCOPE}

To Reproduce

  1. Init new turborepo project
  2. Run turbo prune --scope=web
  3. There's no turbo.json file in the out/ or `out/json/ folder

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions