-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(docker): improve debian-dev Dockerfile build caching #12807
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?
Conversation
a9c6280 to
7d03549
Compare
Optimize Docker layer caching to significantly reduce rebuild time when only source code changes: - Separate dependency installation from source code copy - Build brotli in build stage instead of runtime stage - Copy only dependency-related files before running make deps Signed-off-by: Sihyeon Jang <sihyeon.jang@navercorp.com>
7d03549 to
ed1042a
Compare
Baoyuantop
left a comment
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.
Is there a significant change in the size of the image?
docker/debian-dev/Dockerfile
Outdated
| COPY ${INSTALL_BROTLI} /install-brotli.sh | ||
| RUN chmod +x /install-brotli.sh \ | ||
| && cd / && ./install-brotli.sh && rm -rf /install-brotli.sh | ||
| RUN echo /usr/local/brotli/lib | tee /etc/ld.so.conf.d/brotli.conf \ |
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.
Please note the handling of the lib64 directory in the original install-brotli.sh script. https://github.com/apache/apisix/blob/master/docker/debian-dev/install-brotli.sh#L28-L32
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.
Thanks for your review! I handled it.
Add conditional logic to check for lib64 directory existence, matching the behavior of the original install-brotli.sh script. Signed-off-by: Sihyeon Jang <sihyeon.jang@navercorp.com>
|
@Baoyuantop The main benefit of this PR is improved build caching - brotli is now built once in the build stage and reused across rebuilds, rather than being rebuilt every time in the runtime stage. The image size remains similar because we're copying the same brotli binaries, just from a different stage. |
Description
Optimize the debian-dev Dockerfile to leverage Docker layer caching more effectively.
Previously, any code change would invalidate the cache and trigger a full rebuild including
make depsand brotli compilation.What this PR does:
Separate dependency files from source code: Copy only
Makefile,rockspec,.requirements, andinstall-dependencies.shbefore runningmake deps, so dependencies are cached unless these files change.Move brotli build to build stage: Previously, brotli was built in the runtime stage, requiring installation of ~80 build packages (gcc, cmake, etc.) every time. Now it's built once in the build stage and only the binary is copied to runtime.
Performance improvement:
Which issue(s) this PR fixes:
Fixes #
Checklist