github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/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 FROM debian:bookworm 7 8 LABEL homepage="https://github.com/google/syzkaller" 9 10 RUN apt-get update --allow-releaseinfo-change 11 RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends \ 12 sudo make nano unzip curl ca-certificates binutils g++ \ 13 g++-arm-linux-gnueabi g++-aarch64-linux-gnu g++-powerpc64le-linux-gnu \ 14 g++-mips64el-linux-gnuabi64 g++-s390x-linux-gnu g++-riscv64-linux-gnu \ 15 libc6-dev-i386 libc6-dev-i386-amd64-cross lib32gcc-12-dev lib32stdc++-12-dev \ 16 python3 python-is-python3 git \ 17 # These are needed to build Linux kernel: 18 flex bison bc libelf-dev libssl-dev \ 19 # qemu-user is required to run alien arch binaries in pkg/cover tests. 20 qemu-user \ 21 && \ 22 apt-get -y autoremove && \ 23 apt-get clean autoclean && \ 24 rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/* 25 26 RUN curl https://dl.google.com/go/go1.21.4.linux-amd64.tar.gz | tar -C /usr/local -xz 27 ENV PATH /usr/local/go/bin:/gopath/bin:$PATH 28 ENV GOPATH /gopath 29 30 # Pre-create dirs for syz-dock. 31 # This is necessary to make docker work with the current user, 32 # otherwise --volume will create these dirs under root and then 33 # the current user won't have access to them. 34 RUN mkdir -p /syzkaller/gopath/src/github.com/google/syzkaller && \ 35 mkdir -p /syzkaller/.cache && \ 36 chmod -R 0777 /syzkaller 37 38 RUN apt-get install -y -q gnupg software-properties-common apt-transport-https 39 RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 40 RUN add-apt-repository "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-15 main" 41 RUN apt-get update --allow-releaseinfo-change 42 RUN apt-get install -y -q --no-install-recommends clang-15 clang-format-15 clang-tidy-15 43 RUN apt-get install -y -q --no-install-recommends flatbuffers-compiler 44 RUN sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100 45 RUN sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100 46 RUN sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-15 100 47 RUN sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100 48 RUN apt autoremove -y -q 49 50 # Install OS toolchains from pre-built archives. 51 # These archives were created with: 52 # tar -cz --owner=0 --group=0 --mode=go=u -f netbsd-toolchain.tar.gz netbsd/tools netbsd/dest 53 # tar -cz --owner=0 --group=0 --mode=go=u -f fuchsia-toolchain.tar.gz fuchsia/prebuilt/third_party/clang \ 54 # fuchsia/zircon/system/ulib fuchsia/src/lib/ddk fuchsia/out/x64/fidling/gen \ 55 # fuchsia/out/x64/zircon_toolchain/obj/zircon/public/sysroot/sysroot \ 56 # fuchsia/out/x64/x64-shared/*.so fuchsia/out/arm64/fidling/gen \ 57 # fuchsia/out/arm64/zircon_toolchain/obj/zircon/public/sysroot/sysroot \ 58 # fuchsia/out/arm64/arm64-shared/*.so 59 # 60 # And then uploaded to GCS with: 61 # gsutil mv gs://syzkaller/GOOS-toolchain.tar.gz gs://syzkaller/GOOS-toolchain.old.tar.gz 62 # gsutil cp GOOS-toolchain.tar.gz gs://syzkaller/ 63 # gsutil acl ch -g all:R gs://syzkaller/GOOS-toolchain.tar.gz 64 # 65 # NetBSD toolchain can be re-built with: 66 # ./build.sh -j72 -m amd64 -U -T ../tools tools 67 # ./build.sh -j72 -m amd64 -U -T ../tools -D ../dest distribution 68 # 69 # To build root image run: 70 # docker run -it --rm --privileged --device /dev/loop0 gcr.io/syzkaller/env 71 # mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 72 # create-image.sh -a s390x -d buster 73 74 RUN dpkg --add-architecture i386 && \ 75 apt-get update --allow-releaseinfo-change && \ 76 DEBIAN_FRONTEND=noninteractive apt-get install -y -q \ 77 # required to build root images. 78 debootstrap ssh-tools qemu-user-static && \ 79 apt-get -y autoremove && \ 80 apt-get clean autoclean && \ 81 rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/* 82 83 84 RUN curl https://storage.googleapis.com/syzkaller/fuchsia-toolchain.tar.gz | tar -C /syzkaller -xz 85 RUN curl https://storage.googleapis.com/syzkaller/netbsd-toolchain.tar.gz | tar -C /syzkaller -xz 86 ENV SOURCEDIR_FUCHSIA /syzkaller/fuchsia 87 ENV SOURCEDIR_NETBSD /syzkaller/netbsd 88 89 # Build Python 2.7 from source. 90 RUN apt-get install -y -q libsqlite3-dev 91 RUN wget -O /tmp/Python-2.7.18.tgz 'https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz' 92 RUN cd /tmp/ && tar -zxf Python-2.7.18.tgz 93 RUN cd /tmp/Python-2.7.18 && ./configure 94 RUN cd /tmp/Python-2.7.18 && make -j2 && make altinstall 95 RUN ln -s /usr/local/bin/python2.7 /usr/bin/python2 96 97 # Install gcloud sdk for dashboard/app tests. 98 # The newest version (as of 07/10/23) is 437, however, it seems to expect to be run with python3 99 # (but still requires python2). But Go's aetest package still runs dev_appserver.py with python2.7. 100 # So let's use an older, but working sdk. 101 RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-400.0.0-linux-x86_64.tar.gz | tar -C /usr/local -xz 102 ENV PATH /usr/local/google-cloud-sdk/bin:$PATH 103 RUN gcloud components install --quiet app-engine-python app-engine-go app-engine-python-extras cloud-datastore-emulator 104 RUN chmod 0777 /usr/local/google-cloud-sdk 105 106 # The default Docker prompt is too ugly and takes the whole line: 107 # I have no name!@0f3331d2fb54:~/gopath/src/github.com/google/syzkaller$ 108 RUN echo "export PS1='syz-env🈴 '" > /syzkaller/.bashrc 109 ENV SYZ_ENV yes 110 111 ENTRYPOINT ["bash"]