Skip to content

Commit

Permalink
Build in stages to shed 9gb from the jvm base builder image (#12649)
Browse files Browse the repository at this point in the history
This PR reduces the final `base-builder-jvm` image by 9GB.

Careful review and full integration testing across oss-fuzz projects are
required before merging, obviously.

This worked on two projects I was interested in. One that used
`@FuzzTest` and one that used `fuzzerTestOneInput`
  • Loading branch information
tballison authored Nov 15, 2024
1 parent 1de481b commit d6f73fb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions infra/base-images/base-builder-jvm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder
FROM gcr.io/oss-fuzz-base/base-builder AS base

ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64
ENV JAVA_15_HOME /usr/lib/jvm/java-15-openjdk-amd64
Expand All @@ -27,6 +27,7 @@ RUN install_java.sh

RUN chmod 777 /usr/local/bin && chmod 777 /usr/local/lib

FROM base AS builder
RUN useradd -m jazzer_user

USER jazzer_user
Expand Down Expand Up @@ -54,10 +55,12 @@ RUN cp $(bazel cquery --output=files //src/main/java/com/code_intelligence/jazze
cp $(bazel cquery --output=files //deploy:jazzer-api) $JAZZER_API_PATH && \
cp $(bazel cquery --output=files //deploy:jazzer-junit) $JAZZER_JUNIT_PATH

USER root
FROM base AS final

RUN rm -rf /home/jazzer_user/.cache/bazel /home/jazzer_user/.cache/bazelisk && \
rm -rf $SRC/jazzer
COPY --from=builder /usr/local/bin/jazzer_agent_deploy.jar /usr/local/bin/jazzer_agent_deploy.jar
COPY --from=builder /usr/local/bin/jazzer_driver /usr/local/bin/jazzer_driver
COPY --from=builder $JAZZER_API_PATH $JAZZER_API_PATH
COPY --from=builder $JAZZER_JUNIT_PATH $JAZZER_JUNIT_PATH

RUN chmod 755 /usr/local/bin && chmod 755 /usr/local/lib

Expand Down

0 comments on commit d6f73fb

Please sign in to comment.