github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/tools/docker/env/Dockerfile (about) 1 # Copyright 2020 syzkaller project authors. All rights reserved. 2 # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 # See /tools/docker/README.md for details. 5 6 # Construct a /syzkaller folder. 7 FROM debian:trixie AS syzkaller-folder 8 WORKDIR /syzkaller 9 RUN apt-get update --allow-releaseinfo-change 10 RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q curl 11 12 # Pre-create dirs for syz-dock. 13 # This is necessary to make docker work with the current user, 14 # otherwise --volume will create these dirs under root and then 15 # the current user won't have access to them. 16 RUN mkdir -p /syzkaller/gopath/src/github.com/google/syzkaller && \ 17 mkdir -p /syzkaller/.cache/gomod && \ 18 chmod -R 0777 /syzkaller 19 20 # Install OS toolchains from pre-built archives. 21 # These archives were created with: 22 # tar -cz --owner=0 --group=0 --mode=go=u -f netbsd-toolchain.tar.gz netbsd/tools netbsd/dest 23 # tar -cz --owner=0 --group=0 --mode=go=u -f fuchsia-toolchain.tar.gz fuchsia/prebuilt/third_party/clang \ 24 # fuchsia/zircon/system/ulib fuchsia/src/lib/ddk fuchsia/out/x64/fidling/gen \ 25 # fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot \ 26 # fuchsia/out/x64/x64-shared/*.so fuchsia/out/arm64/fidling/gen \ 27 # fuchsia/out/arm64/zircon_toolchain/obj/zircon/public/sysroot/sysroot \ 28 # fuchsia/out/arm64/arm64-shared/*.so 29 # 30 # And then uploaded to GCS with: 31 # gsutil mv gs://syzkaller/GOOS-toolchain.tar.gz gs://syzkaller/GOOS-toolchain.old.tar.gz 32 # gsutil cp GOOS-toolchain.tar.gz gs://syzkaller/ 33 # gsutil acl ch -g all:R gs://syzkaller/GOOS-toolchain.tar.gz 34 # 35 # NetBSD toolchain can be re-built with: 36 # ./build.sh -j72 -m amd64 -U -T ../tools tools 37 # ./build.sh -j72 -m amd64 -U -T ../tools -D ../dest distribution 38 # 39 # To build root image run: 40 # docker run -it --rm --privileged --device /dev/loop0 gcr.io/syzkaller/env 41 # mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 42 # create-image.sh -a <ARCH> -d <DEBIAN RELEASE> 43 44 RUN curl https://storage.googleapis.com/syzkaller/fuchsia-toolchain.tar.gz | tar -C /syzkaller -xz 45 RUN curl https://storage.googleapis.com/syzkaller/netbsd-toolchain.tar.gz | tar -C /syzkaller -xz 46 47 # Now build the actual syz-env container. 48 FROM debian:trixie 49 50 LABEL homepage="https://github.com/google/syzkaller" 51 52 RUN apt-get update --allow-releaseinfo-change 53 RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends \ 54 sudo make nano unzip curl ca-certificates binutils g++ \ 55 g++-arm-linux-gnueabi g++-aarch64-linux-gnu g++-powerpc64le-linux-gnu \ 56 g++-mips64el-linux-gnuabi64 g++-s390x-linux-gnu g++-riscv64-linux-gnu \ 57 libc6-dev-i386 libc6-dev-i386-amd64-cross lib32gcc-14-dev lib32stdc++-14-dev \ 58 python3 python-is-python3 python3-legacy-cgi git \ 59 # These are needed to build Linux kernel: 60 flex bison bc libelf-dev libssl-dev \ 61 # qemu-user is required to run alien arch binaries in pkg/cover tests. 62 qemu-user \ 63 # These are various fsck-like commands needed for prog/fsck: 64 dosfstools e2fsprogs btrfs-progs util-linux f2fs-tools jfsutils \ 65 util-linux dosfstools ocfs2-tools reiserfsprogs xfsprogs erofs-utils \ 66 exfatprogs gfs2-utils \ 67 && \ 68 apt-get -y autoremove && \ 69 apt-get clean autoclean && \ 70 rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/* 71 72 # Since go 1.21 the toolchain required by go.mod is automatically downloaded. 73 # There is no need to version up golang here after go.mod changes. 74 RUN curl https://dl.google.com/go/go1.24.4.linux-amd64.tar.gz | tar -C /usr/local -xz 75 ENV PATH /usr/local/go/bin:/gopath/bin:$PATH 76 ENV GOPATH /gopath 77 ENV GOMODCACHE /syzkaller/.cache/gomod 78 79 # Install clang. 80 RUN apt-get install -y -q gnupg apt-transport-https 81 RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /usr/share/keyrings/llvm-snapshot.gpg 82 RUN echo "deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/trixie/ llvm-toolchain-trixie-21 main" | sudo tee /etc/apt/sources.list.d/llvm-21.list 83 RUN apt-get update --allow-releaseinfo-change 84 RUN apt-get install -y -q --no-install-recommends clang-21 clang-format-21 clang-tidy-21 lld-21 85 RUN apt-get install -y -q --no-install-recommends flatbuffers-compiler 86 RUN sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-21 100 87 RUN sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-21 100 88 RUN sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-21 100 89 RUN sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-21 100 90 RUN sudo update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/lld-21 100 91 RUN apt autoremove -y -q 92 93 # Install the Spanner emulator. 94 ARG SPANNER_EMULATOR_VERSION=1.5.28 95 RUN mkdir /spanner 96 RUN curl https://storage.googleapis.com/cloud-spanner-emulator/releases/${SPANNER_EMULATOR_VERSION}/cloud-spanner-emulator_linux_amd64-${SPANNER_EMULATOR_VERSION}.tar.gz | tar -C /spanner -xz 97 RUN chmod u+x /spanner/gateway_main /spanner/emulator_main 98 ENV SPANNER_EMULATOR_BIN=/spanner/gateway_main 99 100 RUN dpkg --add-architecture i386 && \ 101 apt-get update --allow-releaseinfo-change && \ 102 DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ 103 # required to build root images. 104 debootstrap ssh-tools qemu-user-static && \ 105 apt-get -y autoremove && \ 106 apt-get clean autoclean && \ 107 rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/* 108 109 # Copy the /syzkaller folder and set the toolchain environment variables. 110 COPY --from=syzkaller-folder /syzkaller/ /syzkaller/ 111 RUN chmod 0777 /syzkaller 112 ENV SOURCEDIR_FUCHSIA /syzkaller/fuchsia 113 ENV SOURCEDIR_NETBSD /syzkaller/netbsd 114 115 # Rust toolchain for kernel builds. 116 ENV RUSTUP_HOME=/usr/local/rustup 117 ENV CARGO_HOME=/usr/local/cargo 118 ENV PATH=/usr/local/cargo/bin:$PATH 119 ENV RUST_VERSION=1.91.1 120 RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUST_VERSION 121 RUN rustup component add rust-src 122 RUN cargo install --locked bindgen-cli 123 124 # Use the latest libdw-dev release, otherwise we get compilation error when CONFIG_RUST=y. 125 RUN apt-get install -y --no-install-recommends libdw-dev libelf-dev 126 127 # Install node to pass act jobs (https://github.com/nektos/act) 128 RUN apt-get install -y -q nodejs 129 130 # Install gcloud sdk for dashboard/app tests. 131 RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-519.0.0-linux-x86_64.tar.gz | tar -C /usr/local -xz 132 ENV PATH /usr/local/google-cloud-sdk/bin:$PATH 133 RUN gcloud components install --quiet app-engine-python app-engine-go app-engine-python-extras cloud-datastore-emulator 134 RUN chmod 0777 /usr/local/google-cloud-sdk 135 136 # Patch gcloud app-engine-python to fix projected queries problem, see issue #4785. 137 RUN sed -i "s/entity\.key\.MergeFrom(original_entity\.key())/entity\.key\.MergeFrom(original_entity\.key)/g" \ 138 /usr/local/google-cloud-sdk/platform/google_appengine/google/appengine/datastore/datastore_sqlite_stub.py 139 RUN sed -i "s/array\.array('B', str(value_data))))/entity_pb2\.PropertyValue, array\.array('B', value_data)))/g" \ 140 /usr/local/google-cloud-sdk/platform/google_appengine/google/appengine/datastore/datastore_sqlite_stub.py 141 142 # The default Docker prompt is too ugly and takes the whole line: 143 # I have no name!@0f3331d2fb54:~/gopath/src/github.com/google/syzkaller$ 144 RUN echo "export PS1='syz-env🈴 '" > /syzkaller/.bashrc 145 ENV SYZ_ENV yes 146 147 ENTRYPOINT ["bash"]