-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Makefile+tools: reduce LND linter docker image size by 85% from 2330 MB
to 355 MB
#10202
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: master
Are you sure you want to change the base?
Makefile+tools: reduce LND linter docker image size by 85% from 2330 MB
to 355 MB
#10202
Conversation
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.
Summary of Changes
Hello @mohamedawnallah, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request aims to drastically reduce the size of the LND linter Docker image. This is achieved by migrating to an Alpine-based Go image and optimizing the build process within the Dockerfile, complemented by corresponding adjustments in the Makefile for cache handling. The primary impact is a more efficient CI/CD pipeline due to smaller image downloads and reduced storage requirements.
Highlights
- Significant Image Size Reduction: Reduced the LND linter Docker image size by 85%, from 2330 MB to 355 MB, leading to faster downloads and reduced storage.
- Base Image Migration: Switched the
tools/Dockerfile
base image from the largergolang:1.24.6
to the more lightweightgolang:1.24.6-alpine
. - Build Process Optimization: Implemented
apk
for package installation and added post-build cleanup steps in the Dockerfile to remove build caches and temporary files, further minimizing the final image size. - Makefile Cache Alignment: Updated the
Makefile
to align Docker volume mounts for Go build caches with the new Dockerfile structure, and removed the explicitGOMODCACHE
mount.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request significantly reduces the LND linter docker image size by switching to an Alpine base image and implementing multi-stage build-like optimizations within a single RUN
command to clean up build dependencies and caches. The changes are well-executed and effective. I have one minor suggestion for the tools/Dockerfile
to further optimize the image size by handling the apk
cache more efficiently. The related changes in the Makefile
are correct and align with the new Docker image structure.
|
||
COPY . /tmp/tools | ||
RUN apk update && apk add --no-cache git |
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.
While this change correctly switches to apk
for the Alpine base image, there's a small improvement to further reduce the image size. The apk update
command creates a cache in /var/cache/apk/
. In your later RUN
command on line 17, you remove this cache with rm -rf /var/cache/apk/*
.
However, because the removal happens in a different RUN
instruction (and thus a different Docker layer), the cache files from this layer will still be part of the image, even though they are marked as deleted in a later layer.
To avoid this and make the image even smaller, you should perform the cleanup in the same RUN
instruction. After applying the suggestion below, you can remove the rm -rf /var/cache/apk/*
from the RUN
command on lines 11-18.
RUN apk update && apk add --no-cache git && rm -rf /var/cache/apk/*
Change Description
Description of change / link to associated issue.
Steps to Test
Steps for reviewers to follow to test the change.
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.