-
-
Notifications
You must be signed in to change notification settings - Fork 92
Closed as not planned
Description
------------------------------
第一阶段:构建 (Build Stage)
------------------------------
FROM node:22-alpine AS builder
WORKDIR /app
RUN npm install -g pnpm
COPY . .
安装依赖
--frozen-lockfile 确保使用 lock 文件中的确切版本
RUN pnpm install
构建项目 (生成 .output 目录)
RUN pnpm run build
------------------------------
第二阶段:运行 (Run Stage)
------------------------------
FROM node:22-alpine AS runner
WORKDIR /app
设置环境变量
NUXT_HOST=0.0.0.0 允许外部访问容器
NUXT_PORT=3000 指定运行端口
ENV NODE_ENV=production
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000
从构建阶段复制构建产物 (.output 目录)
COPY --from=builder /app/.output ./.output
开放端口
EXPOSE 3000
启动 Nuxt (Nitro) 服务
CMD ["node", ".output/server/index.mjs"]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels