zeel2104 opened a new pull request, #2981:
URL: https://github.com/apache/hugegraph/pull/2981
## Purpose of the PR
- close #2977
- Improve Docker build cache efficiency for pd/store/server images in Phase
A scope without changing runtime behavior.
- Reduce unnecessary cache invalidation caused by broad source copying and
reuse Maven dependencies/layers more effectively across repeated builds.
## Main Changes
- Added a root `.dockerignore` to exclude cache-noisy files that should not
affect Docker image builds, while keeping required Maven module sources in the
build context.
- Refactored `hugegraph-pd/Dockerfile`, `hugegraph-store/Dockerfile`,
`hugegraph-server/Dockerfile`, and `hugegraph-server/Dockerfile-hstore` to copy
dependency-related `pom.xml` files before copying the full source tree.
- Added BuildKit Maven cache mounts with
`--mount=type=cache,target=/root/.m2` for both dependency resolution and
package steps.
- Kept existing runtime image behavior unchanged, including entrypoints,
ports, and container startup flow.
- During validation, narrowed an overly broad `.dockerignore` rule so Maven
module directories such as `hugegraph-server/hugegraph-dist` remain included in
the Docker build context.
## Verifying these changes
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
- [ ] Already covered by existing tests, such as *(please modify tests
here)*.
- [x] Need tests and can be verified as follows:
- Build all four images successfully with `DOCKER_BUILDKIT=1`:
- `docker build -f hugegraph-pd/Dockerfile -t hugegraph-pd:cache-test
.`
- `docker build -f hugegraph-store/Dockerfile -t
hugegraph-store:cache-test .`
- `docker build -f hugegraph-server/Dockerfile -t
hugegraph-server:cache-test .`
- `docker build -f hugegraph-server/Dockerfile-hstore -t
hugegraph-server-hstore:cache-test .`
- Rebuild images back-to-back without Java source changes and compare
timings/cache reuse:
- `hugegraph-server/Dockerfile-hstore`: `5.77s -> 2.84s` (`~50.7%`
faster)
- `hugegraph-pd/Dockerfile`: `7.79s -> 3.59s` (`~53.9%` faster)
- Confirm build logs show cached reuse for the pom-first dependency
layer, Maven cache mount, and later package/runtime layers.
## Does this PR potentially affect the following parts?
- [ ] Dependencies ([add/update
license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses)
info &
[regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh))
- [ ] Modify configurations
- [ ] The public API
- [ ] Other affects (typed here)
- [x] Nope
## Documentation Status
- [ ] `Doc - TODO`
- [ ] `Doc - Done`
- [x] `Doc - No Need`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]