修正dockerfile

This commit is contained in:
2025-07-30 23:47:14 +08:00
parent c2a937eded
commit a301b4c692

View File

@@ -1,27 +1,32 @@
# ------------- 依赖缓存阶段 -------------
FROM node:22-alpine AS base
# 国内镜像
RUN npm config set registry https://registry.npmmirror.com
FROM node:22-alpine
WORKDIR /app
# RUN npm config set registry https://registry.npmmirror.com
RUN corepack enable
# 拷贝所有源码 - Nuxt 4在pnpm i阶段需要完整的项目结构
COPY . .
# Copy package.json and your lockfile, here we add pnpm-lock.yaml for illustration
# COPY package.json pnpm-lock.yaml .npmrc ./
# 安装依赖
RUN corepack enable && pnpm install --frozen-lockfile
COPY . ./
# Install dependencies
RUN pnpm i
# Copy the entire project
# Build the project
# 执行补丁脚本
RUN chmod +x patch-ui-pro.zsh && ./patch-ui-pro.zsh
RUN pnpm run build
# Change the port and host
ENV PORT=3000
ENV HOST=0.0.0.0
# ------------- 构建阶段 -------------
FROM base AS builder
RUN pnpm build
# ------------- 运行阶段 -------------
FROM node:22-alpine AS production
WORKDIR /app
# 拷贝构建产物 - Nuxt的output目录已经包含了所有运行时需要的文件
COPY --from=builder /app/.output ./.output
EXPOSE 3000
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
CMD ["node", ".output/server/index.mjs"]