diff --git a/php_pc/Dockerfile b/php_pc/Dockerfile index 3590eef..5a18dd0 100644 --- a/php_pc/Dockerfile +++ b/php_pc/Dockerfile @@ -12,29 +12,27 @@ RUN yarn install --frozen-lockfile COPY . . 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/node_modules ./node_modules -# # 拷贝构建产物 -# COPY --from=builder /app/.output .output -# COPY --from=builder /app/node_modules ./node_modules +# 只拷贝必要的运行文件(不执行 yarn install) +# 如果 Nuxt 构建产物已完整,可不再安装依赖 +# COPY package*.json yarn.lock ./ +# RUN yarn install --production --frozen-lockfile -# # 只拷贝必要的运行文件(不执行 yarn install) -# # 如果 Nuxt 构建产物已完整,可不再安装依赖 -# # COPY package*.json yarn.lock ./ -# # RUN yarn install --production --frozen-lockfile +# ✅ 安装 serve 用于启动 SSR 服务 +RUN npm install -g serve -# # ✅ 安装 serve 用于启动 SSR 服务 -# RUN npm install -g serve +# 暴露端口 +EXPOSE 8091 -# # 暴露端口 -# EXPOSE 8091 - -# # 启动 Nuxt SSR 服务 -# # CMD ["node", ".output/server/index.mjs"] -CMD ["bash"] +# 启动 Nuxt SSR 服务 +CMD ["node", ".output/server/index.mjs"]