Skip to content

perf(docker): improve pd/store/server image build cache efficiency#3025

Open
bitflicker64 wants to merge 2 commits into
apache:masterfrom
bitflicker64:improve-docker-build-cache
Open

perf(docker): improve pd/store/server image build cache efficiency#3025
bitflicker64 wants to merge 2 commits into
apache:masterfrom
bitflicker64:improve-docker-build-cache

Conversation

@bitflicker64
Copy link
Copy Markdown
Contributor

Purpose of the PR

close #2977

Main Changes

.dockerignore (new file)

  • Minimal, intentionally lean — only Docker-specific extras (.git, .github, compose files, docs)
  • Most patterns already covered by .gitignore, not duplicated per maintainer guidance

All 4 Dockerfiles

  • Added COPY --parents **/pom.xml ./ before COPY . . — pom layer only invalidates on pom changes, not source changes
  • Added --mount=type=cache,target=/root/.m2 on mvn package — deps cached across repeated builds
  • Removed vim, cron, service cron start, rm /var/lib/dpkg/info/libc-bin.*, dead code from runtime stage

Note: dependency:go-offline not used — inter-module deps like hg-pd-client aren't on Maven Central and would cause it to fail.

Verifying these changes

  • Need tests and can be verified as follows:
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 .

Does this PR potentially affect the following parts?

  • Dependencies (add/update license info & regenerate_known_dependencies.sh)
  • Modify configurations
  • The public API
  • Other affects (typed here)
  • Nope

Documentation Status

  • Doc - No Need

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. ci-cd Build or deploy perf labels May 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 1.56%. Comparing base (e108076) to head (4cc2e42).

❗ There is a different number of reports uploaded between BASE (e108076) and HEAD (4cc2e42). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (e108076) HEAD (4cc2e42)
3 2
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #3025       +/-   ##
============================================
- Coverage     35.85%   1.56%   -34.30%     
+ Complexity      338      43      -295     
============================================
  Files           802     780       -22     
  Lines         67995   65480     -2515     
  Branches       8902    8454      -448     
============================================
- Hits          24381    1026    -23355     
- Misses        41008   64368    +23360     
+ Partials       2606      86     -2520     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve Docker build cache efficiency for HugeGraph PD, Store, and Server images by adding Docker context filtering and BuildKit/Maven cache-related Dockerfile changes.

Changes:

  • Adds a new root .dockerignore.
  • Updates four Dockerfiles to use a pom-only copy layer and Maven cache mounts.
  • Removes some runtime packages and cleanup/startup commands from image build stages.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
.dockerignore Adds Docker build-context exclusions.
hugegraph-pd/Dockerfile Refactors PD image build layers and runtime dependency install.
hugegraph-store/Dockerfile Refactors Store image build layers and runtime dependency install.
hugegraph-server/Dockerfile Refactors Server image build layers and runtime dependency install.
hugegraph-server/Dockerfile-hstore Refactors hstore Server image build layers and runtime dependency install.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hugegraph-pd/Dockerfile
Comment thread hugegraph-store/Dockerfile
Comment thread hugegraph-server/Dockerfile
Comment thread hugegraph-server/Dockerfile-hstore
Comment thread hugegraph-pd/Dockerfile
Comment on lines +25 to 29
# Copy pom files first — layer is only invalidated when pom files change,
# keeping the Maven cache mount warm across source-only changes.
COPY --parents **/pom.xml ./
ARG MAVEN_ARGS

Comment thread .dockerignore
Comment thread hugegraph-pd/Dockerfile
Comment thread hugegraph-store/Dockerfile
Comment thread hugegraph-server/Dockerfile
Comment thread hugegraph-server/Dockerfile-hstore
- Add .dockerignore to reduce build context noise (defer to .gitignore,
  add **/target/ and Docker-specific extras explicitly)
- Refactor all 4 Dockerfiles: pom-first COPY layer + BuildKit .m2 cache mount
- Add # syntax=docker/dockerfile:1 for compatibility with older Docker versions
- Restore cron in runtime stage to preserve optional monitor support
- Remove dead code: vim, service cron start, rm libc-bin hack, set -x, pwd&&cd
- Update server-ci.yml ubuntu-22.04 -> ubuntu-latest (resolves existing TODO)
@bitflicker64 bitflicker64 requested a review from Copilot May 14, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd Build or deploy perf size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Improve Docker build cache efficiency for pd/store/server images

2 participants