不周 · 含 Docker 部署文件

This commit is contained in:
agent
2026-08-06 02:17:23 +00:00
commit 880be36fe5
85 changed files with 16958 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
# ---------- 第一阶段:构建 ----------
FROM node:20-alpine AS build
WORKDIR /app
# 先只拷贝依赖清单,利用 Docker 层缓存加速重复构建
COPY package.json package-lock.json* ./
# 国内网络环境可取消下一行注释使用镜像源
# RUN npm config set registry https://registry.npmmirror.com
RUN npm install
# 拷贝源码并构建(产物输出到 /app/dist)
COPY . .
RUN npm run build
# ---------- 第二阶段:运行 ----------
FROM nginx:1.27-alpine
# 单页应用 Nginx 配置(SPA 回退 + 静态资源缓存)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 拷贝构建产物
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]