Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Bug] docker build #2089

Closed
brinkqiang opened this issue Apr 18, 2024 · 3 comments
Closed

[Bug] docker build #2089

brinkqiang opened this issue Apr 18, 2024 · 3 comments
Labels
🐛 Bug Something isn't working | 缺陷

Comments

@brinkqiang
Copy link

💻 系统环境

Ubuntu

📦 部署环境

Docker

🌐 浏览器

Other

🐛 问题描述

自己build docker镜像总是提示错误。错误如下。而直接用官方的部署则可以。
经过自己多次测试 发现可能是内存问题。能问一下 build这个镜像要多少内存?因为是云主机 内存不是很大(2G)。 自己加了swap交互区(8G) 还是一样。

🚦 期望结果

希望能在2G内存的情况下build docker

📷 复现步骤

找台2G内存机器即可。sudo docker build -t lobe-chat . --no-cache

📝 补充信息

[+] Building 206.2s (17/23) docker:default
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 2.11kB 0.0s
=> [internal] load metadata for docker.io/library/node:20-slim 1.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 142B 0.0s
=> [base 1/1] FROM docker.io/library/node:20-slim@sha256:9f938a1eeb3f85ca7691e1b4b5e9ab91e1d2efa7afc1d3e495b6f8158b7e2d39 0.0s
=> [internal] load build context 1.4s
=> => transferring context: 88.75kB 0.9s
=> CACHED [runner 1/9] WORKDIR /app 0.0s
=> CACHED [runner 2/9] RUN addgroup --system --gid 1001 nodejs 0.0s
=> CACHED [runner 3/9] RUN adduser --system --uid 1001 nextjs 0.0s
=> CACHED [sharp 1/5] RUN corepack enable 0.0s
=> CACHED [sharp 2/5] WORKDIR /app 0.0s
=> CACHED [sharp 3/5] RUN npm config set registry https://registry.npmmirror.com/ 0.0s
=> CACHED [sharp 4/5] RUN pnpm config set registry https://registry.npmmirror.com/ 0.0s
=> CACHED [sharp 5/5] RUN pnpm add sharp 0.0s
=> CACHED [builder 3/6] COPY package.json ./ 0.0s
=> CACHED [builder 4/6] RUN pnpm i 0.0s
=> CACHED [builder 5/6] COPY . . 0.0s
=> ERROR [builder 6/6] RUN pnpm run build:docker # run build standalone for docker version 202.6s

[builder 6/6] RUN pnpm run build:docker # run build standalone for docker version:
1.873
1.873 > @lobehub/chat@0.147.18 build:docker /app
1.873 > DOCKER=true next build && npm run build-sitemap
1.873
6.580 Attention: Next.js now collects completely anonymous telemetry regarding usage.
6.582 This information is used to shape Next.js' roadmap and prioritize features.
6.583 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:
6.583 https://nextjs.org/telemetry
6.583
6.779 ▲ Next.js 14.1.4
6.781
6.967 Creating an optimized production build ...
8.312 ✓ (pwa) Compiling for server...
8.320 ✓ (pwa) Compiling for server...
8.327 ✓ (pwa) Compiling for client (static)...
8.335 ○ (pwa) Service worker: /app/public/sw.js
8.335 ○ (pwa) URL: /sw.js
8.335 ○ (pwa) Scope: /
200.2
200.2 <--- Last few GCs --->
200.2
200.2 [18:0x6a47720] 195137 ms: Mark-Compact (reduce) 935.0 (1005.1) -> 935.0 (1005.1) MB, 1224.69 / 0.00 ms (average mu = 0.219, current mu = 0.159) allocation failure; GC in old space requested
200.2 [18:0x6a47720] 196717 ms: Mark-Compact (reduce) 935.0 (1005.1) -> 935.0 (1005.1) MB, 1257.28 / 0.00 ms (average mu = 0.212, current mu = 0.204) allocation failure; GC in old space requested
200.2
200.2
200.2 <--- JS stacktrace --->
200.2
200.2 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
200.2 ----- Native stack trace -----
200.2
200.3 1: 0xb84bd6 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
200.3 2: 0xefec30 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
200.3 3: 0xefef17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
200.3 4: 0x1110925 [node]
200.3 5: 0x1110eb4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
200.3 6: 0x1127da4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
200.3 7: 0x11285bc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
200.3 8: 0x1129c32 v8::internal::Heap::CollectAllAvailableGarbage(v8::internal::GarbageCollectionReason) [node]
200.3 9: 0x10ffa7f v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
200.3 10: 0x10dc176 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
200.3 11: 0x10cdda4 v8::internal::FactoryBasev8::internal::Factory::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [node]
200.3 12: 0x10d0586 v8::internal::FactoryBasev8::internal::Factory::NewRawOneByteString(int, v8::internal::AllocationType) [node]
200.3 13: 0x14207c7 v8::internal::String::SlowFlatten(v8::internal::Isolate*, v8::internal::Handlev8::internal::ConsString, v8::internal::AllocationType) [node]
200.3 14: 0xf0dccd v8::String::Utf8Length(v8::Isolate*) const [node]
200.3 15: 0xc85152 [node]
200.3 16: 0x18e5546 [node]
201.1 Aborted (core dumped)
201.9  ELIFECYCLE  Command failed with exit code 134.


Dockerfile:30

28 |
29 | COPY . .
30 | >>> RUN pnpm run build:docker # run build standalone for docker version
31 |
32 | ## Production image, copy all the files and run next

ERROR: failed to solve: process "/bin/sh -c pnpm run build:docker # run build standalone for docker version" did not complete successfully: exit code: 134

@brinkqiang brinkqiang added the 🐛 Bug Something isn't working | 缺陷 label Apr 18, 2024
@lobehubbot
Copy link
Member

👀 @brinkqiang

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

@cy948
Copy link
Contributor

cy948 commented Apr 18, 2024

先试试关掉 nextjs 的 type check 和 lint check,目前用的 8G 机器不关也是会卡死。示例:
https://github.com/cy948/lobe-chat/blob/ee077b319e937979826821935a69216381ac95dc/next.config.mjs#L58:L63

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


First try to turn off the type check and lint check of nextjs. The 8G machine currently used will freeze if it is not turned off. Example:
https://github.com/cy948/lobe-chat/blob/ee077b319e937979826821935a69216381ac95dc/next.config.mjs#L58:L63

@lobehub lobehub locked and limited conversation to collaborators Apr 19, 2024
@arvinxx arvinxx converted this issue into discussion #2096 Apr 19, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
🐛 Bug Something isn't working | 缺陷
Projects
Archived in project
Development

No branches or pull requests

3 participants