This commit is contained in:
hailin 2025-07-28 22:17:36 +08:00
parent c79b50f610
commit 82e4658a16
1 changed files with 18 additions and 20 deletions

View File

@ -12,29 +12,27 @@ RUN yarn install --frozen-lockfile
COPY . . COPY . .
RUN yarn build RUN yarn build
# ────────────────────
# 第二步:运行阶段
# ────────────────────
FROM node:20-slim AS runtime
# # ──────────────────── WORKDIR /app
# # 第二步:运行阶段
# # ────────────────────
# FROM node:20-slim AS runtime
# WORKDIR /app # 拷贝构建产物
COPY --from=builder /app/.output .output
COPY --from=builder /app/node_modules ./node_modules
# # 拷贝构建产物 # 只拷贝必要的运行文件(不执行 yarn install
# COPY --from=builder /app/.output .output # 如果 Nuxt 构建产物已完整,可不再安装依赖
# COPY --from=builder /app/node_modules ./node_modules # COPY package*.json yarn.lock ./
# RUN yarn install --production --frozen-lockfile
# # 只拷贝必要的运行文件(不执行 yarn install # ✅ 安装 serve 用于启动 SSR 服务
# # 如果 Nuxt 构建产物已完整,可不再安装依赖 RUN npm install -g serve
# # COPY package*.json yarn.lock ./
# # RUN yarn install --production --frozen-lockfile
# # ✅ 安装 serve 用于启动 SSR 服务 # 暴露端口
# RUN npm install -g serve EXPOSE 8091
# # 暴露端口 # 启动 Nuxt SSR 服务
# EXPOSE 8091 CMD ["node", ".output/server/index.mjs"]
# # 启动 Nuxt SSR 服务
# # CMD ["node", ".output/server/index.mjs"]
CMD ["bash"]