lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design LLMs/AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Bedrock / Azure / Mistral / Perplexity ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT chat application.
https://chat-preview.lobehub.com
MIT License
32.52k stars 7.8k forks source link

[Bug] dockerfile部署 #2529

Closed kwjlhh closed 4 weeks ago

kwjlhh commented 1 month ago

💻 Operating System

Windows

📦 Environment

Official Preview

🌐 Browser

Chrome

🐛 Bug Description

FROM node:20-slim AS base

Sharp dependencies, copy all the files for production

FROM base AS sharp ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable

WORKDIR /app

RUN pnpm add sharp

Install dependencies only when needed

FROM base AS builder ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable

WORKDIR /app

COPY package.json ./ COPY .npmrc ./

If you want to build docker in China

RUN pnpm config set registry https://registry.npmmirror.com/ RUN pnpm i

COPY . .

Node

ENV NODE_OPTIONS "--max-old-space-size=8192"

run build standalone for docker version

RUN npm run build:docker

Production image, copy all the files and run next

FROM base AS runner WORKDIR /app

ENV NODE_ENV production

RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

Set the correct permission for prerender cache

RUN mkdir .next RUN chown nextjs:nodejs .next

Automatically leverage output traces to reduce image size

https://nextjs.org/docs/advanced-features/output-file-tracing

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static COPY --from=sharp --chown=nextjs:nodejs /app/node_modules/.pnpm ./node_modules/.pnpm

USER nextjs

EXPOSE 3210

set hostname to localhost

ENV HOSTNAME "0.0.0.0" ENV PORT=3210

General Variables

ENV ACCESS_CODE ""

ENV API_KEY_SELECT_MODE ""

CMD ["node", "server.js"]

使用如上dockerfile进行docker build指令, 其中在../node_modules/tree-sitter install: gyp ERR! not ok .../node_modules/tree-sitter install: Failed 会报错说找不到python,但build仍在继续,是否需要安装python? 第二,COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ 在这里也会报错说找不到/app/.next/standalone COPY failed: stat app/.next/standalone: file does not exist 请问这两个问题怎么解决

🚦 Expected Behavior

No response

📷 Recurrence Steps

No response

📝 Additional Information

No response

lobehubbot commented 1 month ago

👀 @kwjlhh

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。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot commented 4 weeks ago

✅ @kwjlhh

This issue is closed, If you have any questions, you can comment and reply.\ 此问题已经关闭。如果您有任何问题,可以留言并回复。