At a previous company, we containerized applications by writing a Dockerfile, building the source code, and then building and pushing the image with kaniko.
At my current company, we use buildpacks to simplify CI/CD.
I want to take this opportunity to briefly explain what a buildpack is.
The Spring Boot documentation explains it in detail, as shown below.

It says that buildpacks can create images without a Dockerfile.
With the Maven plugin, you can define the bootBuildImage task in pom.xml; with Gradle, you can define it in build.gradle and use it in your CI/CD pipeline.

Following the example, you can specify the bootBuildImage task and build the image with the command below.
./gradelw bootBuildImage
As the official documentation also explains, you can change the JVM options as follows!
tasks.named<BootBuildImage>("bootBuildImage") {
environment.set(mapOf(
"BPE_DELIM_JAVA_TOOL_OPTIONS" to " ",
"BPE_APPEND_JAVA_TOOL_OPTIONS" to "-XX:+HeapDumpOnOutOfMemoryError"
))
}
Using it at work has simplified the CI/CD pipeline itself and made it easier to read. But it seems I cannot perform the image size optimizations I would do in a Dockerfile, such as splitting stages and reducing the number of layers.
Does anyone know a way to reduce image size while still using buildpacks?