Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: make it possible to cache docker containers build #12284

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

DavidKorczynski
Copy link
Collaborator

No description provided.

@DonggeLiu DonggeLiu requested a review from oliverchang July 30, 2024 08:31
infra/helper.py Outdated Show resolved Hide resolved
@DavidKorczynski
Copy link
Collaborator Author

/gcbrun skip

@DavidKorczynski DavidKorczynski merged commit 3beb664 into master Aug 2, 2024
19 checks passed
@DavidKorczynski DavidKorczynski deleted the add-caching-option branch August 2, 2024 08:10
DavidKorczynski added a commit to google/oss-fuzz-gen that referenced this pull request Aug 10, 2024
First touch on #499

Depends on: google/oss-fuzz#12284

The way this work is by saving a cached version of `build_fuzzers` post
running of `compile` and then modifying the Dockerfiles of a project to
use this cached build image + an adjusted build script.

For example, for brotli the Dockerfile is originally:

```sh
                                                                                
FROM gcr.io/oss-fuzz-base/base-builder                                          
RUN apt-get update && apt-get install -y cmake libtool make                     
                                                                                
RUN git clone --depth 1 https://github.com/google/brotli.git                    
WORKDIR brotli                                                                  
COPY build.sh $SRC/                                                             
                                                                                
COPY 01.c /src/brotli/c/fuzz/decode_fuzzer.c      
```

a Dockerfile is then created which relies on the cached version, and it
loosk like:

```sh
FROM cached_image_brotli                                                        
# RUN apt-get update && apt-get install -y cmake libtool make                   
#                                                                               
# RUN git clone --depth 1 https://github.com/google/brotli.git                  
# WORKDIR brotli                                                                
# COPY build.sh $SRC/                                                           
#                                                                               
COPY 01.c /src/brotli/c/fuzz/decode_fuzzer.c                                    
#                                                                               
COPY adjusted_build.sh $SRC/build.sh 
```

`adjusted_build.sh` is then the script that only builds fuzzers. This
means we can also use `build_fuzzers`/`compile` workflows as we know it.

More specifically, this PR:

- Makes it possible to build Docker images of fuzzer build containers.
Does this by running `build_fuzzers`, saving the docker container and
then commit the docker container to an image. This image will have a
projects' build set up post running of `compile`. This is then used when
building fuzzers by OFG.
- Supports only ASAN mode for now. Should be easy to extend to coverage
too.
- Currently builds images first and then uses them locally. We could
extend, probably on another step of this, to use containers pushed by
OSS-Fuzz itself.
- Only does the caching if a "cache-build-script" exists (added a few
for some projects) which contains the build instructions post-build
process. It should be easy to extend such that we can rely on some DB of
auto-generated build scripts as well (ref:
google/oss-fuzz#11937) but I think it's nice to
have both the option of us creating the scripts ourselves + an
auto-generated DB.

---------

Signed-off-by: David Korczynski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants