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 RUN apt update && apt-get install git -y RUN git clone https://github.com/lobehub/lobe-chat.git . #COPY package.json ./ # If you want to build docker in China # RUN npm config set registry https://registry.npmmirror.com/ RUN pnpm i #COPY . . RUN pnpm run build:docker # run build standalone for docker version ## 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 RUN mkdir .next/cache RUN chmod -R 777 .next/cache # 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 7860 # set hostname to localhost ENV HOSTNAME "0.0.0.0" ENV PORT=7860 # General Variables ENV ACCESS_CODE "" ENV CUSTOM_MODELS "" # OpenAI ENV OPENAI_API_KEY "sk-xxx" ENV OPENAI_PROXY_URL "https://api.openai.com/v1" # Azure OpenAI ENV USE_AZURE_OPENAI "" ENV AZURE_API_KEY "" ENV AZURE_API_VERSION "" # Google ENV GOOGLE_API_KEY "" # Zhipu ENV ZHIPU_API_KEY "" # Moonshot ENV MOONSHOT_API_KEY "" # Ollama ENV OLLAMA_PROXY_URL "" CMD ["node", "server.js"]