diff --git a/sdks/go/container/Dockerfile b/sdks/go/container/Dockerfile index b3b2fbbec3a9..3d70e2834b70 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 " 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 c43eb0cb8c02..7a8c9e7e7d7e 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/