Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 优化dockerfile,可使包体积从1.1G缩小至200M #3006

Merged
merged 3 commits into from
Nov 23, 2024

Conversation

owenyang0
Copy link
Contributor

@owenyang0 owenyang0 commented Nov 21, 2024

尽量按此模板PR内容,或粘贴相关的ISSUE链接。

已知问题

  1. 基于当前Dockerfile构建后,docker包体积约1.1G,体积过大不利于容器管理浪费带宽。

解决方案

  1. 参考官方next docker部署方案,使用standalone部署方式,仅将必要文件打包

改动收益

  1. 减小Docker包体积
  2. 1.1G 缩小至 200M

具体改动

  1. 调整 next.config.jsoutputstandalone
  2. Dockerfile 增加 runner 构建步骤,仅打包必要文件

在线测试

线上运行良好,可访问我的博客体验:https://blog.owenyang.top

体积对比

image

测试确认

  • 本地开发环境测试通过
  • 生产环境构建测试通过
  • 版本号正确显示
  • 环境变量配置正常工作

Copy link

vercel bot commented Nov 21, 2024

@owenyang0 is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

@tangly1024 tangly1024 merged commit fed0aaf into tangly1024:main Nov 23, 2024
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants