Skip to content

Commit

Permalink
Fix Dockerfile rewrite for using cached builds. (#699)
Browse files Browse the repository at this point in the history
We weren't keeping the ARG, WORKDIR lines.

ARG is necessary for obvious reasons since we are relying on injecting
the base image at runtime.

WORKDIR is required for:
https://github.com/google/oss-fuzz/blob/edfa6730fa9f1dca77dd27c0b3a643171e082950/infra/build/functions/build_project.py#L229
  • Loading branch information
oliverchang authored Nov 7, 2024
1 parent 4b25746 commit ccbeb65
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion experiment/oss_fuzz_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,23 @@ def rewrite_project_to_cached_project_chronos(generated_project) -> None:

# Now comment out everything except the first FROM and the last COPY that
# was added earlier in the OFG process.
arg_line = -1
workdir_line = -1
from_line = -1
copy_fuzzer_line = -1

for line_idx, line in enumerate(docker_content.split('\n')):
if line.startswith('WORKDIR') and workdir_line == -1:
# OSS-Fuzz infra relies on parsing WORKDIR.
workdir_line = line_idx
if line.startswith('ARG') and arg_line == -1:
arg_line = line_idx
if line.startswith('FROM') and from_line == -1:
from_line = line_idx
if line.startswith('COPY'):
copy_fuzzer_line = line_idx

lines_to_keep = {from_line, copy_fuzzer_line}
lines_to_keep = {arg_line, from_line, copy_fuzzer_line, workdir_line}
new_content = ''
for line_idx, line in enumerate(docker_content.split('\n')):
if line_idx not in lines_to_keep:
Expand Down

0 comments on commit ccbeb65

Please sign in to comment.