10000 CI: Use GitHub actions cache in docker builds by Fijxu · Pull Request #5302 · iv-org/invidious · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

CI: Use GitHub actions cache in docker builds #5302

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

Closed
wants to merge 1 commit into from Fijxu:gha-docker-cache

Conversation

Fijxu
Copy link
Member
@Fijxu Fijxu commented May 14, 2025

We already make use of the mount cache on e2df12b to speed up the compiling on Invidious, but we can also use Github actions for the Dockerfile, which caches packages installed using apk and any other layer of the container that can be cached.

For installed packages, it will always use the same cached version (if the cache has not been used on 7 days according to https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy), so on each build, the packages are not going to be updated (https://docs.docker.com/build/cache/invalidation/#run-instructions). I personally think this is better to prevent a possible breakage on an updated package (which is probably not going to happen anyways because we use a specific alpine tag).

@Fijxu
Copy link
Member Author
Fijxu commented May 14, 2025

Seems to work fine: https://github.com/iv-org/invidious/actions/runs/15012807593/job/42184935828?pr=5302#step:5:200.

I may open another PR to improve the speed of https://github.com/iv-org/invidious/actions/runs/15012807593/workflow?pr=5302#L91 since it needs a different approach to be able to cache the layers, possible solution: https://stackoverflow.com/a/75544124

Adding cache to the build-docker job will likely save like just 5 seconds, but better than nothing I guess.

@Fijxu Fijxu marked this pull request as ready for review May 14, 2025 05:49
@Fijxu Fijxu requested a review from a team as a code owner May 14, 2025 05:49
@Fijxu Fijxu requested review from alexmaras and removed request for a team May 14, 2025 05:49
@unixfox
Copy link
Member
unixfox commented May 14, 2025

so on each build, the packages are not going to be updated

That's an issue if you need to quickly patch a vulnerability in a package or dependency.

@unixfox unixfox requested review from unixfox and syeopite and removed request for alexmaras May 14, 2025 15:20
Copy link
Member
@syeopite syeopite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an issue if you need to quickly patch a vulnerability in a package or dependency.

Yeah this is a problem. Though Crystal and Invidious also doesn't have too many system dependencies so I'm not sure how large of a problem it'd really be.

The container for x86-64 already builds in ~ 5 minutes and 30 seconds which is imo is more than good enough for an automated image build. Any improvements to that is pretty negligible.

Instead I think it'll make more sense to optimize the arm64 build process (mainly by switching away from QEMU to the native arm runner on Github Actions) which takes almost 30 minutes to complete.

EDIT: Accidentally used the duration for building the test images during CI instead off the actual images for nightly/stable builds

@Fijxu
Copy link
Member Author
Fijxu commented May 15, 2025

Though Crystal and Invidious also doesn't have too many system dependencies so I'm not sure how large of a problem it'd really be.

That's an issue if you need to quickly patch a vulnerability in a package or dependency.

Yeah, getting a vulnerability with the low amount of packages Invidious uses is pretty unlikely, but there is a still a possibility, some day, a vulnerability on some package may be released and abused, and if we wanted to release a fast fix with the package already patched on Alpine Linux repositories, we would need to delete the caches on https://github.com/iv-org/invidious/actions/caches?query=sort%3Acreated-desc manually before letting GH Actions build the Invidious container image, which doesn't seem practical at all.

I was searching about how to only ignore cache for the RUN command, but that is not possible. What it's possible is to prevent cache of a stage (moby/moby#1996 (comment)) but that will just complicate the Dockerfile.

Instead I think it'll make more sense to optimize the arm64 build process (mainly by switching away from QEMU to the native arm runner on Github Actions) which takes almost 10 minutes to complete.

I'll go with this in a new PR instead.

@Fijxu Fijxu closed this May 15, 2025
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.

3 participants
0