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

👷 build: optimize image size under glibc env #4025

Merged
merged 37 commits into from
Sep 27, 2024

Conversation

hezhijie0327
Copy link
Contributor

@hezhijie0327 hezhijie0327 commented Sep 19, 2024

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

承接 #3926 中提到的新方案

  1. 沿用 Rollback 回 node:20-slim 前的方案,继承其所有特性的同时保留与 node:20-alpine 等同的小体积
    a. 从 node:20-slim 提取 nodeproxychains 的依赖项,移除对于正式环境无用的 nodejs 开发环境(如 npm 等),仅保留 node 二进制
    b. 保留 Rootless 特性,nextjs:nodejs
  2. 将应用层 Image 改用基于 glibcbusybox:latest 进行应用环境准备及用户创建
  3. 将最终 Image 使用 scratch 进行重新封装,镜像压缩
  4. [TODO] 引入基于 js 的启动器
    a. 简化 PROXY_URL DNS 解析处理逻辑,使用 dns
    b. 添加额外的诊断信息,如 PROXY_URL DNS 解析失败等
    c. 添加 isValidSSL function,用于后续检测 OSS 及 Auth URL 是否配置正确,检测异常提示添加 NODE_TLS_REJECT_UNAUTHORIZED="0" 或映射 /etc/ssl/certs/ca-certificates.crt
    d. 添加对 OSS 及 Auth URL SSL 证书检测(S3_ENDPOINT, S3_PUBLIC_DOMAIN, *_ISSUER
  5. 支持自签证书,将 node 内建 CA 改用系统 CA,可通过映射主机 /etc/ssl/certs/ca-certificates.crt 即可完成证书信任

Note:
暂未合并 #3926 新加入的 ENV [TODO] 已并入

📝 补充信息 | Additional Information

镜像大小
image
启动日志
image

Copy link

vercel bot commented Sep 19, 2024

@hezhijie0327 is attempting to deploy a commit to the LobeHub Pro Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 19, 2024
@lobehubbot
Copy link
Member

👍 @hezhijie0327

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.48%. Comparing base (4f6e20d) to head (deb3ea8).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #4025     +/-   ##
=========================================
  Coverage   92.48%   92.48%             
=========================================
  Files         482      482             
  Lines       34488    34488             
  Branches     2288     3381   +1093     
=========================================
  Hits        31896    31896             
  Misses       2592     2592             
Flag Coverage Δ
app 92.48% <ø> (ø)
server 97.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Sep 19, 2024
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Sep 19, 2024
@hezhijie0327
Copy link
Contributor Author

@arvinxx 改造好了,新引入了一个 scripts/serverLauncher/startServer.js 启动器用于启动前环境检测,进行基础的 Troubleshooting

  1. ProxyChains 环境检测
    a. 当 PROXY_URLIP 或解析成功时,提示当前所有 Outbound 流量经由代理服务器
    image
    b. 当 PROXY_URL 为域名时,解析错误,进行抛错,提示用户检查 DNS 服务器
    image

  2. TLS 证书检测(S3_ENDPOINT, S3_PUBLIC_DOMAIN, *_ISSUER
    a. 当 TLS 检测通过后,提示 TLS 验证成功
    image
    b. 当 TLS 为自签证书或证书过期,进行抛错,提示用户更改 NODE_TLS_REJECT_UNAUTHORIZED="0" 或映射 /etc/ssl/certs/ca-certificates.crt 进容器
    image
    c. 当映射的 /etc/ssl/certs/ca-certificates.crt 无效时,进行抛错,提示检查 /etc/ssl/certs/ca-certificates.crt 是否正确
    image
    d. 当 URL 测试连接失败时,抛警告,提示用户检查网络设置或防火墙
    image
    e. 当 URL 为空,抛警告,提示用户TLS检查将忽略并建议检查环境变量是否设置正确
    image
    f. 当 URL 为非 HTTPS 时,抛警告,仅提示用户TLS检查将忽略
    image

Dockerfile Outdated Show resolved Hide resolved
@arvinxx arvinxx merged commit 7eecb23 into lobehub:main Sep 27, 2024
5 of 7 checks passed
@lobehubbot
Copy link
Member

❤️ Great PR @hezhijie0327 ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 discord,然后私信 @arvinxx@canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。

@lobehubbot
Copy link
Member

🎉 This PR is included in version 1.20.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

arvinxx added a commit that referenced this pull request Sep 27, 2024
arvinxx added a commit that referenced this pull request Sep 27, 2024
This reverts commit 7eecb23.
@hezhijie0327 hezhijie0327 deleted the dockerfile branch September 27, 2024 13:55
cookieY added a commit to cookieY/lobe-chat that referenced this pull request Sep 29, 2024
* 'main' of github.com:cookieY/lobe-chat:
  🔖 chore(release): v1.20.5 [skip ci]
  📝 docs: Update docker-compose to use new LOGTO env (lobehub#4199)
  👷 build: optimize image size under glibc env (lobehub#4176)
  🔖 chore(release): v1.20.4 [skip ci]
  ⚡ perf: remove some blur style to improve performance (lobehub#4085)
  Update dependency unstructured-client to ^0.18.0 (lobehub#4065)
  📝 docs: Add deployment using ZITADEL authentication services (lobehub#4081)
  🔖 chore(release): v1.20.3 [skip ci]
  🐛 fix: improve delete orphan chunks when delete files (lobehub#4179)
  📝 docs: add new configuration item of clerk singup (lobehub#4188)
  📝 docs: update model-provider document (lobehub#4181)
  🔖 chore(release): v1.20.2 [skip ci]
  💄 style: add zhipu glm-4-flashx model (lobehub#4173)
  👷 build: revert lobehub#4025 (lobehub#4175)
  🔖 chore(release): v1.20.1 [skip ci]
  👷 build: optimize image size under `glibc` env (lobehub#4025)
  🔖 chore(release): v1.20.0 [skip ci]
  ✨ feat: add Hunyuan(Tencent) model provider (lobehub#4147)
  🔖 chore(release): v1.19.36 [skip ci]
  💄 style: add llama3.2 model for openrouter provider (lobehub#4151)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants