Skip to content

Commit

Permalink
Initial version of Debian Bookworm Dockers
Browse files Browse the repository at this point in the history
Signed-off-by: Yurii Hordynskyi <[email protected]>
  • Loading branch information
IGordynskyi committed Nov 28, 2024
1 parent 29004b8 commit 9af26bc
Show file tree
Hide file tree
Showing 8 changed files with 529 additions and 2 deletions.
12 changes: 11 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ base_os_map["deb10"]="buster"
base_os_map["buster"]="buster"
base_os_map["deb11"]="bullseye"
base_os_map["bullseye"]="bullseye"
base_os_map["deb12"]="bookworm"
base_os_map["bookworm"]="bookworm"


print-help() {
Expand All @@ -36,7 +38,7 @@ print-help() {
echo " Target device with this NPU"
echo " -s [redis|thrift]"
echo " SAI interface"
echo " -o [buster|bullseye]"
echo " -o [buster|bullseye|bookworm]"
echo " Docker image base OS"
echo " --nosnappi"
echo " Do not include snappi to the final image"
Expand Down Expand Up @@ -143,6 +145,14 @@ print-build-options() {

trap print-build-options EXIT

# Link the pip configuration file to copy to the Docker image
if [ "${BASE_OS}" = "bookworm" ]; then
rm -f pip.conf
if [ -f dockerfiles/${BASE_OS}/pip.conf ]; then
ln -s dockerfiles/${BASE_OS}/pip.conf pip.conf
fi
fi

# Build base Docker image
if [ "${IMAGE_TYPE}" = "standalone" ]; then
docker build -f dockerfiles/${BASE_OS}/Dockerfile -t sc-base:${BASE_OS} .
Expand Down
133 changes: 133 additions & 0 deletions dockerfiles/bookworm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
FROM debian:bookworm-slim

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive

# Copy the pip.conf file
COPY pip.conf /root/.config/pip/pip.conf

# Install generic packages
RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
apt-utils \
vim \
curl \
wget \
iproute2 \
unzip \
git \
procps \
build-essential \
graphviz \
doxygen \
aspell \
python3-pip \
rsyslog \
supervisor

# Add support for supervisord to handle startup dependencies
RUN pip3 install supervisord-dependent-startup==1.4.0

# Install dependencies
RUN apt-get install -y redis-server libhiredis0.14 python3-redis libc-ares2

# Install sonic-swss-common & sonic-sairedis building dependencies
RUN apt-get install -y \
make libtool m4 autoconf dh-exec debhelper automake cmake pkg-config \
libhiredis-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev swig \
libgtest-dev libgmock-dev libboost-dev autoconf-archive \
uuid-dev libboost-serialization-dev nlohmann-json3-dev

RUN apt-get install -y \
libnl-3-dev libnl-genl-3-dev libnl-route-3-dev libnl-nf-3-dev libzmq3-dev

COPY sai.env /

RUN git clone --recursive https://github.com/sonic-net/sonic-swss-common \
&& cd sonic-swss-common \
&& . /sai.env \
&& git checkout ${SWSS_COMMON_ID} \
&& ./autogen.sh \
&& export DEB_BUILD_PROFILES="nopython2 noyangmod" \
&& export DEB_DH_SHLIBDEPS_ARGS_ALL=--dpkg-shlibdeps-params=--ignore-missing-info \
&& dpkg-buildpackage -us -uc -b --jobs=auto \
&& cd .. \
&& dpkg -i libswsscommon_1.0.0_amd64.deb \
&& dpkg -i libswsscommon-dev_1.0.0_amd64.deb \
&& rm -rf sonic-swss-common \
&& rm -f *swsscommon*

WORKDIR /sai

# Install ptf_nn_agent dependencies
RUN apt-get install -y libffi-dev \
&& wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \
&& tar xvfz 1.0.0.tar.gz \
&& cd nanomsg-1.0.0 \
&& mkdir -p build \
&& cd build \
&& cmake .. \
&& make install \
&& ldconfig \
&& cd ../.. \
&& rm -rf 1.0.0.tar.gz nanomsg-1.0.0 \
&& pip3 install nnpy

# Update Redis configuration:
# - Enable keyspace notifications as per sonic-swss-common/README.md
# - Do not daemonize redis-server since supervisord will manage it
# - Do not save Redis DB on disk
RUN sed -ri 's/^# unixsocket/unixsocket/' /etc/redis/redis.conf \
&& sed -ri 's/^unixsocketperm .../unixsocketperm 777/' /etc/redis/redis.conf \
&& sed -ri 's/redis-server.sock/redis.sock/' /etc/redis/redis.conf \
&& sed -ri 's/notify-keyspace-events ""/notify-keyspace-events AKE/' /etc/redis/redis.conf \
&& sed -ri 's/^daemonize yes/daemonize no/' /etc/redis/redis.conf \
&& sed -ri 's/^save/# save/' /etc/redis/redis.conf

# Disable kernel logging support
RUN sed -ri '/imklog/s/^/#/' /etc/rsyslog.conf

# Install PTF dependencies
RUN pip3 install scapy dpkt

# Install ptf_nn_agent and PTF helpers (required by sai_dataplane.py)
COPY ptf/ptf_nn/ptf_nn_agent.py /ptf/ptf_nn/ptf_nn_agent.py
COPY ptf/setup.py /ptf/setup.py
COPY ptf/README.md /ptf/README.md
COPY ptf/src/ptf/*.py /ptf/src/ptf/
COPY ptf/src/ptf/platforms/*.py /ptf/src/ptf/platforms/
COPY ptf/requirements.txt /ptf/requirements.txt

RUN echo "#mock" > /ptf/ptf && pip3 install /ptf

# Install SAI attributes metadata JSON generator
COPY scripts/gen_attr_list /sai/gen_attr_list

# Install SAI-C dependencies
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0
RUN apt-get install -y python3-paramiko

# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
RUN pip3 install --upgrade invoke>=2.2.0

# Deploy SAI Challenger
COPY common /sai-challenger/common
COPY cli /sai-challenger/cli
COPY topologies /sai-challenger/topologies
COPY setup.py /sai-challenger/setup.py
COPY scripts/sai-cli-completion.sh /sai-challenger/scripts/sai-cli-completion.sh
RUN echo ". /sai-challenger/scripts/sai-cli-completion.sh" >> /root/.bashrc

# Deploy a remote commands listener
COPY scripts/redis-cmd-listener.py /sai-challenger/scripts/redis-cmd-listener.py

# Install SAI Challenger
RUN pip3 install /sai-challenger/common /sai-challenger

WORKDIR /sai-challenger/tests

# Setup supervisord
COPY scripts/veth-create.sh /usr/bin/veth-create.sh
COPY scripts/redis_start.sh /usr/bin/redis_start.sh
COPY configs/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["/usr/bin/supervisord"]
121 changes: 121 additions & 0 deletions dockerfiles/bookworm/Dockerfile.client
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
FROM debian:bookworm-slim

## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive

# Copy the pip.conf file
COPY pip.conf /root/.config/pip/pip.conf

# Install generic packages
RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y \
apt-utils \
build-essential \
python3 \
python3-pip \
python3-redis \
iproute2 \
rsyslog \
supervisor \
cmake \
graphviz \
doxygen \
aspell \
git \
wget \
libffi-dev \
nlohmann-json3-dev \
python3-paramiko \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /sai

# Install SAI attributes metadata JSON generator
COPY scripts/gen_attr_list /sai/gen_attr_list
COPY sai.env /

RUN git clone https://github.com/opencomputeproject/SAI.git \
&& cd SAI \
&& . /sai.env \
&& git checkout ${SAI_ID} \
&& cd meta \
&& make saimetadata.h \
&& make saimetadata.c \
&& cd .. \
&& mkdir /usr/include/sai \
&& cp inc/* /usr/include/sai/ \
&& cp experimental/* /usr/include/sai/ \
&& cp meta/sai*.h /usr/include/sai/ \
&& cp meta/saimetadatautils.c /sai/gen_attr_list/ \
&& cp meta/saimetadata.c /sai/gen_attr_list/ \
&& cp meta/saiserialize.c /sai/gen_attr_list/ \
&& cd /sai/gen_attr_list \
&& mkdir build && cd build \
&& cmake .. \
&& make -j$(nproc) \
&& mkdir -p /etc/sai \
&& ./attr_list_generator > /etc/sai/sai.json.tmp \
&& python3 -mjson.tool /etc/sai/sai.json.tmp > /etc/sai/sai.json \
&& rm /etc/sai/sai.json.tmp \
&& rm -rf /sai/SAI

# Install SAI-C dependencies
RUN pip3 install pytest pytest_dependency pytest-html aenum pdbpp macaddress click==8.0

ARG NOSNAPPI
RUN if [ "$NOSNAPPI" != "y" ]; then \
pip3 install snappi==0.11.14 snappi_ixnetwork==0.9.1 ; \
fi

# Fix invoke/loader.py:3: DeprecationWarning caused by load_module()
RUN pip3 install --upgrade invoke>=2.2.0

# Install PTF dependencies
RUN pip3 install scapy dpkt

# Install ptf_nn_agent dependencies
RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \
&& tar xvfz 1.0.0.tar.gz \
&& cd nanomsg-1.0.0 \
&& mkdir -p build \
&& cd build \
&& cmake .. \
&& make install \
&& ldconfig \
&& cd ../.. \
&& rm -rf 1.0.0.tar.gz nanomsg-1.0.0 \
&& pip3 install nnpy

# Install ptf_nn_agent and PTF helpers (required by sai_dataplane.py)
COPY ptf/ptf_nn/ptf_nn_agent.py /ptf/ptf_nn/ptf_nn_agent.py
COPY ptf/setup.py /ptf/setup.py
COPY ptf/README.md /ptf/README.md
COPY ptf/src/ptf/*.py /ptf/src/ptf/
COPY ptf/src/ptf/platforms/*.py /ptf/src/ptf/platforms/
COPY ptf/requirements.txt /ptf/requirements.txt
RUN echo "#mock" > /ptf/ptf && pip3 install /ptf

# Deploy SAI Challenger
COPY common /sai-challenger/common
COPY cli /sai-challenger/cli
COPY topologies /sai-challenger/topologies
COPY setup.py /sai-challenger/setup.py
COPY scripts/sai-cli-completion.sh /sai-challenger/scripts/sai-cli-completion.sh
RUN echo ". /sai-challenger/scripts/sai-cli-completion.sh" >> /root/.bashrc

# Deploy a remote commands listener (mock for setup.py)
RUN mkdir -p /sai-challenger/scripts \
&& echo "#mock" > /sai-challenger/scripts/redis-cmd-listener.py

# Install SAI Challenger
RUN pip3 install /sai-challenger/common /sai-challenger

# Disable kernel logging support
RUN sed -ri '/imklog/s/^/#/' /etc/rsyslog.conf

WORKDIR /sai-challenger/tests

# Setup supervisord
COPY configs/client/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["/usr/bin/supervisord"]

57 changes: 57 additions & 0 deletions dockerfiles/bookworm/Dockerfile.saithrift-client
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM sc-client:bookworm

# Copy the pip.conf file
COPY pip.conf /root/.config/pip/pip.conf

ENV SAIGEN_DEPS libgetopt-long-descriptive-perl libconst-fast-perl \
libtemplate-perl libnamespace-autoclean-perl \
libmoose-perl libmoosex-aliases-perl

WORKDIR /sai

# Install Thrift code gen
RUN apt-get -o Acquire::Check-Valid-Until=false update \
&& apt install -y libtool pkg-config \
&& wget "http://archive.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz" \
&& tar -xf thrift-0.11.0.tar.gz \
&& cd thrift-0.11.0 \
&& ./bootstrap.sh \
&& ./configure --prefix=/usr --with-cpp --with-python \
--with-qt4=no --with-qt5=no --with-csharp=no --with-java=no --with-erlang=no \
--with-nodejs=no --with-lua=no --with-per=no --with-php=no --with-dart=no \
--with-ruby=no --with-haskell=no --with-go=no --with-rs=no --with-haxe=no \
--with-dotnetcore=no --with-d=no \
&& make && make install \
&& pip3 install ctypesgen lib/py \
&& cd /sai \
&& rm -rf thrift-0.11.0 thrift-0.11.0.tar.gz \
&& rm -rf /var/lib/apt/lists/*

COPY sai.env /sai

RUN apt-get -o Acquire::Check-Valid-Until=false update \
&& apt install -y ${SAIGEN_DEPS} \
&& git clone https://github.com/opencomputeproject/SAI.git \
&& cd SAI \
&& . /sai/sai.env \
&& git checkout ${SAI_ID} \
&& cp inc/* /usr/include/sai/ \
&& cp experimental/* /usr/include/sai/ \
&& cd test/saithriftv2/ \
&& make meta \
&& make install-pylib \
&& cd dist \
&& tar zxf saithrift-0.9.tar.gz \
&& cd saithrift-0.9 \
&& python3 setup.py install \
&& cd /sai \
&& rm -rf SAI \
&& apt purge -y ${SAIGEN_DEPS} \
&& rm -rf /var/lib/apt/lists/*

# Install PTF dependencies
RUN pip3 install pysubnettree

WORKDIR /sai-challenger/tests

CMD ["/usr/bin/supervisord"]
Loading

0 comments on commit 9af26bc

Please sign in to comment.