spring-projects / spring-projects/spring-boot

Support caching build layers to an image

Open
#28,386 4 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

The spring-boot:build-image Maven goal and bootBuildImage Gradle task configure the CNB builder to cache layers created by buildpacks to make subsequent image builds run faster. Currently the cache is stored as named volume in the Docker daemon. This doesn't work well when running builds on CI/CD environments, since Docker daemons might be ephemeral or builds might run on different worker nodes.

To better support running builds on CI/CD environments, the CNB builder supports storing cached layers in an OCI image. The Boot plugins could be enhanced to support this configuration also.

For Maven, the build configuration would be:

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <image>
            <buildCache>
              <image>
                <name>repo.example.com/cache-${project.artifactId}:latest</name>
              </image>
            </buildCache>
          </image>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

For Gradle, the build configuration would be:

bootBuildImage {
  buildCache {
    image {
      name = "repo.example.com/cache-${rootProject.name}:latest"
    }
  }
}

Note: the image option is not available for the launch cache, only for the build cache.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the spring-boot:build-image Maven goal and bootBuildImage Gradle task, then trace how each configures CNB build caching and Docker volumes. Add support for selecting an OCI image for the build cache in both plugin configurations, while leaving launch-cache image support unavailable. Verify the Maven and Gradle examples and confirm cached layers can be reused across workers.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, spring-boot
Domain
build-system, devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.