Some checks failed
continuous-integration/drone/push Build encountered an error
1. 新增 .drone.yml 配置文件 - 自动安装 npm 依赖 - 自动构建生产版本 - 构建 Docker 镜像 - 自动部署到生产服务器 - 健康检查验证部署成功 2. 新增 Dockerfile - 多阶段构建:Node 编译 + Nginx 运行 - 优化镜像体积,使用 alpine 基础镜像 - 配置静态资源缓存 - 添加健康检查 3. 新增 nginx.conf - 配置前端路由支持(Vue Router history 模式) - 代理 API 请求到后端服务 - 优化 Gzip 压缩和静态资源缓存 - 支持 BladeX 系统模块路径代理 现在推送代码后,前端会自动部署到生产环境! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
770 B
Docker
38 lines
770 B
Docker
# 构建阶段
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
# 复制 package 文件
|
|
COPY package*.json ./
|
|
|
|
# 安装依赖(使用国内镜像加速)
|
|
RUN npm install --registry=https://registry.npmmirror.com
|
|
|
|
# 复制源码
|
|
COPY . .
|
|
|
|
# 构建生产版本
|
|
RUN npm run build
|
|
|
|
# 运行阶段:使用 Nginx 服务静态文件
|
|
FROM nginx:alpine
|
|
|
|
LABEL maintainer="JohnSion"
|
|
LABEL description="武术比赛管理系统前端"
|
|
|
|
# 复制构建产物到 Nginx 目录
|
|
COPY --from=builder /build/dist /usr/share/nginx/html
|
|
|
|
# 复制 Nginx 配置
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# 暴露端口
|
|
EXPOSE 80
|
|
|
|
# 健康检查
|
|
HEALTHCHECK --interval=30s --timeout=3s CMD wget -q --spider http://localhost/ || exit 1
|
|
|
|
# 启动 Nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|