- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6.2k
Add cache to container build #35697
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
base: main
Are you sure you want to change the base?
Add cache to container build #35697
Conversation
correct permissions on copied files
Avoid copying .git directory into the container
instead of running two jobs compiling the same code, run one and reuse layers
drop platforms from dryrun
| replaces #34876 and #27998 to a lesser degree. I've tried to trim down CI time further but I can either optimize for local or CI builds because dockers caching system allows to push layers to registry but it does not allow to share mounted cache in any way. I've tried using one action to do so but it did not work at all and maybe for the better as juggling the cache wouldn't be too fun if something went wrong. It would be possible to optimize for layers here (which I've sort of done) and have them pushed to registry on nightly builds then pulled during every other one but it then removes the mountable cache completely as when both are used they are unreliable (cache is empty and layers apply as if it worked). | 
| - uses: docker/setup-qemu-action@v3 | ||
| - uses: docker/setup-buildx-action@v3 | ||
| annotations: | | ||
| org.opencontainers.image.authors="maintainers@gitea.io" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just add this to the Dockerfiles instead:
LABEL org.opencontainers.image.authors="maintainers@gitea.io"Ref: https://docs.docker.com/reference/build-checks/maintainer-deprecated/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, Dockerfiles do already have a maintainer label:
Line 45 in 8085c75
| LABEL maintainer="maintainers@gitea.io" | 
It's probably better to use org.opencontainers.image.authors instead, but definitely not two labels for the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it to tag generation to avoid having implicitly marking user built containers as maintained by gitea, but I can move back into the container if it's not a concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm makes sense your way I guess. Would just like to avoid duplication.
It's not required and grows over time. Also exclude containerfiles from the copy so changes in them won't trigger layer invalidation if it's not needed
| By the way, to speed up the "github actions release", I can see a much faster approach: 
 (The container build cache can still be supported for developers who need to build the images by themselves) | 
| How would you keep it sane though? It is a good idea ( | 
| Just an idea 😄 not sure whether it brings enough value | 
| I'd say it does but inverse (binary from container) would be simpler to do (safe for windows builds). I can look at it later. Is the  | 
| 
 Agree with you. That checkout came from "Docker multi-stage (#2927)", it seems no real use case for it. 
 If removing it can make the whole system simpler, maybe it's fine to remove it. If removing it doesn't simplify, maybe it can still be kept for a while. Update: it just conflicts the GITEA_VERSION used by Makefile: 
 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM.
The new approach looks pretty cool and much clearer than before.
add mount cache directives to container builds, which speeds up local builds bypassing node and go package download entirely on second build and caching go compilation.
drop job level split on regular/rootless, which allows to reuse the previously made stage for rootless, skipping duplicate builds in CI.