1*33edd672SMark# Copyright 2021 Code Intelligence GmbH 2*33edd672SMark# 3*33edd672SMark# Licensed under the Apache License, Version 2.0 (the "License"); 4*33edd672SMark# you may not use this file except in compliance with the License. 5*33edd672SMark# You may obtain a copy of the License at 6*33edd672SMark# 7*33edd672SMark# http://www.apache.org/licenses/LICENSE-2.0 8*33edd672SMark# 9*33edd672SMark# Unless required by applicable law or agreed to in writing, software 10*33edd672SMark# distributed under the License is distributed on an "AS IS" BASIS, 11*33edd672SMark# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*33edd672SMark# See the License for the specific language governing permissions and 13*33edd672SMark# limitations under the License. 14*33edd672SMark 15*33edd672SMarkFROM ubuntu:20.04 AS builder 16*33edd672SMark 17*33edd672SMarkENV DEBIAN_FRONTEND=noninteractive 18*33edd672SMarkRUN apt-get update && apt-get install -y curl git python3 openjdk-17-jdk-headless 19*33edd672SMark 20*33edd672SMarkWORKDIR /root 21*33edd672SMarkRUN curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.15.0/bazelisk-linux-amd64 -o /usr/bin/bazelisk && \ 22*33edd672SMark chmod +x /usr/bin/bazelisk && \ 23*33edd672SMark git clone --depth=1 https://github.com/CodeIntelligenceTesting/jazzer.git && \ 24*33edd672SMark cd jazzer && \ 25*33edd672SMark # The LLVM toolchain requires ld and ld.gold to exist, but does not use them. 26*33edd672SMark touch /usr/bin/ld && \ 27*33edd672SMark touch /usr/bin/ld.gold && \ 28*33edd672SMark bazelisk build --config=docker //launcher:jazzer && \ 29*33edd672SMark mkdir -p /app && \ 30*33edd672SMark cp $(bazelisk cquery --config=docker --output=files //src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar) /app/jazzer_standalone.jar && \ 31*33edd672SMark cp $(bazelisk cquery --config=docker --output=files //launcher:jazzer) /app/ 32*33edd672SMark 33*33edd672SMark# :debug includes a busybox shell, which is needed for libFuzzer's use of system() for e.g. the 34*33edd672SMark# -fork and -minimize_crash commands. 35*33edd672SMarkFROM gcr.io/distroless/java17:debug 36*33edd672SMark 37*33edd672SMarkCOPY --from=builder /app/* /app/ 38*33edd672SMark# system() expects the shell at /bin/sh, but the image has it at /busybox/sh. We create a symlink, 39*33edd672SMark# but have to use the long form as a simple RUN <command> also requires /bin/sh. 40*33edd672SMarkRUN ["/busybox/sh", "-c", "ln -s /busybox/sh /bin/sh"] 41*33edd672SMarkWORKDIR /fuzzing 42*33edd672SMarkENTRYPOINT [ "/app/jazzer" ] 43