diff --git a/build/scripts/build_helper b/build/scripts/build_helper index d689501f88eab24b2051d0ad489177037c020613..8bad057289b33ecde0b8594cc88925ce23157793 100644 --- a/build/scripts/build_helper +++ b/build/scripts/build_helper @@ -25,7 +25,7 @@ # ####################################### #SUPPORTED_DISTRO="Ubuntu 18.04, CentOS 7, RHEL 7" -SUPPORTED_DISTRO="Ubuntu 18.04" +SUPPORTED_DISTRO="Ubuntu 18.04 RHEL" if [ ! -f /etc/os-release ]; then echo_fatal "No /etc/os-release file found. You're likely on an unsupported distro." fi @@ -33,13 +33,13 @@ 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") case "$OS_DISTRO" in 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" ;; debian) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; esac -IS_CONTAINER=`egrep -c "docker|kubepods" /proc/self/cgroup` +IS_CONTAINER=`egrep -c "docker|kubepods|podman" /proc/self/cgroup` if [ $IS_CONTAINER -eq 0 ] then @@ -128,7 +128,10 @@ check_supported_distribution() { local distribution=$(get_distribution_release) case "$distribution" in "ubuntu18.04") return 0 ;; - #"rhel7") return 0 ;; + "rhel8") return 0 ;; + "rhel8.2") return 0 ;; + "rhel8.3") return 0 ;; + "rhel8.4") return 0 ;; #"centos7") return 0 ;; esac return 1 diff --git a/build/scripts/build_helper.amf b/build/scripts/build_helper.amf index c62393670c9ce449f6977afb47e88a8424f14f44..4262e2def986603d8fbf2ff541f764f0cfb5306f 100755 --- a/build/scripts/build_helper.amf +++ b/build/scripts/build_helper.amf @@ -53,7 +53,7 @@ install_fmt() { git clone https://github.com/fmtlib/fmt.git ret=$?;[[ $ret -ne 0 ]] && return $ret cd fmt - cmake -DFMT_TEST=FALSE . + $CMAKE -DFMT_TEST=FALSE . ret=$?;[[ $ret -ne 0 ]] && return $ret make -j `nproc` ret=$?;[[ $ret -ne 0 ]] && return $ret @@ -137,7 +137,7 @@ install_pistache_from_git() { cd pistache && git checkout e18ed9baeb2145af6f9ea41246cf48054ffd9907 ret=$?;[[ $ret -ne 0 ]] && popd && return $ret mkdir _build && cd _build - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. + $CMAKE -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. ret=$?;[[ $ret -ne 0 ]] && popd && return $ret make ret=$?;[[ $ret -ne 0 ]] && popd && return $ret @@ -182,7 +182,7 @@ install_nlohmann_from_git() { cd json && git checkout master ret=$?;[[ $ret -ne 0 ]] && popd && return $ret mkdir _build && cd _build - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=OFF .. + $CMAKE -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=OFF .. ret=$?;[[ $ret -ne 0 ]] && popd && return $ret make ret=$?;[[ $ret -ne 0 ]] && popd && return $ret @@ -244,8 +244,10 @@ check_install_amf_deps(){ PACKAGE_LIST="\ autoconf \ automake \ + gcc-c++ \ bison \ $CMAKE \ + make \ doxygen \ flex \ gdb \ @@ -298,10 +300,12 @@ check_install_amf_deps(){ elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then PACKAGE_LIST="\ guile-devel \ + mysql \ + mysql-devel \ + mysql-libs \ libconfig-devel \ libgcrypt-devel \ gmp-devel \ - libidn2-devel \ libidn-devel \ lksctp-tools \ lksctp-tools-devel \ @@ -311,7 +315,9 @@ check_install_amf_deps(){ libxml2-devel \ openssl \ check \ - python \ + nettle-devel \ + libcurl-devel \ + python2 \ pkgconfig" else echo_fatal "$OS_DISTRO is not a supported distribution." diff --git a/build/scripts/build_helper.fb_folly b/build/scripts/build_helper.fb_folly index a162b3cafc1a30bac92a2d2aeda03a5fb7c7d7b5..452860fe6b4dd13a2fa2522ff5bf610b92ac8cf7 100644 --- a/build/scripts/build_helper.fb_folly +++ b/build/scripts/build_helper.fb_folly @@ -47,33 +47,52 @@ install_fb_folly_from_source(){ if [[ $prompt =~ [yY](es)* ]] then - - $SUDO apt-get install $OPTION \ - g++ \ - cmake \ - libboost-all-dev \ - libevent-dev \ - libdouble-conversion-dev \ - libgoogle-glog-dev \ - libgflags-dev \ - libiberty-dev \ - liblz4-dev \ - liblzma-dev \ - libsnappy-dev \ - make \ - wget \ - zlib1g-dev \ - binutils-dev \ - libjemalloc-dev \ - libssl-dev \ - pkg-config - ret=$?;[[ $ret -ne 0 ]] && return $ret + if [[ "$OS_BASEDISTRO" == "fedora" ]]; then + $SUDO $INSTALLER install $OPTION \ + gcc-c++ \ + $CMAKE \ + boost-devel \ + libevent-devel \ + double-conversion-devel \ + glog-devel \ + gflags-devel \ + snappy-devel \ + make \ + lz4-devel \ + zlib-devel \ + binutils-devel \ + jemalloc-devel \ + openssl-devel \ + pkg-config + ret=$?;[[ $ret -ne 0 ]] && return $ret + elif [[ $OS_DISTRO == "ubuntu" ]]; then + $SUDO $INSTALLER install $OPTION \ + g++ \ + cmake \ + libboost-all-dev \ + libevent-dev \ + libdouble-conversion-dev \ + libgoogle-glog-dev \ + libgflags-dev \ + libiberty-dev \ + liblz4-dev \ + liblzma-dev \ + libsnappy-dev \ + make \ + wget \ + zlib1g-dev \ + binutils-dev \ + libjemalloc-dev \ + libssl-dev \ + pkg-config + ret=$?;[[ $ret -ne 0 ]] && return $ret + fi pushd /tmp if [ $debug -eq 1 ]; then # For advanced debugging options - $SUDO apt-get install $OPTION \ + $SUDO $INSTALLER install $OPTION \ libunwind8-dev \ libelf-dev \ libdwarf-dev @@ -83,7 +102,7 @@ install_fb_folly_from_source(){ tar zxf release-1.8.0.tar.gz && \ rm -f release-1.8.0.tar.gz && \ cd googletest-release-1.8.0 && \ - cmake . && \ + $CMAKE . && \ make && \ $SUDO make install ret=$?;[[ $ret -ne 0 ]] && popd && return $ret @@ -95,8 +114,32 @@ install_fb_folly_from_source(){ git clone https://github.com/facebook/folly.git ret=$?;[[ $ret -ne 0 ]] && popd && return $ret cd folly + if [[ "$OS_BASEDISTRO" == "fedora" ]]; then + git checkout -f v2019.06.17.00 + echo 'diff --git a/build/fbcode_builder/CMake/FindGflags.cmake b/build/fbcode_builder/CMake/FindGflags.cmake' > patch.diff + echo 'index 246ceac..3b96716 100644' >> patch.diff + echo '--- a/build/fbcode_builder/CMake/FindGflags.cmake' >> patch.diff + echo '+++ b/build/fbcode_builder/CMake/FindGflags.cmake' >> patch.diff + echo '@@ -34,6 +34,9 @@ IF (LIBGFLAGS_INCLUDE_DIR)' >> patch.diff + echo ' ENDIF ()' >> patch.diff + echo '' >> patch.diff + echo ' find_package(gflags CONFIG QUIET)' >> patch.diff + echo '+get_filename_component (_LIB_PATH "${gflags_CONFIG}/../../../" ABSOLUTE)' >> patch.diff + echo '+unset(gflags_LIBRARIES)' >> patch.diff + echo '+find_library(gflags_LIBRARIES gflags PATHS ${_LIB_PATH})' >> patch.diff + echo ' if (gflags_FOUND)' >> patch.diff + echo ' if (NOT Gflags_FIND_QUIETLY)' >> patch.diff + echo ' message(STATUS "Found gflags from package config ${gflags_CONFIG}")' >> patch.diff + git apply patch.diff + else + git checkout -f v2019.11.11.00 + fi mkdir _build && cd _build - cmake .. + if [[ "$OS_BASEDISTRO" == "fedora" ]]; then + cmake3 .. + else + cmake .. + fi ret=$?;[[ $ret -ne 0 ]] && popd && return $ret make -j $(nproc) ret=$?;[[ $ret -ne 0 ]] && popd && return $ret @@ -104,6 +147,7 @@ install_fb_folly_from_source(){ ret=$?;[[ $ret -ne 0 ]] && popd && return $ret popd fi + echo_success "End of folly installation" return 0 } diff --git a/docker/Dockerfile.amf.rhel8.2 b/docker/Dockerfile.amf.rhel8.2 new file mode 100644 index 0000000000000000000000000000000000000000..fed003ac2df486f9fd37254fe9d31be2e78191bb --- /dev/null +++ b/docker/Dockerfile.amf.rhel8.2 @@ -0,0 +1,135 @@ +#/* +# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more +# * contributor license agreements. See the NOTICE file distributed with +# * this work for additional information regarding copyright ownership. +# * The OpenAirInterface Software Alliance licenses this file to You under +# * the OAI Public License, Version 1.1 (the "License"); you may not use this file +# * except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.openairinterface.org/?page_id=698 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# *------------------------------------------------------------------------------- +# * For more information about the OpenAirInterface (OAI) Software Alliance: +# * contact@openairinterface.org +# */ +#--------------------------------------------------------------------- +# +# Dockerfile for the Open-Air-Interface AMF service +# Valid for RHEL 8.2 +# +#--------------------------------------------------------------------- + +#--------------------------------------------------------------------- +# BUILDER IMAGE +#--------------------------------------------------------------------- +FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-amf-builder + +ARG NEEDED_GIT_PROXY + +COPY tmp/ca/redhat-uep.pem /etc/rhsm/ca +COPY tmp/entitlement/*.pem /etc/pki/entitlement + +#ENV DEBIAN_FRONTEND=noninteractive +#ENV TZ=Europe +#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN rm -f /etc/rhsm-host && \ + yum repolist --disablerepo=* && \ + subscription-manager repos --enable codeready-builder-for-rhel-8-x86_64-rpms && \ + yum update -y && \ + yum install -y \ + psmisc \ + git \ + diffutils \ + file \ + gcc-c++ \ + cmake3 \ + ninja-build \ + boost-devel \ + openssl-devel \ + openssl + +# 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 http.sslverify false + +# cpprest package install +RUN git clone https://github.com/Microsoft/cpprestsdk.git +RUN cd cpprestsdk && git submodule update --init && mkdir build && cd build && cmake3 -G Ninja .. -DCMAKE_BUILD_TYPE=Release && ninja install && ldconfig -v + +# Copying source code +WORKDIR /openair-amf/ +COPY . /openair-amf + +# Installing all the needed libraries/packages to build and run AMF +WORKDIR /openair-amf/build/scripts +RUN ./build_amf --install-deps --force + +# Building AMF +WORKDIR /openair-amf/build/scripts +RUN ./build_amf --clean --Verbose --build-type Release --jobs + + +#--------------------------------------------------------------------- +# TARGET IMAGE +#--------------------------------------------------------------------- +FROM registry.access.redhat.com/ubi8/ubi:latest as oai-amf + +# We install some debug tools for the moment in addition of mandatory libraries +RUN yum update -y && \ + yum install -y --enablerepo="ubi-8-codeready-builder" \ + psmisc \ + net-tools \ + libevent && \ + rm -rf /var/lib/apt/lists/* + + +# Copying executable and generated libraries +WORKDIR /openair-amf/bin +COPY --from=oai-amf-builder /openair-amf/build/amf/build/amf oai_amf + +COPY --from=oai-amf-builder /usr/lib64/libconfig++.so.9 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_system.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/local/lib64/libpistache.so.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/mysql/libmysqlclient.so.21 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libsctp.so.1 /usr/lib64/ +COPY --from=oai-amf-builder /usr/local/lib64/libcpprest.so.2.10 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_random.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_thread.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_filesystem.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_chrono.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_atomic.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_date_time.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libboost_regex.so.1.66.0 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libicudata.so.60 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libicui18n.so.60 /usr/lib64/ +COPY --from=oai-amf-builder /usr/lib64/libicuuc.so.60 /usr/lib64/ + +COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh entrypoint.sh + +# debug +#RUN ldconfig -v +#RUN ldd oai_amf + +# Copying template configuration files +WORKDIR /openair-amf/etc +COPY --from=oai-amf-builder /openair-amf/etc/amf.conf . +COPY --from=oai-amf-builder /openair-amf/etc/modules.conf . + +WORKDIR /openair-amf + +# expose ports +EXPOSE 80/tcp 9090/tcp 38412/sctp + +CMD ["/openair-smf/bin/oai_amf", "-c", "/openair-smf/etc/amf.conf", "-o"] +ENTRYPOINT ["/openair-smf/bin/entrypoint.sh"] +#CMD ["sleep", "infinity"] + + diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..5254592acb76ab5a7bb398bb2b00daec130f68e7 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -euo pipefail + +CONFIG_DIR="/oai-cn5g-amf/etc" +PUSH_PROTOCOL_OPTION=${PUSH_PROTOCOL_OPTION:-no} + +for c in ${CONFIG_DIR}/*.conf; do + # grep variable names (format: ${VAR}) from template to be rendered + VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs) + + # create sed expressions for substituting each occurrence of ${VAR} + # with the value of the environment variable "VAR" + EXPRESSIONS="" + for v in ${VARS}; do + NEW_VAR=`echo $v | sed -e "s#@##g"` + if [[ "${!NEW_VAR}x" == "x" ]]; then + echo "Error: Environment variable '${NEW_VAR}' is not set." \ + "Config file '$(basename $c)' requires all of $VARS." + exit 1 + fi + EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g" + done + EXPRESSIONS="${EXPRESSIONS#';'}" + + # render template and inline replace config file + sed -i "${EXPRESSIONS}" ${c} +done + +exec "$@"