This is an automated email from the ASF dual-hosted git repository.

Abacn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 13bbd5c4d67 Reduce number of layers for Beam container images (#38440)
13bbd5c4d67 is described below

commit 13bbd5c4d67c349f2c8184d24d2ba0cf3bbf2a15
Author: Yi Hu <[email protected]>
AuthorDate: Mon May 11 12:42:53 2026 -0400

    Reduce number of layers for Beam container images (#38440)
---
 sdks/go/container/Dockerfile   | 10 +++++++---
 sdks/java/container/Dockerfile | 31 +++++++++++++++----------------
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/sdks/go/container/Dockerfile b/sdks/go/container/Dockerfile
index b3b2fbbec3a..3d70e2834b7 100644
--- a/sdks/go/container/Dockerfile
+++ b/sdks/go/container/Dockerfile
@@ -16,7 +16,12 @@
 # limitations under the License.
 ###############################################################################
 
-FROM gcr.io/distroless/base-nossl-debian12:latest
+FROM gcr.io/distroless/base-nossl-debian12:latest AS base_image
+
+# Distroless base image has many layers. Squash into single layer
+FROM scratch
+COPY --from=base_image / /
+
 LABEL Author "Apache Beam <[email protected]>"
 
 ARG TARGETOS
@@ -24,8 +29,7 @@ ARG TARGETARCH
 
 ADD target/${TARGETOS}_${TARGETARCH}/boot /opt/apache/beam/
 
-COPY target/LICENSE /opt/apache/beam/
-COPY target/NOTICE /opt/apache/beam/
+COPY target/LICENSE target/NOTICE /opt/apache/beam/
 
 # Add Go licenses.
 COPY target/go-licenses/* /opt/apache/beam/third_party_licenses/golang/
diff --git a/sdks/java/container/Dockerfile b/sdks/java/container/Dockerfile
index c43eb0cb8c0..7a8c9e7e7d7 100644
--- a/sdks/java/container/Dockerfile
+++ b/sdks/java/container/Dockerfile
@@ -24,22 +24,21 @@ ARG TARGETARCH
 
 ARG pull_licenses
 
-ADD target/slf4j-api.jar /opt/apache/beam/jars/
-ADD target/slf4j-jdk14.jar /opt/apache/beam/jars/
-ADD target/jcl-over-slf4j.jar /opt/apache/beam/jars/
-ADD target/log4j-over-slf4j.jar /opt/apache/beam/jars/
-ADD target/log4j-to-slf4j.jar /opt/apache/beam/jars/
-ADD target/beam-sdks-java-harness.jar /opt/apache/beam/jars/
-
-# Required to use jamm as a javaagent to get accurate object size measuring
-# COPY fails if file is not found, so use a wildcard for open-module-agent.jar
-# since it is only included in Java 9+ containers
-COPY target/jamm.jar target/open-module-agent.jar /opt/apache/beam/jars/
-
-COPY target/${TARGETOS}_${TARGETARCH}/boot /opt/apache/beam/
-
-COPY target/LICENSE /opt/apache/beam/
-COPY target/NOTICE /opt/apache/beam/
+# Dependency jars
+COPY target/slf4j-api.jar \
+     target/slf4j-jdk14.jar \
+     target/jcl-over-slf4j.jar \
+     target/log4j-over-slf4j.jar \
+     target/log4j-to-slf4j.jar \
+     # Required to use jamm as a javaagent to get accurate object size 
measuring
+     target/jamm.jar \
+     /opt/apache/beam/jars/
+
+# Built jars
+COPY target/open-module-agent.jar target/beam-sdks-java-harness.jar 
/opt/apache/beam/jars/
+
+# Built binary with licenses
+COPY target/${TARGETOS}_${TARGETARCH}/boot target/LICENSE target/NOTICE 
/opt/apache/beam/
 
 # copy third party licenses
 ADD target/third_party_licenses /opt/apache/beam/third_party_licenses/

Reply via email to