From 1ecb98bfec6402b51a93da62b4402a1be558c3c9 Mon Sep 17 00:00:00 2001 From: Yurii Lisovskyi Date: Fri, 29 Sep 2023 13:50:24 +0300 Subject: [PATCH] Generic docker image Signed-off-by: Yurii Lisovskyi --- build.sh | 3 +- configs/server/supervisord.conf.thrift | 41 +++++++++++++ .../buster/Dockerfile.saithrift-server | 60 ++++++++++++++++++- 3 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 configs/server/supervisord.conf.thrift diff --git a/build.sh b/build.sh index 5b104ecd..02fb1f12 100755 --- a/build.sh +++ b/build.sh @@ -155,9 +155,10 @@ if [ "${IMAGE_TYPE}" = "standalone" ]; then elif [ "${IMAGE_TYPE}" = "server" ]; then find ${ASIC_PATH}/../ -type f -name \*.py -exec install -D {} .build/{} \; find ${ASIC_PATH}/../ -type f -name \*.json -exec install -D {} .build/{} \; - docker build -f dockerfiles/${BASE_OS}/Dockerfile.server -t sc-server-base:${BASE_OS} ${CACHE} . if [ "${SAI_INTERFACE}" = "thrift" ]; then docker build -f dockerfiles/${BASE_OS}/Dockerfile.saithrift-server -t sc-thrift-server-base:${BASE_OS} ${CACHE} . + else + docker build -f dockerfiles/${BASE_OS}/Dockerfile.server -t sc-server-base:${BASE_OS} ${CACHE} . fi rm -rf .build/ else diff --git a/configs/server/supervisord.conf.thrift b/configs/server/supervisord.conf.thrift new file mode 100644 index 00000000..80a2eb9b --- /dev/null +++ b/configs/server/supervisord.conf.thrift @@ -0,0 +1,41 @@ +[supervisord] +logfile_maxbytes=1MB +logfile_backups=2 +nodaemon=true + +[eventlistener:dependent-startup] +command=python3 -m supervisord_dependent_startup +autostart=true +autorestart=unexpected +startretries=0 +exitcodes=0,3 +events=PROCESS_STATE +buffer_size=1024 + +[program:rsyslogd] +command=/usr/sbin/rsyslogd -n -iNONE +priority=1 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true + +[program:wait-interfaces] +command=/usr/bin/wait-interfaces.sh +priority=2 +startsecs=0 +autostart=false +autorestart=false +dependent_startup=true + +[program:syncd] +command=/usr/bin/syncd -s -p /etc/sai.d/sai.profile +priority=5 +autostart=false +autorestart=true +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=rsyslogd:running wait-interfaces:exited + diff --git a/dockerfiles/buster/Dockerfile.saithrift-server b/dockerfiles/buster/Dockerfile.saithrift-server index 72374090..0c286802 100644 --- a/dockerfiles/buster/Dockerfile.saithrift-server +++ b/dockerfiles/buster/Dockerfile.saithrift-server @@ -1,4 +1,58 @@ -FROM sc-server-base:buster +FROM debian:buster-slim + +RUN echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb [arch=amd64] http://debian-archive.trafficmanager.net/debian buster-backports main" >> /etc/apt/sources.list + +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +# 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 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 swig3.0 \ + libgtest-dev libgmock-dev libboost-dev autoconf-archive \ + uuid-dev libboost-serialization-dev libyang-dev libyang0.16 + +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 \ + && 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* # Install generic packages RUN apt-get install -y \ @@ -18,4 +72,6 @@ RUN apt-get install -y thrift-compiler libthrift-dev libthrift-0.11.0 \ WORKDIR /sai-challenger -CMD ["/usr/bin/supervisord"] \ No newline at end of file +COPY configs/server/supervisord.conf.thrift /etc/supervisor/conf.d/supervisord.conf + +CMD ["/usr/bin/supervisord"]