-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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(docker): optimize; add Chromium bundled ver #9626
Conversation
Signed-off-by: Rongrong <i@rong.moe>
Signed-off-by: Rongrong <i@rong.moe>
Signed-off-by: Rongrong <i@rong.moe>
Signed-off-by: Rongrong <i@rong.moe>
Signed-off-by: Rongrong <i@rong.moe>
I've done some additional optimization (refer to the modified issue description) to obtain a >1min speedup. I've also requested a secondary run attempt to see if it helps solve the multi-arch caching problem and it seemed to help! |
Signed-off-by: Rongrong <i@rong.moe>
I am still figuring out if the image size of the Chromium-bundled version can be further shrunk. Refer to puppeteer/puppeteer#7822 (comment) |
for Chromium-bundled version Signed-off-by: Rongrong <i@rong.moe>
OK. Now I have minimized the dependencies of the bundled Chromium. ~50MB is saved from the compressed image size (~130MB from the extracted image size). I've also done some tests to prove that it still works fine with minimized dependencies. To verify that it works fine, check https:// |
I believe that I've fixed the cache issue and a cached build (with routes and |
Now the plan died young. I will no longer pay my effort on it until it deserves. But there does be a preview: master...Rongronggg9:railway-ci https://railway.app/changelog/2022-05-27
https://blog.railway.app/p/updates-on-plans
|
Since Railway decided on this move, it will lose its competitiveness among other free hosting platforms that can be found on https://free-for.dev. These are just a few from there for a brief comparison:
The "banned dependency" also hit me for deploying RSSHub on Railway at the end of November last year. I've asked the support to review this. It was escalated to the upper staff and I haven't received a single word since then. For me, their detection system feels like "ban-everything-i-don't-like-on-steroids", e.g., one of their customer asked |
该 PR 相关 Issue / Involved issue
Close #7612
Close #7613
完整路由地址 / Example for the proposed route(s)
新 RSS 检查列表 / New RSS Script Checklist
Puppeteer
说明 / Note
Bump Debian from stretch to
busterbullseyenode:14-slim
is based on Debian stretch, which will be EOL after 2022/6/30.Bump node from 14 to 16
#9626 (comment)
Optimizations
Rewrite Dockerfile
Rewrote the Dockerfile to speed up the build process and maximize the cache hit rate and concurrency. Some unnecessary dependencies are no longer installed. Typically speeds up the build workflow by >5min (initial cache miss builds).
Check the comments in Dockerfile for more details.
Optimize
minify-docker.js
Only copy those files in
node_modules/
. Typically speeds up the build workflow by >30s.Separate the minifying stage and only install production deps in the
dep-builder
stageThe separate stage
docker-minifier
has only necessary dependencies ofminify-docker.js
and thedep-builder
stage no longer needs dev dependencies. Thus, installing fewer dependencies effectively cuts down the build time. It also helps further shrink the cache size, which saves GitHub Actions cache space and speeds up the cache export process.Typically speeds up the build workflow by >1min (initial cache miss builds).
Add Chromium-bundled version
There are 4 reasons why we should build a Chromium-bundled version:
browserless/chrome
is unbelievably huge and clumsy (~900MB compressed size), which makes pulling its image a painful work, while the Chromium-bundled version is pretty light-weighted (~270MB~220MB compressed size, of which ~70MB is RSSHub and its deps).browserless/chrome
consumes more memory. Even if it is inactive, it still eats >100M happily, not to mention the time when it is active.browserless/chrome
, instead, "Each version of Puppeteer bundles a specific version of Chromium – the only version it is guaranteed to work with". Thus, there might be some potential issues.browserless/chrome
as another service and get them connected, but the bad news is that it will be exposed to the Internet (so unnecessary and dangerous!). If this PR gets merged, I will create another PR to make the deployment to Railway.app easier.The Chromium-bundled Docker image is able to reuse all caches from the ordinary image to speed up its build progress. Typically, only needs <1min even if the cache for Chromium misses.
The previous Dockerfile has been unable to build Chromium-bundled images for a long time, so this is also a fix.
I did not change the
docker-compose.yml
to adopt the Chromium-bundled version but just added some prompts. If such a change is considered acceptable, I may also change it to use the Chromium-bundled version by default.To verify that it works fine, check https://
<REDACTED>
.up.railway.app/pincong/hotNote about unintended cache miss on some arch:
I've noticed this issue for a long time. I've managed to test using registry cache instead of GitHub Actions cache, only to find that nothing changed:
moby/buildkit#2822
Thus, even though I managed to adopt a lot of caching techniques, non-initial builds are still sometimes as slow as initial ones.
It seems that dropping one arch may help since usually only one arch loses its cache. But that's not cool before figuring out how many users still have their ARMv7 devices running RSSHub. (only the repo owner can check the last pull time of each tag and each arch on Docker Hub)