From ae18d35577c2e7e556be98bb4dc854317440a55a Mon Sep 17 00:00:00 2001 From: Stefan Wiehler Date: Thu, 18 Nov 2021 15:18:52 +0100 Subject: tools/syz-env: add local build option Useful for testing local Dockerfile changes that have not been pushed yet. --- docs/contributing.md | 6 ++++++ tools/syz-env | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/contributing.md b/docs/contributing.md index 4d1278a1c..85ce77e6d 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -151,6 +151,12 @@ docker pull docker.pkg.github.com/google/syzkaller/env docker tag docker.pkg.github.com/google/syzkaller/env gcr.io/syzkaller/env ``` +You can also build the container from the respective `Dockerfile` by setting the `SYZ_ENV_BUILD` environment variable, i.e.: +``` +SYZ_ENV_BUILD=1 syz-env +``` +This can be useful to test local changes that have not been pushed to the registry yet. + ### Using [act](https://github.com/nektos/act) .github/workflows has more tests compared to `syz-env make presubmit`. To have the same tests as the workflow, we can run these workflow jobs locally. ``` diff --git a/tools/syz-env b/tools/syz-env index 30a1f8448..479f858ec 100755 --- a/tools/syz-env +++ b/tools/syz-env @@ -62,8 +62,15 @@ if [ ! "$(docker info -f "{{println .SecurityOptions}}" | grep rootless)" ]; the DOCKERARGS+=" --user $(id -u ${USER}):$(id -g ${USER})" fi -# Update docker image -docker pull -q gcr.io/syzkaller/${IMAGE} + +# Build or update docker image +if [ ! -z "$SYZ_ENV_BUILD" ]; then + IMAGE_NAME="syz-$IMAGE" + docker build "$SCRIPT_DIR/docker/$IMAGE" --tag "$IMAGE_NAME" ${BUILDARGS[@]} +else + IMAGE_NAME="gcr.io/syzkaller/$IMAGE" + docker pull -q "$IMAGE_NAME" +fi # Run everything as the host user, this is important for created/modified files. docker run \ @@ -82,4 +89,4 @@ docker run \ --env GITHUB_PR_COMMITS \ --env CI \ ${DOCKERARGS[@]} \ - gcr.io/syzkaller/${IMAGE} -c "$COMMAND" + "$IMAGE_NAME" -c "$COMMAND" -- cgit mrf-deployment