back to home

sonic-net / sonic-buildimage

Scripts which perform an installable binary image build for SONiC

938 stars
1,756 forks
2,873 issues
CPythonJinja

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing sonic-net/sonic-buildimage in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/sonic-net/sonic-buildimage)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

*master builds*: *202511 builds*: *202505 builds*: *202411 builds*: *202405 builds*: SONiC Image Azure Pipelines All SONiC project build pipelines can be found at Download Portal for SONiC Images sonic-buildimage Build SONiC Switch Images Description Following are the instructions on how to build an (ONIE) compatible network operating system (NOS) installer image for network switches, and also how to build docker images running inside the NOS. Note that SONiC images are build per ASIC platform. Switches using the same ASIC platform share a common image. For a list of supported switches and ASIC, please refer to this list Hardware Any server can be a build image server as long as it has: • Multiple cores to increase build speed • Plenty of RAM (less than 8 GiB is likely to cause issues) • 300G of free disk space • KVM Virtualization Support. > Note: If you are in a VM, make sure you have support for nested virtualization. > Some cases (e.g. building OVS image) also requires extra configuration > options to expose the full KVM interface to the VM > (e.g. the KVM paravirtualization support on VirtualBox). A good choice of OS for building SONiC is currently Ubuntu 22.04 or Ubuntu 24.04. > **Note (Ubuntu 24.04):** Python 3.12+ removed the module, which breaks the > legacy package. The prerequisites script and manual steps below install > instead, which is a drop-in replacement that works on all Python versions. Automated prerequisites installation and repository cloning For convenience, you can use the automated prerequisites script to handle both prerequisites installation and repository cloning: If you have already cloned the repo, run it locally to install only the prerequisites (the script detects an existing clone at and skips the clone/checkout step): > **Tip:** You can override clone location and branch: > > When already exists, only prerequisites are installed — no second clone. This script will automatically: • Install required packages (pip, jinja, Docker) • Configure Docker for non-root usage • Clone the repository with all submodules After completing this step, proceed to the Usage section below. Manual prerequisites installation • Install pip and jinja in host build machine, execute below commands if j2/jinjanator is not available: > **Note:** If you cannot run the command after installation, this is likely because the directory was just created and is not yet included in your . Please log out and log back in to refresh your environment, then test the command again. • Install Docker and configure your system to allow running the 'docker' command without 'sudo': • Add current user to the docker group: • Log out and log back in so that your group membership is re-evaluated • If you are using Linux kernel 5.3 or newer, then you must use Docker 20.10.10 or newer. This is because older Docker versions did not allow the syscall, which is now used in Bookworm. > Note: If a previous installation of Docker using snap was present on the > system, remove it and also remove docker from snap before reinstallating docker. > This will avoid known bugs that falsely report read-only filesystems issues > during the build process. Manual clone the repository with all the git submodules To clone the code repository recursively: Usage To build SONiC installer image and docker images, run the following commands: Build performance tips **Parallelism vs memory:** Each parallel job can use 4–6 GB RAM during C++ compilation, plus a ~4 GB base overhead. Rule of thumb: : | JOBS | Approx RAM needed | Typical VS build time | |------|-------------------|----------------------| | 1 | ~10 GB | ~3 hours | | 4 | ~28 GB | ~1.5 hours | | 8 | ~52 GB | ~1 hour | **Contain OOM in the build container** (protects host processes): **Skip tests for faster iteration:** **Use a persistent config file** instead of CLI overrides — create (gitignored): The supported ASIC vendors are: • PLATFORM=barefoot • PLATFORM=broadcom • PLATFORM=marvell-prestera • PLATFORM=marvell-teralynx • PLATFORM=mellanox • PLATFORM=centec • PLATFORM=nephos • PLATFORM=nvidia-bluefield • PLATFORM=vs Usage for ARM Architecture To build Arm32 bit for (ARMHF) platform _example:_ To build Arm32 bit for (ARMHF) Marvell Prestera platform on amd64 host for debian buster using cross-compilation, run the following commands: Running the above Arm32 build using cross-compilation instead of qemu emulator drastically reduces the build time. To build Arm64 bit for platform **NOTE**: • Recommend reserving at least 100G free space to build one platform with a single job. The build process will use more disk if you are setting to more than 1. • If Docker's workspace folder, , resides on a partition without sufficient free space, you may encounter an error like the following during a Docker container build job: The solution is to move the directory to a partition with more free space. • Use to enable http(s) proxy in the build process. • Add your user account to group and use your user account to make. or are not supported. • For more details on cross-compilation errors, please refer to README.arm64_build_on_amd64.md The SONiC installer contains all docker images needed. SONiC uses one image for all devices of a same ASIC vendor. For Broadcom ASIC, we build ONIE and EOS image. EOS image is used for Arista devices, ONIE image is used for all other Broadcom ASIC based devices. You may find the rules/config file useful. It contains configuration options for the build process, like adding more verbosity or showing dependencies, username and password for base image etc. Every docker image is built and saved to target/ directory. So, for instance, to build only docker-database, execute: Same goes for debian packages, which are under target/debs/: Every target has a clean target, so in order to clean swss, execute: It is recommended to use clean targets to clean all packages that are built together, like dev package…