Skip to content

Commit 3149d95

Browse files
jacobsalwaydongjoon-hyun
authored andcommitted
[SPARK-51520][K8S] Use JRE to reduce size of Docker image
### What changes were proposed in this pull request? * Switch to Azul JRE to save ~100 megabytes on the final runtime image * Add a Buildkit cache mount for the Gradle cache to speed up local Docker builds during development ### Why are the changes needed? The image is currently quite large at ~500 megabytes ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Tested locally ### Was this patch authored or co-authored using generative AI tooling? No Closes #167 from jacobsalway/use-jre-to-reduce-docker-image-size. Authored-by: Jacob Salway <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent aa76c01 commit 3149d95

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

build-tools/docker/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
# limitations under the License.
1616
#
1717
FROM gradle:8.13-jdk17-noble AS builder
18+
1819
WORKDIR /app
20+
1921
COPY . .
20-
RUN ./gradlew clean build -x check
2122

22-
FROM azul/zulu-openjdk:21
23+
RUN --mount=type=cache,target=/home/gradle/.gradle/caches gradle --no-daemon clean build -x check
24+
25+
FROM azul/zulu-openjdk:21-jre
26+
2327
ARG APP_VERSION=0.1.0-SNAPSHOT
2428
ARG SPARK_UID=185
29+
2530
LABEL org.opencontainers.image.authors="Apache Spark project <[email protected]>"
2631
LABEL org.opencontainers.image.licenses="Apache-2.0"
2732
LABEL org.opencontainers.image.ref.name="Apache Spark Kubernetes Operator"
@@ -32,14 +37,16 @@ ENV SPARK_OPERATOR_WORK_DIR=/opt/spark-operator/operator
3237
ENV SPARK_OPERATOR_JAR=spark-kubernetes-operator.jar
3338

3439
WORKDIR $SPARK_OPERATOR_WORK_DIR
40+
3541
RUN groupadd --system --gid=$SPARK_UID spark && \
3642
useradd --system --home-dir $SPARK_OPERATOR_HOME --uid=$SPARK_UID --gid=spark spark && \
3743
chown -R spark:spark $SPARK_OPERATOR_HOME
3844

3945
COPY --from=builder --chown=spark:spark /app/spark-operator/build/libs/spark-kubernetes-operator-$APP_VERSION-all.jar $SPARK_OPERATOR_JAR
4046
COPY --from=builder --chown=spark:spark /app/build-tools/docker/docker-entrypoint.sh .
4147

42-
4348
USER spark
49+
4450
ENTRYPOINT ["/opt/spark-operator/operator/docker-entrypoint.sh"]
51+
4552
CMD ["help"]

0 commit comments

Comments
 (0)