Appendix A: Building SONiC from the open-source repository
Users can build a SONiC deployment image using the open-source SONiC project, including environment setup and image compilation.
This section describes how to build a SONiC deployment image using the open-source SONiC repository. The procedures apply to supported Nokia hardware platforms.
After completing the build process, perform an upgrade as needed. See Upgrading to a customer-compiled SONiC software image for more information.
Building the SONiC software image
Build the SONiC image from source using the open-source SONiC build framework.
This task describes how to compile a SONiC image. It follows the open-source SONiC build process with Nokia-specific board support packages (BSPs) and platform adapters. This build procedure can be performed on a physical server or on a virtual machine (VM) in a cloud environment. Ensure that the build environment meets the required operating system, architecture, compute, memory, and storage requirements.
The following are required to perform the build:
- Ubuntu 20.04 build server with docker and python3 installed
- administrative access and sufficient disk space
- Internet access to clone community SONiC repositories from GitHub
-
Install and set up Docker.
If Docker was installed via snap, first remove it. Then add the Docker repository and install the Docker Engine and related tools.
# If your Ubuntu 20.04 server already includes an instance of docker installed by snap, the SONIC build may not work. Please uninstall it first. >> sudo snap remove docker # and follow the instructions below to install docker >> sudo apt-get update >> sudo apt-get install ca-certificates curl >> sudo install -m 0755 -d /etc/apt/keyrings >> sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee \ /etc/apt/keyrings/docker.asc > /dev/null >> sudo chmod a+r /etc/apt/keyrings/docker.asc >> echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \ | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null >> sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin dockercompose-plugin >> sudo gpasswd -a ${USER} docker >> newgrp docker -
Use the Python pip utility to install the
j2cli template utility used by the community SONiC
build systems.
>> sudo apt install python3-pip >> pip install j2cli >> export PATH="$HOME/.local/bin:$PATH" >> source ~/.bashrc -
Clone the community SONiC build repository.
git clone https://github.com/sonic-net/sonic-buildimage.git -b 202505 cd sonic-buildimage -
Run the following command to initialize the sub-repositories, fetch
sub-modules, and prepare the build environment.
make init -
Configure the Broadcom build settings.
make configure PLATFORM=broadcom -
Start the compilation to build the image.
The build time depends on the server resources and network speed.
make SONIC_BUILD_JOBS=4 target/sonic-broadcom.binThe output directory contains the built image file, for example sonic-broadcom.bin.
You can now use the generated image to upgrade a device. See Upgrading to a customer-compiled SONiC software image for instructions.