Deploy error on monorepo (Turborepo)

I’m trying to deploy a monorepo app, but flyctl fails while building Dockerfile.
I have tried to run deploy with flag --local-only, but without success.

My Dockerfile build without problems locally

:x:fly deploy ./apps/worker --local-only --no-cache

:white_check_mark:docker build -t worker:latest --build-arg="APP=worker" --no-cache .

Dockerfile

FROM  node:20-alpine AS custom-node
ARG PNPM_VERSION=8.14.0
ARG TURBO_VERSION=1.11.2

RUN apk add -f --update --no-cache --virtual .gyp nano bash libc6-compat python3 make g++ caddy \
  && npm install -g pnpm@${PNPM_VERSION} turbo@${TURBO_VERSION} \
  && apk del .gyp

FROM custom-node AS pruned
WORKDIR /app
ARG APP

COPY . .

RUN turbo prune --scope=$APP --docker

FROM custom-node AS installer
WORKDIR /app
ARG APP

COPY --from=pruned /app/out/json/ .
COPY --from=pruned /app/out/pnpm-lock.yaml /app/pnpm-lock.yaml

RUN --mount=type=cache,target=/usr/local/share/.cache/yarn/v6,sharing=private \
  pnpm install

FROM custom-node as builder
WORKDIR /app
ARG APP

COPY --from=installer --link /app .

COPY --from=pruned /app/out/full/ .

RUN pnpm run --filter=database build \
  && pnpm run --filter=database generate \
  && pnpm run --filter=${APP} build

#############################################
FROM custom-node AS runner
WORKDIR /app
ARG APP
ARG START_COMMAND=start

ENV APP=${APP}
ENV START_COMMAND=${START_COMMAND}
ENV PORT=3000

COPY --from=builder /app .

CMD pnpm run --filter=${APP} ${START_COMMAND}

Try fly deploy --dockerfile /path/to/Dockerfile -c apps/worker/fly.toml
Since turbo expects the build to be at the root of your project, you have to deploy there and point to the Dockerfile/toml

1 Like

So obvious lol. Thanks bro.