Files
martial-web/Dockerfile
n72595987@gmail.com 36116e0973
Some checks failed
continuous-integration/drone/push Build is failing
修复前端构建:正确配置 BladeX 私有 npm registry
问题:
- Dockerfile 中 npm install 时未复制 .npmrc 文件
- 使用 --registry 参数覆盖了 .npmrc 中的私有 registry 配置
- 导致无法下载 @saber scope 的私有包,报 E401 认证错误

解决方案:
- Dockerfile: 在 npm install 前复制 .npmrc 文件
- Dockerfile: 移除 --registry 参数,使用 .npmrc 中的配置
- .drone.yml: 同样移除 --registry 参数

现在 npm 会正确使用:
- @saber 包 -> https://center.javablade.com (私有 registry)
- 其他包 -> npm 默认源

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 17:57:25 +08:00

39 lines
777 B
Docker

# 构建阶段
FROM node:18-alpine AS builder
WORKDIR /build
# 复制 package 文件和 npm 配置
COPY package*.json ./
COPY .npmrc ./
# 安装依赖(.npmrc 中已配置私有 registry 和认证)
RUN npm install
# 复制源码
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;"]