This commit is contained in:
hailin 2025-07-28 18:51:30 +08:00
parent c561d3c9a4
commit 11e153a4f2
1 changed files with 18 additions and 18 deletions

View File

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