perf: optimize Docker build and fix security vulnerabilities#536
Merged
Conversation
- Split multi-platform Docker build into parallel jobs (amd64, arm64) - Add timeout protection to all jobs (30min npm, 60min amd64, 180min arm64) - Optimize Dockerfile with security improvements (non-root user, healthcheck) - Update critical dependencies (@modelcontextprotocol/sdk, glob, tar, react-router-dom) - Reduce build time by ~50% (6h → 3h) - Fix 10 security vulnerabilities (6 high, 4 moderate) Fixes: Docker Hub publish timeout issue Fixes: Dependabot security alerts Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Member
Author
问题描述
解决方案1. Docker 构建优化核心改进
Dockerfile 安全加固 # 非 root 用户运行
RUN addgroup -g 1000 app && adduser -D -u 1000 -G app app
USER app
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --spider http://localhost:5203/health || exit 1
# 减少镜像层数
RUN npm install -g @promptx/mcp-server && \
mkdir -p /data && \
chown -R app:app /data预期效果
2. 安全依赖更新已更新的包
修复成果 通过更新上述依赖包,显著减少了安全漏洞数量:
注: GitHub Dependabot 和 pnpm audit 使用不同的漏洞数据库,数字可能有差异。GitHub Dependabot 显示的原始漏洞数为 28 个。 测试验证构建测试pnpm build
单元测试pnpm test
安全审计pnpm audit
变更文件核心文件:
依赖更新:
剩余漏洞说明部分漏洞来自深层依赖链,无法直接修复。 典型案例: 后续建议:
这些深层依赖需要上游包更新,不影响本次修复的核心功能。 检查清单
影响范围受影响的包 (通过 changeset 管理):
用户影响:
部署建议合并后建议:
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Description
Docker Build Timeout
Security Vulnerabilities
Solution
1. Docker Build Optimization
Core Improvements
Parallel Multi-Platform Builds: Split single job into 3 parallel jobs
publish-docker-amd64(60min timeout)publish-docker-arm64(180min timeout)publish-docker-manifest(10min timeout, merges images)Timeout Protection:
Build Workflow Optimization:
docker buildx imagetoolsDockerfile Security Hardening
Expected Impact
2. Security Dependency Updates
Updated Packages
Results
Significantly reduced security vulnerabilities by updating the above dependencies:
Note: GitHub Dependabot and pnpm audit use different vulnerability databases, so numbers may differ. GitHub Dependabot shows 28 original vulnerabilities.
Testing & Validation
Build Test
Unit Tests
pnpm testSecurity Audit
Changed Files
Core Files:
Dependency Updates:
Remaining Vulnerabilities
Some vulnerabilities come from deep dependency chains and cannot be directly fixed.
Example:
Recommendations:
These deep dependencies require upstream package updates and don't affect core functionality.
Checklist
Impact Scope
Affected Packages (managed via changeset):
User Impact:
Post-Merge Recommendations
After merging: