Commit 5d9612f9 authored by Raphael Defosseux's avatar Raphael Defosseux

fix(build): simplication and optimization of image building

  * Remove un-necessary builder image packages
  * Faster builds on built-from-source packages
  * Support for Ubuntu20/22 image generation
  * RHEL8-minimal target image
  * health-check natively in image
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent 5d3fd80b
...@@ -25,15 +25,15 @@ ...@@ -25,15 +25,15 @@
# #
####################################### #######################################
#SUPPORTED_DISTRO="Ubuntu 18.04, CentOS 7, RHEL 7" #SUPPORTED_DISTRO="Ubuntu 18.04, CentOS 7, RHEL 7"
SUPPORTED_DISTRO="Ubuntu 18.04, RHEL8" SUPPORTED_DISTRO="Ubuntu 18.04,20.04,22.04, RHEL8"
if [ ! -f /etc/os-release ]; then if [ ! -f /etc/os-release ]; then
echo_fatal "No /etc/os-release file found. You're likely on an unsupported distro." echo_fatal "No /etc/os-release file found. You're likely on an unsupported distro."
fi fi
OS_DISTRO=$(grep "^ID=" /etc/os-release | sed "s/ID=//" | sed "s/\"//g") OS_DISTRO=$(grep "^ID=" /etc/os-release | sed "s/ID=//" | sed "s/\"//g")
OS_RELEASE=$(grep "^VERSION_ID=" /etc/os-release | sed "s/VERSION_ID=//" | sed "s/\"//g") OS_RELEASE=$(grep "^VERSION_ID=" /etc/os-release | sed "s/VERSION_ID=//" | sed "s/\"//g")
case "$OS_DISTRO" in case "$OS_DISTRO" in
fedora) OS_BASEDISTRO="fedora"; INSTALLER="dnf"; CMAKE="cmake3" ;; fedora) OS_BASEDISTRO="fedora"; INSTALLER="dnf"; CMAKE="cmake" ;;
rhel) OS_BASEDISTRO="fedora"; INSTALLER="yum"; CMAKE="cmake3" ;; rhel) OS_BASEDISTRO="fedora"; INSTALLER="yum"; CMAKE="cmake" ;;
centos) OS_BASEDISTRO="fedora"; INSTALLER="yum"; CMAKE="cmake3" ;; centos) OS_BASEDISTRO="fedora"; INSTALLER="yum"; CMAKE="cmake3" ;;
debian) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; debian) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;;
ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;;
...@@ -129,6 +129,7 @@ check_supported_distribution() { ...@@ -129,6 +129,7 @@ check_supported_distribution() {
case "$distribution" in case "$distribution" in
"ubuntu18.04") return 0 ;; "ubuntu18.04") return 0 ;;
"ubuntu20.04") return 0 ;; "ubuntu20.04") return 0 ;;
"ubuntu22.04") return 0 ;;
"rhel8") return 0 ;; "rhel8") return 0 ;;
"rhel8.2") return 0 ;; "rhel8.2") return 0 ;;
"rhel8.3") return 0 ;; "rhel8.3") return 0 ;;
...@@ -164,7 +165,10 @@ clean_kernel() { ...@@ -164,7 +165,10 @@ clean_kernel() {
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
disable_ipv6() { disable_ipv6() {
$SUDO sysctl -w net.ipv6.conf.all.disable_ipv6=1 if [ $IS_CONTAINER -eq 0 ]
then
$SUDO sysctl -w net.ipv6.conf.all.disable_ipv6=1
fi
} }
......
...@@ -30,44 +30,6 @@ ...@@ -30,44 +30,6 @@
SCRIPT=$(readlink -f ${BASH_SOURCE}) SCRIPT=$(readlink -f ${BASH_SOURCE})
THIS_SCRIPT_PATH=`dirname $SCRIPT` THIS_SCRIPT_PATH=`dirname $SCRIPT`
source $THIS_SCRIPT_PATH/build_helper source $THIS_SCRIPT_PATH/build_helper
source $THIS_SCRIPT_PATH/build_helper.libconfig
#-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script)
#arg2 is debug (0 or 1) (install debug libraries)
install_fmt() {
echo "Starting to install fmt"
if [ $1 -eq 0 ]; then
read -p "Do you want to install open-source formatting library for C++ ? <y/N> " prompt
OPTION=""
else
prompt='y'
OPTION="-y"
fi
echo "Install fmt from source"
if [[ $prompt =~ [yY](es)* ]]
then
cd /tmp
echo "Downloading fmt"
$SUDO rm -rf /tmp/fmt*
git clone https://github.com/fmtlib/fmt.git
ret=$?;[[ $ret -ne 0 ]] && return $ret
cd fmt
# Looks like since Nov 11 commits, we cannot build
git checkout -f 1936dddc3c53c1c0db55a665cf419dc7a257ba62
$CMAKE -DFMT_TEST=FALSE .
ret=$?;[[ $ret -ne 0 ]] && return $ret
make -j `nproc`
ret=$?;[[ $ret -ne 0 ]] && return $ret
$SUDO make install
cd /tmp
rm -rf /tmp/fmt*
fi
echo "fmt installation complete"
return 0
}
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#arg1 is force (0 or 1) (no interactive script) #arg1 is force (0 or 1) (no interactive script)
...@@ -148,13 +110,14 @@ install_pistache_from_git() { ...@@ -148,13 +110,14 @@ install_pistache_from_git() {
-DPISTACHE_BUILD_EXAMPLES=false \ -DPISTACHE_BUILD_EXAMPLES=false \
-DPISTACHE_BUILD_TESTS=false \ -DPISTACHE_BUILD_TESTS=false \
-DPISTACHE_BUILD_DOCS=false \ -DPISTACHE_BUILD_DOCS=false \
.. ..
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make make -j $(nproc)
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install $SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd popd
rm -Rf $OPENAIRCN_DIR/build/ext/pistache/_build
fi fi
echo "pistache installation complete" echo "pistache installation complete"
return 0 return 0
...@@ -201,6 +164,7 @@ install_nlohmann_from_git() { ...@@ -201,6 +164,7 @@ install_nlohmann_from_git() {
$SUDO make install $SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd popd
rm -Rf $OPENAIRCN_DIR/build/ext/json/_build
fi fi
echo "Nlohmann Json installation complete" echo "Nlohmann Json installation complete"
return 0 return 0
...@@ -230,7 +194,7 @@ install_nghttp2_from_git() { ...@@ -230,7 +194,7 @@ install_nghttp2_from_git() {
if [[ $OS_DISTRO == "ubuntu" ]]; then if [[ $OS_DISTRO == "ubuntu" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
g++ \ g++ \
cmake \ $CMAKE \
binutils \ binutils \
autoconf \ autoconf \
automake \ automake \
...@@ -241,7 +205,7 @@ install_nghttp2_from_git() { ...@@ -241,7 +205,7 @@ install_nghttp2_from_git() {
libcunit1-dev \ libcunit1-dev \
libssl-dev \ libssl-dev \
libxml2-dev libev-dev libevent-dev libjansson-dev libc-ares-dev \ libxml2-dev libev-dev libevent-dev libjansson-dev libc-ares-dev \
libjemalloc-dev libsystemd-dev cython python3-dev python-setuptools" libjemalloc-dev libsystemd-dev python3-dev python-setuptools"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
gcc-c++ \ gcc-c++ \
...@@ -286,12 +250,13 @@ install_nghttp2_from_git() { ...@@ -286,12 +250,13 @@ install_nghttp2_from_git() {
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
./configure --enable-asio-lib --enable-lib-only ./configure --enable-asio-lib --enable-lib-only
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make make -j $(nproc)
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO make install $SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
$SUDO ldconfig $SUDO ldconfig
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
git clean -x -d -ff .
popd popd
fi fi
echo "nghttp2 installation complete" echo "nghttp2 installation complete"
...@@ -324,7 +289,9 @@ check_install_smf_deps() { ...@@ -324,7 +289,9 @@ check_install_smf_deps() {
#$SUDO systemctl mask apt-daily.timer #$SUDO systemctl mask apt-daily.timer
#$SUDO systemctl mask apt-daily-upgrade.service #$SUDO systemctl mask apt-daily-upgrade.service
#$SUDO systemctl mask apt-daily-upgrade.timer #$SUDO systemctl mask apt-daily-upgrade.timer
$SUDO sed -i 's/1/0/g' /etc/apt/apt.conf.d/10periodic if [ $IS_CONTAINER -eq 0 ]; then
$SUDO sed -i 's/1/0/g' /etc/apt/apt.conf.d/10periodic
fi
fi fi
update_package_db update_package_db
...@@ -337,26 +304,16 @@ check_install_smf_deps() { ...@@ -337,26 +304,16 @@ check_install_smf_deps() {
PACKAGE_LIST="\ PACKAGE_LIST="\
autoconf \ autoconf \
automake \ automake \
bison \
build-essential \ build-essential \
cmake \ $CMAKE \
daemon \
doxygen \
flex \
gdb \
wget \
git" git"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
autoconf \ autoconf \
automake \ automake \
bison \
gcc-c++ \ gcc-c++ \
$CMAKE \ $CMAKE \
make \ make \
doxygen \
flex \
gdb \
git" git"
else else
echo_fatal "$OS_DISTRO is not a supported distribution." echo_fatal "$OS_DISTRO is not a supported distribution."
...@@ -372,53 +329,48 @@ check_install_smf_deps() { ...@@ -372,53 +329,48 @@ check_install_smf_deps() {
# Currently Ubuntu18.04 has boost 1.65 as the latest # Currently Ubuntu18.04 has boost 1.65 as the latest
# We need at least 1.66 # We need at least 1.66
# PPA has 1.67 # PPA has 1.67
$SUDO $INSTALLER install $OPTION software-properties-common
$SUDO add-apt-repository ppa:mhier/libboost-latest --yes $SUDO add-apt-repository ppa:mhier/libboost-latest --yes
$SUDO $INSTALLER update $SUDO $INSTALLER update
specific_packages="libconfig++-dev libboost-all-dev" if [ $IS_CONTAINER -eq 0 ]; then
;; specific_packages="libconfig++-dev libasio-dev libboost-all-dev mysql-server libasan4"
else
specific_packages="libconfig++-dev libasio-dev libboost-all-dev libasan4"
fi
;;
"ubuntu20.04") "ubuntu20.04")
specific_packages="libconfig++-dev libasio-dev libboost-all-dev" specific_packages="libconfig++-dev libasio-dev libboost-all-dev libasan5"
;; ;;
*) "ubuntu22.04")
specific_packages="libconfig++-dev libasio-dev libboost-all-dev" specific_packages="libconfig++-dev libasio-dev libboost-all-dev libasan6"
;; ;;
esac esac
# removed libspdlog-dev # removed libspdlog-dev
PACKAGE_LIST="\ PACKAGE_LIST="\
$specific_packages \ $specific_packages \
guile-2.0-dev \
libcurl4-gnutls-dev \ libcurl4-gnutls-dev \
libevent-dev \ libevent-dev \
libgcrypt?-dev \
libgmp-dev \ libgmp-dev \
libhogweed? \ libhogweed? \
libidn2-0-dev \
libidn11-dev \
libpthread-stubs0-dev \
libssl-dev \ libssl-dev \
libtool \ libtool \
libxml2 \ libxml2 \
libxml2-dev \ libxml2-dev \
openssl \ openssl \
python \
nettle-dev \ nettle-dev \
libcurl4 \ libcurl4 \
net-tools \ net-tools \
pkg-config \ pkg-config \
wget \ ninja-build"
libasan?"
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
boost-devel \ boost-devel \
guile-devel \
libconfig-devel \ libconfig-devel \
libgcrypt-devel \ libgcrypt-devel \
gmp-devel \ gmp-devel \
libidn-devel \
lksctp-tools \ lksctp-tools \
lksctp-tools-devel \ lksctp-tools-devel \
openssl-devel \ openssl-devel \
libnghttp2 \
libtool \ libtool \
libxml2 \ libxml2 \
libxml2-devel \ libxml2-devel \
...@@ -428,42 +380,41 @@ check_install_smf_deps() { ...@@ -428,42 +380,41 @@ check_install_smf_deps() {
libcurl-devel \ libcurl-devel \
python2 \ python2 \
pkgconfig \ pkgconfig \
ninja-build \
libasan" libasan"
else else
echo_fatal "$OS_DISTRO is not a supported distribution." echo_fatal "$OS_DISTRO is not a supported distribution."
fi fi
echo "Install distro libs" echo "Install distro libs"
$SUDO $INSTALLER install $OPTION $PACKAGE_LIST $SUDO $INSTALLER install $OPTION $PACKAGE_LIST
# fix issue with libboost in U18 for a bare metal deployment # fix issue with libboost in U18 for a bare metal deployment
if [[ $OS_DISTRO == "ubuntu" ]]; then if [[ $OS_DISTRO == "ubuntu" ]]; then
case "$(get_distribution_release)" in case "$(get_distribution_release)" in
"ubuntu18.04") "ubuntu18.04")
$SUDO $INSTALLER remove $OPTION libboost1.65-dev || true $SUDO $INSTALLER remove $OPTION libboost1.65-dev || true
$SUDO $INSTALLER autoremove $OPTION || true
$SUDO $INSTALLER install $OPTION libboost1.67-dev $SUDO $INSTALLER install $OPTION libboost1.67-dev
;; ;;
esac esac
fi fi
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
echo "distro libs installation complete" echo "distro libs installation complete"
# Use fmt lib included in spdlog
#install_fmt $1
#ret=$?;[[ $ret -ne 0 ]] && return $ret
install_spdlog_from_git $1 $2 install_spdlog_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
install_pistache_from_git $1 $2 install_pistache_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
install_nlohmann_from_git $1 $2 install_nlohmann_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
install_nghttp2_from_git $1 $2 install_nghttp2_from_git $1 $2
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
$SUDO ldconfig
return 0 return 0
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -563,5 +514,3 @@ check_install_smf_min_deps() { ...@@ -563,5 +514,3 @@ check_install_smf_min_deps() {
return 0 return 0
} }
...@@ -187,7 +187,7 @@ pipeline { ...@@ -187,7 +187,7 @@ pipeline {
echo "Maybe a previous build went wrong" echo "Maybe a previous build went wrong"
} }
// In case of push to `develop` branch we build from scratch // In case of push to `develop` branch we build from scratch
myShCmd('docker build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.smf.ubuntu18 . > archives/smf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.smf.ubuntu . > archives/smf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
try { try {
...@@ -251,7 +251,7 @@ pipeline { ...@@ -251,7 +251,7 @@ pipeline {
myShCmd('cp /etc/pki/entitlement/*pem ./etc-pki-entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('cp /etc/pki/entitlement/*pem ./etc-pki-entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/rhsm.conf ./rhsm-conf', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo cp /etc/rhsm/rhsm.conf ./rhsm-conf', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/ca/*pem ./rhsm-ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo cp /etc/rhsm/ca/*pem ./rhsm-ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.smf.rhel8 . > archives/smf_podman_image_build.log 2>&1', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('sudo podman build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.smf.rhel8 --format docker . > archives/smf_podman_image_build.log 2>&1', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
// Putting a place holder to try out on the flattening of image. // Putting a place holder to try out on the flattening of image.
// If not satisfactory, we can remove it. // If not satisfactory, we can remove it.
myShCmd('python3 ./ci-scripts/flatten_image.py --tag oai-smf:' + smf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('python3 ./ci-scripts/flatten_image.py --tag oai-smf:' + smf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
......
...@@ -21,13 +21,16 @@ ...@@ -21,13 +21,16 @@
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #
# Dockerfile for the Open-Air-Interface SMF service # Dockerfile for the Open-Air-Interface SMF service
# Valid for Ubuntu-18.04 (bionic) # Valid for Ubuntu-18.04 (bionic),
# Ubuntu-20.04 (focal),
# Ubuntu-22.04 (jammy)
# #
#--------------------------------------------------------------------- #---------------------------------------------------------------------
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# BUILDER IMAGE # BUILDER IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
ARG BASE_IMAGE=ubuntu:bionic
FROM oai-smf-base:latest as oai-smf-builder FROM oai-smf-base:latest as oai-smf-builder
WORKDIR /openair-smf/ WORKDIR /openair-smf/
...@@ -53,36 +56,53 @@ RUN apt-get update && \ ...@@ -53,36 +56,53 @@ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \ psmisc \
net-tools \ net-tools \
tzdata \
bc \ bc \
perl \ libssh-4 \
openssl \ openssl \
libasan4 \ libbrotli1 \
netbase \
# Ubuntu 18 --> libasan4
# Ubuntu 20 --> libasan5
# Ubuntu 22 --> libasan6
libgssapi-krb5-2 \
# Ubuntu 18/20 --> libldap-2.4-2
# Ubuntu 22 --> libldap-2.5-0
libldap-2.?-? \
libconfig++9v5 \
libsctp1 \
librtmp1 \ librtmp1 \
libpsl5 \ libpsl5 \
libcurl?-gnutls \ libcurl?-gnutls \
libgssapi-krb5-2 \ # Ubuntu 18 --> boost62/65 -> will remove both
libldap-2.4-2 \ # Ubuntu 20 --> boost67/71 -> will remove 67
libconfig++9v5 \ # Ubuntu 22 --> boost74
&& rm -rf /var/lib/apt/lists/* libboost-thread1.??.0 \
libboost-chrono1.??.0 \
&& rm -rf /var/lib/apt/lists/* \
/lib/x86_64-linux-gnu/libboost_system.so.1.6*.0 \
/lib/x86_64-linux-gnu/libboost_chrono.so.1.6*.0 \
/lib/x86_64-linux-gnu/libboost_thread.so.1.6*.0
# Copying executable and generated libraries # Copying executable and generated libraries
WORKDIR /openair-smf/bin WORKDIR /openair-smf/bin
COPY --from=oai-smf-builder \ COPY --from=oai-smf-builder \
/openair-smf/build/smf/build/oai_smf \ /openair-smf/build/smf/build/oai_smf \
/openair-smf/scripts/entrypoint.sh \ /openair-smf/scripts/entrypoint.sh \
/openair-smf/scripts/healthcheck.sh \
./ ./
WORKDIR /usr/local/lib/ WORKDIR /usr/local/lib/
COPY --from=oai-smf-builder \ COPY --from=oai-smf-builder \
/usr/local/lib/libpistache.so \ # Copying only the packages built from source
/usr/local/lib/libnghttp2.so.14 \ /usr/local/lib/libnghttp2.so.14 \
/usr/local/lib/libnghttp2_asio.so.1 \ /usr/local/lib/libnghttp2_asio.so.1 \
/usr/lib/libboost_system.so.1.67.0 \ /usr/local/lib/libpistache.so \
/usr/lib/libboost_thread.so.1.67.0 \ # Ubuntu 18 --> boost 67 will be copied
/usr/lib/libboost_chrono.so.1.67.0 \ /usr/lib/libboost_system.so.1.* \
/openair-smf/build/smf/build/nas/libNAS.so \ /usr/lib/libboost_thread.so.1.* \
/usr/lib/libboost_chrono.so.1.* \
./ ./
RUN ldconfig && \ RUN ldconfig && \
ldd /openair-smf/bin/oai_smf ldd /openair-smf/bin/oai_smf
...@@ -91,7 +111,14 @@ RUN ldconfig && \ ...@@ -91,7 +111,14 @@ RUN ldconfig && \
WORKDIR /openair-smf/etc WORKDIR /openair-smf/etc
COPY --from=oai-smf-builder /openair-smf/etc/smf.conf . COPY --from=oai-smf-builder /openair-smf/etc/smf.conf .
# expose ports
WORKDIR /openair-smf WORKDIR /openair-smf
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-smf/bin/healthcheck.sh
EXPOSE 80/tcp 9090/tcp 8805/udp EXPOSE 80/tcp 9090/tcp 8805/udp
......
...@@ -568,11 +568,11 @@ class HtmlReport(): ...@@ -568,11 +568,11 @@ class HtmlReport():
else: else:
cell_msg += ' ** Nlohmann Json Installation: KO\n' cell_msg += ' ** Nlohmann Json Installation: KO\n'
if base_image: if base_image:
cell_msg += ' ** nghttp2 Installation: N/A\n' cell_msg += ' ** nghttp2-asio Installation: N/A\n'
elif nghttp2_build_status: elif nghttp2_build_status:
cell_msg += ' ** nghttp2 Installation: OK\n' cell_msg += ' ** nghttp2-asio Installation: OK\n'
else: else:
cell_msg += ' ** nghttp2 Installation: KO\n' cell_msg += ' ** nghttp2-asio Installation: KO\n'
cell_msg += '</b></pre></td>\n' cell_msg += '</b></pre></td>\n'
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #
# Dockerfile for the Open-Air-Interface SMF service # Dockerfile for the Open-Air-Interface SMF service
# Valid for RHEL 8.2 # Valid for UBI 8.6 | RHEL 8.6
# #
#--------------------------------------------------------------------- #---------------------------------------------------------------------
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-smf-builder FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-smf-builder
ARG NEEDED_GIT_PROXY
# Copy the entitlements # Copy the entitlements
COPY ./etc-pki-entitlement /etc/pki/entitlement COPY ./etc-pki-entitlement /etc/pki/entitlement
...@@ -41,18 +39,23 @@ COPY ./rhsm-ca /etc/rhsm/ca ...@@ -41,18 +39,23 @@ COPY ./rhsm-ca /etc/rhsm/ca
RUN rm -f /etc/rhsm-host && \ RUN rm -f /etc/rhsm-host && \
yum repolist --disablerepo=* && \ yum repolist --disablerepo=* && \
subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms && \ subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms && \
yum update -y && \ yum update -y && \
yum install -y \ yum install -y \
psmisc \ psmisc \
git \ git \
diffutils \ diffutils \
file \ file \
boost-devel &&\ gcc-c++ \
rm -rf /var/lib/apt/lists/* ninja-build \
boost-devel \
openssl-devel \
openssl \
libasan && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/local-lib.conf && \
echo "/usr/local/lib64" >> /etc/ld.so.conf.d/local-lib.conf
# Some GIT configuration command quite useful # Some GIT configuration command quite useful
RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi"
RUN git config --global https.postBuffer 123289600 && \ RUN git config --global https.postBuffer 123289600 && \
git config --global http.sslverify false git config --global http.sslverify false
...@@ -60,46 +63,64 @@ RUN git config --global https.postBuffer 123289600 && \ ...@@ -60,46 +63,64 @@ RUN git config --global https.postBuffer 123289600 && \
WORKDIR /openair-smf WORKDIR /openair-smf
COPY . /openair-smf COPY . /openair-smf
# Installing and Building SMF # Installing all the needed libraries/packages to build and run SMF
WORKDIR /openair-smf/build/scripts WORKDIR /openair-smf/build/scripts
RUN ./build_smf --install-deps --force RUN ./build_smf --install-deps --force
RUN ./build_smf --clean --Verbose --build-type Release --jobs && \
# Building SMF
WORKDIR /openair-smf/build/scripts
RUN ldconfig && \
./build_smf --clean --Verbose --build-type Release --jobs && \
ldd /openair-smf/build/smf/build/smf && \ ldd /openair-smf/build/smf/build/smf && \
mv /openair-smf/build/smf/build/smf /openair-smf/build/smf/build/oai_smf && \ mv /openair-smf/build/smf/build/smf /openair-smf/build/smf/build/oai_smf && \
rm /etc/pki/entitlement/*pem # Remove entitlements and Subscription Manager configs
rm -rf /etc/pki/entitlement && \
rm -rf /etc/rhsm
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# TARGET IMAGE # TARGET IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM registry.access.redhat.com/ubi8/ubi:latest as oai-smf FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as oai-smf
ENV TZ=Europe/Paris ENV TZ=Europe/Paris
# We install some debug tools for the moment in addition of mandatory libraries
RUN yum update -y && \ # Copy the entitlements
yum install -y --enablerepo="ubi-8-codeready-builder" \ COPY ./etc-pki-entitlement /etc/pki/entitlement
psmisc \ # Copy the subscription manager configurations
tzdata \ COPY ./rhsm-conf /etc/rhsm
procps-ng \ COPY ./rhsm-ca /etc/rhsm/ca
net-tools \
libevent && \
yum clean all -y && \ RUN rm -f /etc/rhsm-host && \
rm -rf /var/cache/yum /var/cache/dnf microdnf update -y && \
microdnf install -y \
tzdata \
libasan \
procps-ng \
psmisc \
net-tools \
libicu \
boost \
libevent \
findutils \
libconfig && \
microdnf clean all -y && \
rm -rf /var/cache/yum /var/cache/dnf && \
# Remove entitlements and Subscription Manager configs
rm -rf /etc/pki/entitlement && \
rm -rf /etc/rhsm
# Copying executable and generated libraries # Copying executable and generated libraries
WORKDIR /openair-smf/bin WORKDIR /openair-smf/bin
COPY --from=oai-smf-builder \ COPY --from=oai-smf-builder \
/openair-smf/build/smf/build/oai_smf \ /openair-smf/build/smf/build/oai_smf \
/openair-smf/scripts/entrypoint.sh \ /openair-smf/scripts/entrypoint.sh \
/openair-smf/scripts/healthcheck.sh \
./ ./
COPY --from=oai-smf-builder \ COPY --from=oai-smf-builder \
/usr/local/lib64/libpistache.so.0 \ /usr/local/lib64/libpistache.so.0 \
/usr/local/lib/libnghttp2_asio.so \ /usr/local/lib/libnghttp2_asio.so \
/usr/lib64/libconfig++.so.9 \
/usr/lib64/libboost_system.so.1.66.0 \
/usr/lib64/libboost_thread.so.1.66.0 \
/usr/lib64/libboost_chrono.so.1.66.0 \
/usr/local/lib/libnghttp2_asio.so.1 \ /usr/local/lib/libnghttp2_asio.so.1 \
/usr/lib64/libasan.so.5 \
/openair-smf/build/smf/build/nas/libNAS.so \ /openair-smf/build/smf/build/nas/libNAS.so \
/usr/lib64/ /usr/lib64/
...@@ -115,6 +136,11 @@ WORKDIR /openair-smf ...@@ -115,6 +136,11 @@ WORKDIR /openair-smf
# expose ports # expose ports
EXPOSE 80/tcp 9090/tcp 8805/udp EXPOSE 80/tcp 9090/tcp 8805/udp
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-smf/bin/healthcheck.sh
ENTRYPOINT ["/openair-smf/bin/entrypoint.sh"] ENTRYPOINT ["/openair-smf/bin/entrypoint.sh"]
CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"] CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"]
...@@ -21,32 +21,28 @@ ...@@ -21,32 +21,28 @@
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #
# Dockerfile for the Open-Air-Interface SMF service # Dockerfile for the Open-Air-Interface SMF service
# Valid for Ubuntu-18.04 (bionic) # Valid for Ubuntu-18.04 (bionic),
# Ubuntu-20.04 (focal),
# Ubuntu-22.04 (jammy)
# #
#--------------------------------------------------------------------- #---------------------------------------------------------------------
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# BUILDER IMAGE # BASE IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM ubuntu:bionic as oai-smf-builder ARG BASE_IMAGE=ubuntu:bionic
FROM $BASE_IMAGE as oai-smf-base
ARG NEEDED_GIT_PROXY
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
RUN echo "deb http://fr.archive.ubuntu.com/ubuntu bionic main restricted" >> /etc/apt/sources.list
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \ psmisc \
software-properties-common \ git \
gnupg \ && rm -rf /var/lib/apt/lists/*
git && \
rm -rf /var/lib/apt/lists/*
# Some GIT configuration command quite useful # Some GIT configuration commands quite useful
RUN /bin/bash -c "if [[ -v NEEDED_GIT_PROXY ]]; then git config --global http.proxy $NEEDED_GIT_PROXY; fi"
RUN git config --global https.postBuffer 123289600 && \ RUN git config --global https.postBuffer 123289600 && \
git config --global http.sslverify false git config --global http.sslverify false
...@@ -54,17 +50,26 @@ RUN git config --global https.postBuffer 123289600 && \ ...@@ -54,17 +50,26 @@ RUN git config --global https.postBuffer 123289600 && \
WORKDIR /openair-smf WORKDIR /openair-smf
COPY . /openair-smf COPY . /openair-smf
# Installing and Building SMF # Installing all the needed libraries/packages to build and run SMF
WORKDIR /openair-smf/build/scripts
RUN ./build_smf --install-deps --force && \
cp -Rf /openair-smf/build/ext /openair-smf-ext-ref
#---------------------------------------------------------------------
# BUILDER IMAGE
#---------------------------------------------------------------------
FROM oai-smf-base as oai-smf-builder
# Building SMF
WORKDIR /openair-smf/build/scripts WORKDIR /openair-smf/build/scripts
RUN ./build_smf --install-deps --force RUN ldconfig && \
RUN ./build_smf --clean --Verbose --build-type Release --jobs && \ ./build_smf --clean --Verbose --build-type Release --jobs && \
ldd /openair-smf/build/smf/build/smf && \ ldd /openair-smf/build/smf/build/smf && \
mv /openair-smf/build/smf/build/smf /openair-smf/build/smf/build/oai_smf mv /openair-smf/build/smf/build/smf /openair-smf/build/smf/build/oai_smf
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# TARGET IMAGE # TARGET IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM ubuntu:bionic as oai-smf FROM $BASE_IMAGE as oai-smf
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris ENV TZ=Europe/Paris
# We install some debug tools for the moment in addition of mandatory libraries # We install some debug tools for the moment in addition of mandatory libraries
...@@ -73,36 +78,53 @@ RUN apt-get update && \ ...@@ -73,36 +78,53 @@ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \ DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \ psmisc \
net-tools \ net-tools \
tzdata \
bc \ bc \
perl \ libssh-4 \
openssl \ openssl \
libasan4 \ libbrotli1 \
netbase \
# Ubuntu 18 --> libasan4
# Ubuntu 20 --> libasan5
# Ubuntu 22 --> libasan6
libgssapi-krb5-2 \
# Ubuntu 18/20 --> libldap-2.4-2
# Ubuntu 22 --> libldap-2.5-0
libldap-2.?-? \
libconfig++9v5 \
libsctp1 \
librtmp1 \ librtmp1 \
libpsl5 \ libpsl5 \
libcurl?-gnutls \ libcurl?-gnutls \
libgssapi-krb5-2 \ # Ubuntu 18 --> boost62/65 -> will remove both
libldap-2.4-2 \ # Ubuntu 20 --> boost67/71 -> will remove 67
libconfig++9v5 \ # Ubuntu 22 --> boost74
&& rm -rf /var/lib/apt/lists/* libboost-thread1.??.0 \
libboost-chrono1.??.0 \
&& rm -rf /var/lib/apt/lists/* \
/lib/x86_64-linux-gnu/libboost_system.so.1.6*.0 \
/lib/x86_64-linux-gnu/libboost_chrono.so.1.6*.0 \
/lib/x86_64-linux-gnu/libboost_thread.so.1.6*.0
# Copying executable and generated libraries # Copying executable and generated libraries
WORKDIR /openair-smf/bin WORKDIR /openair-smf/bin
COPY --from=oai-smf-builder \ COPY --from=oai-smf-builder \
/openair-smf/build/smf/build/oai_smf \ /openair-smf/build/smf/build/oai_smf \
/openair-smf/scripts/entrypoint.sh \ /openair-smf/scripts/entrypoint.sh \
/openair-smf/scripts/healthcheck.sh \
./ ./
WORKDIR /usr/local/lib/ WORKDIR /usr/local/lib/
COPY --from=oai-smf-builder \ COPY --from=oai-smf-builder \
/usr/local/lib/libpistache.so \ # Copying only the packages built from source
/usr/local/lib/libnghttp2.so.14 \ /usr/local/lib/libnghttp2.so.14 \
/usr/local/lib/libnghttp2_asio.so.1 \ /usr/local/lib/libnghttp2_asio.so.1 \
/usr/lib/libboost_system.so.1.67.0 \ /usr/local/lib/libpistache.so \
/usr/lib/libboost_thread.so.1.67.0 \ # Ubuntu 18 --> boost 67 will be copied
/usr/lib/libboost_chrono.so.1.67.0 \ /usr/lib/libboost_system.so.1.* \
/openair-smf/build/smf/build/nas/libNAS.so \ /usr/lib/libboost_thread.so.1.* \
/usr/lib/libboost_chrono.so.1.* \
./ ./
RUN ldconfig && \ RUN ldconfig && \
ldd /openair-smf/bin/oai_smf ldd /openair-smf/bin/oai_smf
...@@ -111,7 +133,14 @@ RUN ldconfig && \ ...@@ -111,7 +133,14 @@ RUN ldconfig && \
WORKDIR /openair-smf/etc WORKDIR /openair-smf/etc
COPY --from=oai-smf-builder /openair-smf/etc/smf.conf . COPY --from=oai-smf-builder /openair-smf/etc/smf.conf .
# expose ports
WORKDIR /openair-smf WORKDIR /openair-smf
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-smf/bin/healthcheck.sh
EXPOSE 80/tcp 9090/tcp 8805/udp EXPOSE 80/tcp 9090/tcp 8805/udp
......
#!/bin/bash
set -eo pipefail
STATUS=0
SMF_IP_SBI_INTERFACE=$(ifconfig $SMF_INTERFACE_NAME_FOR_SBI | grep inet | awk {'print $2'})
#Check if entrypoint properly configured the conf file and no parameter is unset(optional)
SMF_SBI_PORT_STATUS=$(netstat -tnpl | grep -o "$SMF_IP_SBI_INTERFACE:$SMF_INTERFACE_PORT_FOR_SBI")
NB_UNREPLACED_AT=`cat /openair-smf/etc/*.conf | grep -v contact@openairinterface.org | grep -c @ || true`
if [ $NB_UNREPLACED_AT -ne 0 ]; then
STATUS=-1
echo "Healthcheck error: UNHEALTHY configuration file is not configured properly"
fi
if [[ -z $SMF_SBI_PORT_STATUS ]]; then
STATUS=-1
echo "Healthcheck error: UNHEALTHY SBI TCP/HTTP port $SMF_INTERFACE_PORT_FOR_SBI is not listening."
fi
exit $STATUS
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment