تايبسكريبت - لم يتمكن بناء مونوربو باستخدام توربوريبو من العثور على الوحدات المشتركة عند بناء Docker Compose
بعض السياق حول المشروع، هذا مستودع واحد يحتوي على تطبيقين باستخدام NextJs13 و TypeScript مع بعض الحزم المشتركة داخل ./packages/shared. بناء التطبيق محليًا يعمل بشكل جيد ولكن عندما أريد بناءه داخل Docker أحصل على هذا الخطأ:
docker-compose up -d
[+] Building 74.5s (15/15) FINISHED docker:desktop-linux
=> [blotter internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 1.44kB 0.0s
=> [blotter internal] load .dockerignore 0.0s
=> => transferring context: 99B 0.0s
=> [blotter internal] load metadata for docker.io/library/node:19.9.0-alpine3.18 2.0s
=> [blotter auth] library/node:pull token for registry-1.docker.io 0.0s
=> [blotter internal] load build context 2.9s
=> => transferring context: 191.45MB 2.9s
=> [blotter base 1/1] FROM docker.io/library/node:19.9.0-alpine3.18@sha256:8ec543d4795e2e85af924a24f8acb039792ae9fe8a42ad5b4bf4c277ab34b62e 0.0s
=> CACHED [blotter pruner 1/5] RUN apk add --no-cache libc6-compat 0.0s
=> CACHED [blotter pruner 2/5] WORKDIR /app 0.0s
=> CACHED [blotter pruner 3/5] RUN npm install turbo --global 0.0s
=> [blotter pruner 4/5] COPY . . 2.7s
=> [blotter pruner 5/5] RUN turbo prune --scope=blotter 1.7s
=> [blotter builder 3/6] COPY --from=pruner /app/out/ . 1.2s
=> [blotter builder 4/6] RUN npm install turbo --global 5.6s
=> [blotter builder 5/6] RUN npm install 31.7s
=> ERROR [blotter builder 6/6] RUN turbo run build --filter=blotter... 25.3s
------
> [blotter builder 6/6] RUN turbo run build --filter=blotter...:
0.255 • Packages in scope: auth, blotter, eslint-config-custom, ui
0.255 • Running build in 4 packages
0.255 • Remote caching disabled
0.256 blotter:build: cache miss, executing 7f0876bc395b9e06
0.896 blotter:build:
0.896 blotter:build: > [email build
0.896 blotter:build: > next build
0.896 blotter:build:
1.454 blotter:build: - info Loaded env from /app/apps/blotter/.env
1.648 blotter:build: Attention: Next.js now collects completely anonymous telemetry regarding usage.
1.648 blotter:build: This information is used to shape Next.js' roadmap and prioritize features.
1.649 blotter:build: You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
1.649 blotter:build: https://nextjs.org/telemetry
1.649 blotter:build:
1.767 blotter:build: - info Creating an optimized production build...
24.76 blotter:build: Failed to compile.
24.76 blotter:build:
24.76 blotter:build: ./app/blotter/ClientLayout.tsx
24.76 blotter:build: Module not found: Can't resolve 'ui/AvatarMenu'
24.76 blotter:build:
24.76 blotter:build: https://nextjs.org/docs/messages/module-not-found
24.76 blotter:build:
24.76 blotter:build: Import trace for requested module:
24.76 blotter:build: ./app/blotter/Session.tsx
24.76 blotter:build:
24.76 blotter:build: ./app/blotter/ops/compra-venta-genuina/new/step1.tsx
24.76 blotter:build: Module not found: Can't resolve 'ui/form/Select'
24.76 blotter:build:
24.76 blotter:build: https://nextjs.org/docs/messages/module-not-found
24.76 blotter:build:
24.76 blotter:build: Import trace for requested module:
24.76 blotter:build: ./app/blotter/ops/compra-venta-genuina/new/page.tsx
24.76 blotter:build:
24.76 blotter:build: ./app/login/page.tsx
24.76 blotter:build: Module not found: Can't resolve 'ui/Login'
24.76 blotter:build:
24.76 blotter:build: https://nextjs.org/docs/messages/module-not-found
24.76 blotter:build:
24.76 blotter:build:
24.76 blotter:build: > Build failed because of webpack errors
24.81 blotter:build: npm ERR! Lifecycle script build failed with error:
24.81 blotter:build: npm ERR! Error: command failed
24.81 blotter:build: npm ERR! in workspace: [email
24.81 blotter:build: npm ERR! at location: /app/apps/blotter
24.82 blotter:build: ERROR: command finished with error: command (/app/apps/blotter) npm run build exited (1)
24.82 blotter#build: command (/app/apps/blotter) npm run build exited (1)
24.82
24.82 Tasks: 0 successful, 1 total
24.82 Cached: 0 cached, 1 total
24.82 Time: 24.577s
24.82 Failed: blotter#build
24.82
24.82 ERROR run failed: command exited (1)
------
failed to solve: process "/bin/sh -c turbo run build --filter=blotter..." did not complete successfully: exit code: 1
ملف دوكر بلوتر
FROM node:19.9.0-alpine3.18 as base
Check https://turbo.build/repo/docs/handbook/deploying-with-docker#the-solution
FROM base AS pruner
RUN apk add --no-cache libc6-compat
WORKDIR /app
RUN npm install turbo --global
COPY . .
Avoid multi-stage builds for now
RUN turbo prune --scope=blotter --docker
RUN turbo prune --scope=blotter
FROM base AS builder
RUN apk add --no-cache libc6-compat
WORKDIR /app
Build the project
COPY --from=pruner /app/out/ .
TODO: npm ci no funciona con los workspaces.
RUN npm install turbo --global
RUN npm install
RUN turbo run build --filter=blotter...
ENTRYPOINT ["tail", "-f", "/dev/null"]
ملف دوكر الخاص بـ advisorts
FROM node:19.9.0-alpine3.18 as base
Check https://turbo.build/repo/docs/handbook/deploying-with-docker#the-solution
FROM base AS pruner
RUN apk add --no-cache libc6-compat
WORKDIR /app
RUN npm install turbo --global
COPY . .
Avoid multi-stage builds for now
RUN turbo prune --scope=blotter --docker
RUN turbo prune --scope=advisors
FROM base AS builder
RUN apk add --no-cache libc6-compat
WORKDIR /app
Build the project
COPY --from=pruner /app/out/ .
TODO: npm ci no funciona con los workspaces.
RUN npm install turbo --global
RUN npm install
RUN turbo run build --filter=advisors...
ENTRYPOINT ["tail", "-f", "/dev/null"]
الموضوع هو أنني تحققت مما إذا كانت مجلدات node_modules تحتوي على التبعيات المشتركة مثل واجهة المستخدم، ونعم... هي موجودة هناك.