sonic-buildimage/dockers/docker-dhcp-server/Dockerfile.j2
Yaqiang Zhu 76b7cb8b64
[dhcp_server] Add dhcp_server container (#14031)
Why I did it
Add dhcp_server ipv4 feature to SONiC.
HLD: sonic-net/SONiC#1282

How I did it
To be clarify: This container is disabled by INCLUDE_DHCP_SERVER = n for now, which would cause container not build.

Add INCLUDE_DHCP_SERVER to indicate whether to build dhcp_server container
Add docker file for dhcp_server, build and install kea-dhcp4 inside container
Add template file for dhcp_server container services.
Add entry for dhcp_server to FEATURE table in config_db.
How to verify it
Build image with INCLUDE_DHCP_SERVER = y to verify:

Image can be install successfully without crush.
By config feature state dhcp_server enabled to enable dhcp_server.
2023-09-11 09:15:56 -07:00

80 lines
2.8 KiB
Django/Jinja
Executable File

{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %}
FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}}
ARG docker_container_name
ARG image_version
## Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive
# Pass the image_version to container
ENV IMAGE_VERSION=$image_version
RUN apt-get update && \
apt-get install -f -y \
tcpdump \
# For kea build environment
automake \
libtool \
pkg-config \
build-essential \
ccache \
# For kea dependancies
libboost-dev \
libboost-system-dev \
liblog4cplus-dev \
libssl-dev
# Install kea from source
RUN apt-get install -f -y devscripts
RUN mkdir kea && cd kea && dget -u http://deb.debian.org/debian/pool/main/i/isc-kea/isc-kea_2.2.0-6.dsc
RUN cd /kea/isc-kea-2.2.0 && autoreconf --install && ./configure --disable-FEATURE \
--enable-static=no --disable-install-configurations --enable-pgsql-ssl=no --with-PACKAGE=no \
&& make -j$(nproc) && make install
# Create run folder for kea
RUN mkdir -p /run/kea
# Create config folder for kea
RUN mkdir -p /etc/kea
# Remove stuff we don't need to reduce image size
RUN cd /usr/local/lib && rm -v *.la && rm -v kea/hooks/*.la
# Strip debug symbols to reduce file size of binaries
Run find /usr/local/sbin/ /usr/local/lib/ -type f -exec strip --strip-unneeded {} \;
# Remove source code
RUN rm -rf /kea
RUN echo "/usr/local/lib/kea/hooks" > /etc/ld.so.conf.d/kea.conf && \
ldconfig
# Remove sbin we don't need
RUN cd /usr/local/sbin && rm -f kea-admin kea-ctrl-agent kea-dhcp-ddns kea-dhcp6 keactrl
# Remove hook lib we don't need
RUN cd /usr/local/lib/kea/hooks && rm -f libdhcp_bootp.so libdhcp_flex_option.so libdhcp_stat_cmds.so
# RUN pip3 install psutil
{% if docker_dhcp_server_debs.strip() -%}
# Copy locally-built Debian package dependencies
{{ copy_files("debs/", docker_dhcp_server_debs.split(' '), "/debs/") }}
# Install locally-built Debian packages and implicitly install their dependencies
{{ install_debian_packages(docker_dhcp_server_debs.split(' ')) }}
{%- endif %}
# Remove build stuff we don't need
RUN apt-get remove -y devscripts \
automake \
libtool \
pkg-config \
build-essential \
ccache
RUN apt-get clean -y && \
apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /debs
COPY ["docker_init.sh", "/usr/bin/"]
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor/"]
COPY ["cli", "/cli/"]
ENTRYPOINT ["/usr/bin/docker_init.sh"]