添加docker构建配置

This commit is contained in:
2025-12-13 20:36:31 +08:00
parent 307573ba1b
commit b32e1d25d1
15 changed files with 995 additions and 842 deletions

View File

@@ -0,0 +1,29 @@
# 前端构建阶段
FROM node:18-alpine as builder
WORKDIR /app
# 复制 package 文件
COPY package*.json ./
# 安装依赖
RUN npm install
# 复制源代码
COPY . .
# 构建前端
RUN npm run build
# Nginx 运行阶段
FROM nginx:alpine
# 复制构建产物到 nginx
COPY --from=builder /app/build /usr/share/nginx/html
# 复制 nginx 配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]