Skip to content

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

@imbajin

Description

@imbajin

Background

The Docker images for hugegraph-pd, hugegraph-store, and hugegraph-server currently build with this pattern:

  1. COPY . /pkg
  2. RUN mvn package ...
  3. Copy build outputs into runtime image

This causes low cache efficiency:

  • Any repository file change (even non-Java files) can invalidate the COPY layer.
  • The expensive mvn package step is re-run too often.
  • CI time stays high even when Java code is unchanged.

Goal

Improve Docker build cache hit rate and reduce unnecessary Maven rebuild time, without changing image runtime behavior.

Scope (Starter Task / Phase A)

Please focus on the low-risk, high-impact subset:

  • Improve .dockerignore to exclude files that should not affect image build cache (for example: .git/, IDE files, temp files).
  • Refactor Dockerfile layer order so dependency-related files are copied before source files where practical.
  • Use BuildKit Maven cache mount (--mount=type=cache,target=/root/.m2) in Maven build steps.
  • Keep existing image entrypoints/ports/runtime behavior unchanged.

Out of Scope (Do NOT include in this issue)

  • Full artifact pipeline split ("build once, package many images").
  • Cross-repo CI architecture redesign.
  • New release logic or tag strategy changes.

Deliverables

  • A PR with Dockerfile and/or .dockerignore updates.
  • A short before/after note from CI showing cache behavior and build time delta.

Acceptance Criteria

  • A second build with no Java source changes shows clear improvement in build time and/or cache hits.
  • Existing image smoke/integration checks still pass.
  • No functional regression in generated images.

Suggested Starting Points

  • hugegraph-pd/Dockerfile
  • hugegraph-store/Dockerfile
  • hugegraph-server/Dockerfile
  • hugegraph-server/Dockerfile-hstore

If the scope starts growing, keep this issue focused on Phase A and open follow-up issues for larger refactors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions