forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/lobehub/lobe-chat
- Loading branch information
Showing
10 changed files
with
824 additions
and
623 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,138 +1,141 @@ | ||
FROM node:20-slim AS base | ||
## Base image for all the stages | ||
FROM node:20-alpine 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 | ||
RUN \ | ||
# Add user nextjs to run the app | ||
addgroup --system --gid 1001 nodejs \ | ||
&& adduser --system --uid 1001 nextjs | ||
|
||
WORKDIR /app | ||
|
||
RUN pnpm add sharp | ||
|
||
## Install dependencies only when needed | ||
## Builder image, install all the dependencies and build the app | ||
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 npm config set registry https://registry.npmmirror.com/ | ||
RUN pnpm i | ||
|
||
COPY . . | ||
ARG USE_NPM_CN_MIRROR | ||
|
||
ENV NEXT_PUBLIC_BASE_PATH "" | ||
ENV NEXT_PUBLIC_BASE_PATH="" | ||
|
||
# Sentry | ||
ENV NEXT_PUBLIC_SENTRY_DSN "" | ||
ENV SENTRY_ORG "" | ||
ENV SENTRY_PROJECT "" | ||
ENV NEXT_PUBLIC_SENTRY_DSN="" \ | ||
SENTRY_ORG="" \ | ||
SENTRY_PROJECT="" | ||
|
||
# Posthog | ||
ENV NEXT_PUBLIC_ANALYTICS_POSTHOG "" | ||
ENV NEXT_PUBLIC_POSTHOG_KEY "" | ||
ENV NEXT_PUBLIC_POSTHOG_HOST "" | ||
ENV NEXT_PUBLIC_ANALYTICS_POSTHOG="" \ | ||
NEXT_PUBLIC_POSTHOG_HOST="" \ | ||
NEXT_PUBLIC_POSTHOG_KEY="" | ||
|
||
# Umami | ||
ENV NEXT_PUBLIC_ANALYTICS_UMAMI "" | ||
ENV NEXT_PUBLIC_UMAMI_SCRIPT_URL "" | ||
ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID "" | ||
ENV NEXT_PUBLIC_ANALYTICS_UMAMI="" \ | ||
NEXT_PUBLIC_UMAMI_SCRIPT_URL="" \ | ||
NEXT_PUBLIC_UMAMI_WEBSITE_ID="" | ||
|
||
# Node | ||
ENV NODE_OPTIONS "--max-old-space-size=8192" | ||
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 | ||
COPY package.json ./ | ||
COPY .npmrc ./ | ||
|
||
RUN \ | ||
# If you want to build docker in China, build with --build-arg USE_NPM_CN_MIRROR=true | ||
if [ "${USE_NPM_CN_MIRROR:-false}" = "true" ]; then \ | ||
export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"; \ | ||
npm config set registry "https://registry.npmmirror.com/"; \ | ||
fi \ | ||
# Set the registry for corepack | ||
&& export COREPACK_NPM_REGISTRY=$(npm config get registry | sed 's/\/$//') \ | ||
# Enable corepack | ||
&& corepack enable \ | ||
# Use pnpm for corepack | ||
&& corepack use pnpm \ | ||
# Install the dependencies | ||
&& pnpm i \ | ||
# Add sharp dependencies | ||
&& mkdir -p /sharp \ | ||
&& pnpm add sharp --prefix /sharp | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
COPY . . | ||
|
||
COPY --from=builder /app/public ./public | ||
# run build standalone for docker version | ||
RUN npm run build:docker | ||
|
||
# Set the correct permission for prerender cache | ||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
## Application image, copy all the files for production | ||
FROM scratch AS app | ||
|
||
COPY --from=builder /app/public /app/public | ||
|
||
# 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 | ||
COPY --from=builder /app/.next/standalone /app/ | ||
COPY --from=builder /app/.next/static /app/.next/static | ||
COPY --from=builder /sharp/node_modules/.pnpm /app/node_modules/.pnpm | ||
|
||
USER nextjs | ||
## Production image, copy all the files and run next | ||
FROM base | ||
|
||
EXPOSE 3210 | ||
# Copy all the files from app, set the correct permission for prerender cache | ||
COPY --from=app --chown=nextjs:nodejs /app /app | ||
|
||
ENV NODE_ENV="production" | ||
|
||
# set hostname to localhost | ||
ENV HOSTNAME "0.0.0.0" | ||
ENV PORT=3210 | ||
ENV HOSTNAME="0.0.0.0" \ | ||
PORT="3210" | ||
|
||
# General Variables | ||
ENV ACCESS_CODE "" | ||
|
||
ENV API_KEY_SELECT_MODE "" | ||
|
||
# OpenAI | ||
ENV OPENAI_API_KEY "" | ||
ENV OPENAI_PROXY_URL "" | ||
ENV OPENAI_MODEL_LIST "" | ||
|
||
# Azure OpenAI | ||
ENV USE_AZURE_OPENAI "" | ||
ENV AZURE_API_KEY "" | ||
ENV AZURE_API_VERSION "" | ||
|
||
ENV GOOGLE_API_KEY "" | ||
|
||
# Zhipu | ||
ENV ZHIPU_API_KEY "" | ||
|
||
# Moonshot | ||
ENV MOONSHOT_API_KEY "" | ||
ENV ACCESS_CODE="" \ | ||
API_KEY_SELECT_MODE="" \ | ||
FEATURE_FLAGS="" | ||
|
||
# Model Variables | ||
ENV \ | ||
# Ai360 | ||
AI360_API_KEY="" \ | ||
# Anthropic | ||
ANTHROPIC_API_KEY="" ANTHROPIC_PROXY_URL="" \ | ||
# Amazon Bedrock | ||
AWS_ACCESS_KEY_ID="" AWS_SECRET_ACCESS_KEY="" AWS_REGION="" \ | ||
# Azure OpenAI | ||
AZURE_API_KEY="" AZURE_API_VERSION="" AZURE_ENDPOINT="" AZURE_MODEL_LIST="" \ | ||
# Baichuan | ||
BAICHUAN_API_KEY="" \ | ||
# DeepSeek | ||
DEEPSEEK_API_KEY="" \ | ||
GOOGLE_API_KEY="" GOOGLE_PROXY_URL="" \ | ||
# Groq | ||
GROQ_API_KEY="" GROQ_PROXY_URL="" \ | ||
# Minimax | ||
MINIMAX_API_KEY="" \ | ||
# Mistral | ||
MISTRAL_API_KEY="" \ | ||
# Moonshot | ||
MOONSHOT_API_KEY="" MOONSHOT_PROXY_URL="" \ | ||
# Novita | ||
NOVITA_API_KEY="" \ | ||
# Ollama | ||
OLLAMA_MODEL_LIST="" OLLAMA_PROXY_URL="" \ | ||
# OpenAI | ||
OPENAI_API_KEY="" OPENAI_MODEL_LIST="" OPENAI_PROXY_URL="" \ | ||
# OpenRouter | ||
OPENROUTER_API_KEY="" OPENROUTER_MODEL_LIST="" \ | ||
# Perplexity | ||
PERPLEXITY_API_KEY="" PERPLEXITY_PROXY_URL="" \ | ||
# Qwen | ||
QWEN_API_KEY="" \ | ||
# Stepfun | ||
STEPFUN_API_KEY="" \ | ||
# Taichu | ||
TAICHU_API_KEY="" \ | ||
# TogetherAI | ||
TOGETHERAI_API_KEY="" TOGETHERAI_MODEL_LIST="" \ | ||
# 01.AI | ||
ZEROONE_API_KEY="" \ | ||
# Zhipu | ||
ZHIPU_API_KEY="" | ||
|
||
# Ollama | ||
ENV OLLAMA_PROXY_URL "" | ||
ENV OLLAMA_MODEL_LIST "" | ||
|
||
# Perplexity | ||
ENV PERPLEXITY_API_KEY "" | ||
|
||
# Anthropic | ||
ENV ANTHROPIC_API_KEY "" | ||
|
||
# Mistral | ||
ENV MISTRAL_API_KEY "" | ||
|
||
# OpenRouter | ||
ENV OPENROUTER_API_KEY "" | ||
ENV OPENROUTER_MODEL_LIST "" | ||
|
||
# 01.AI | ||
ENV ZEROONE_API_KEY "" | ||
|
||
# TogetherAI | ||
ENV TOGETHERAI_API_KEY "" | ||
|
||
# Minimax | ||
ENV MINIMAX_API_KEY "" | ||
|
||
# DeepSeek | ||
ENV DEEPSEEK_API_KEY "" | ||
USER nextjs | ||
|
||
# Qwen | ||
ENV QWEN_API_KEY "" | ||
EXPOSE 3210/tcp | ||
|
||
CMD ["node", "server.js"] | ||
CMD ["node", "/app/server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.