# ------------------------------------------------ # 基础镜像:Node LTS(Debian trixie-slim) # ------------------------------------------------ FROM node:lts-trixie-slim WORKDIR /usr/src/app ENV PNPM_HOME=/pnpm-global ENV PATH=$PNPM_HOME:$PATH ENV SHELL=/bin/sh # ------------------------------------------------ # 安装 pnpm 并配置国内源 # ------------------------------------------------ RUN npm install -g pnpm && \ pnpm config set registry https://registry.npmmirror.com # 在 Dockerfile 里替换源 RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian trixie main contrib non-free" > /etc/apt/sources.list && \ echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main contrib non-free" >> /etc/apt/sources.list && \ echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian trixie-updates main contrib non-free" >> /etc/apt/sources.list # ------------------------------------------------ # 更新系统工具(最小化依赖) # ------------------------------------------------ RUN apt-get update && apt-get install -y --no-install-recommends \ git curl ca-certificates && \ rm -rf /var/lib/apt/lists/* # ------------------------------------------------ # 安装运行时核心依赖(支持 SSR + CSR) # ------------------------------------------------ RUN pnpm add -g \ nuxt@latest \ vue@latest \ vue-router@latest \ @vueuse/core \ @pinia/nuxt \ pinia-plugin-persistedstate \ @element-plus/nuxt \ @element-plus/icons-vue \ @nuxtjs/tailwindcss \ @nuxt/image \ @nuxt/icon \ @nuxtjs/color-mode \ @nuxtjs/component-cache \ axios \ node-fetch \ socket.io-client \ lodash \ dayjs \ crypto-js # ------------------------------------------------ # 版本验证 # ------------------------------------------------ RUN echo "✅ Node 版本:" && node -v && \ echo "✅ pnpm 版本:" && pnpm -v && \ echo "✅ Nuxt 版本:" && pnpm dlx nuxt --version || true # ------------------------------------------------ # 默认端口 # ------------------------------------------------ EXPOSE 3000 # ------------------------------------------------ # 启动方式 # ------------------------------------------------ CMD ["bash"]