Commit 68aa5369 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'rhel8-support' into 'develop'

Added support for rhel8 image build

See merge request oai/cn5g/oai-cn5g-amf!9
parents 41457d64 8d7c93e8
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# #
####################################### #######################################
#SUPPORTED_DISTRO="Ubuntu 18.04, CentOS 7, RHEL 7" #SUPPORTED_DISTRO="Ubuntu 18.04, CentOS 7, RHEL 7"
SUPPORTED_DISTRO="Ubuntu 18.04" SUPPORTED_DISTRO="Ubuntu 18.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
...@@ -33,13 +33,13 @@ OS_DISTRO=$(grep "^ID=" /etc/os-release | sed "s/ID=//" | sed "s/\"//g") ...@@ -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") 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="cmake" ;; 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" ;;
esac 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 ] if [ $IS_CONTAINER -eq 0 ]
then then
...@@ -128,7 +128,10 @@ check_supported_distribution() { ...@@ -128,7 +128,10 @@ check_supported_distribution() {
local distribution=$(get_distribution_release) local distribution=$(get_distribution_release)
case "$distribution" in case "$distribution" in
"ubuntu18.04") return 0 ;; "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 ;; #"centos7") return 0 ;;
esac esac
return 1 return 1
......
...@@ -53,7 +53,7 @@ install_fmt() { ...@@ -53,7 +53,7 @@ install_fmt() {
git clone https://github.com/fmtlib/fmt.git git clone https://github.com/fmtlib/fmt.git
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
cd fmt cd fmt
cmake -DFMT_TEST=FALSE . $CMAKE -DFMT_TEST=FALSE .
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
make -j `nproc` make -j `nproc`
ret=$?;[[ $ret -ne 0 ]] && return $ret ret=$?;[[ $ret -ne 0 ]] && return $ret
...@@ -137,7 +137,7 @@ install_pistache_from_git() { ...@@ -137,7 +137,7 @@ install_pistache_from_git() {
cd pistache && git checkout e18ed9baeb2145af6f9ea41246cf48054ffd9907 cd pistache && git checkout e18ed9baeb2145af6f9ea41246cf48054ffd9907
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build 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 ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
...@@ -182,7 +182,7 @@ install_nlohmann_from_git() { ...@@ -182,7 +182,7 @@ install_nlohmann_from_git() {
cd json && git checkout master cd json && git checkout master
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
mkdir _build && cd _build 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 ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make make
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
...@@ -244,8 +244,10 @@ check_install_amf_deps(){ ...@@ -244,8 +244,10 @@ check_install_amf_deps(){
PACKAGE_LIST="\ PACKAGE_LIST="\
autoconf \ autoconf \
automake \ automake \
gcc-c++ \
bison \ bison \
$CMAKE \ $CMAKE \
make \
doxygen \ doxygen \
flex \ flex \
gdb \ gdb \
...@@ -298,10 +300,12 @@ check_install_amf_deps(){ ...@@ -298,10 +300,12 @@ check_install_amf_deps(){
elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then elif [[ "$OS_BASEDISTRO" == "fedora" ]]; then
PACKAGE_LIST="\ PACKAGE_LIST="\
guile-devel \ guile-devel \
mysql \
mysql-devel \
mysql-libs \
libconfig-devel \ libconfig-devel \
libgcrypt-devel \ libgcrypt-devel \
gmp-devel \ gmp-devel \
libidn2-devel \
libidn-devel \ libidn-devel \
lksctp-tools \ lksctp-tools \
lksctp-tools-devel \ lksctp-tools-devel \
...@@ -311,7 +315,9 @@ check_install_amf_deps(){ ...@@ -311,7 +315,9 @@ check_install_amf_deps(){
libxml2-devel \ libxml2-devel \
openssl \ openssl \
check \ check \
python \ nettle-devel \
libcurl-devel \
python2 \
pkgconfig" pkgconfig"
else else
echo_fatal "$OS_DISTRO is not a supported distribution." echo_fatal "$OS_DISTRO is not a supported distribution."
......
...@@ -47,33 +47,52 @@ install_fb_folly_from_source(){ ...@@ -47,33 +47,52 @@ install_fb_folly_from_source(){
if [[ $prompt =~ [yY](es)* ]] if [[ $prompt =~ [yY](es)* ]]
then then
if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
$SUDO apt-get install $OPTION \ $SUDO $INSTALLER install $OPTION \
g++ \ gcc-c++ \
cmake \ $CMAKE \
libboost-all-dev \ boost-devel \
libevent-dev \ libevent-devel \
libdouble-conversion-dev \ double-conversion-devel \
libgoogle-glog-dev \ glog-devel \
libgflags-dev \ gflags-devel \
libiberty-dev \ snappy-devel \
liblz4-dev \ make \
liblzma-dev \ lz4-devel \
libsnappy-dev \ zlib-devel \
make \ binutils-devel \
wget \ jemalloc-devel \
zlib1g-dev \ openssl-devel \
binutils-dev \ pkg-config
libjemalloc-dev \ ret=$?;[[ $ret -ne 0 ]] && return $ret
libssl-dev \ elif [[ $OS_DISTRO == "ubuntu" ]]; then
pkg-config $SUDO $INSTALLER install $OPTION \
ret=$?;[[ $ret -ne 0 ]] && return $ret 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 pushd /tmp
if [ $debug -eq 1 ]; then if [ $debug -eq 1 ]; then
# For advanced debugging options # For advanced debugging options
$SUDO apt-get install $OPTION \ $SUDO $INSTALLER install $OPTION \
libunwind8-dev \ libunwind8-dev \
libelf-dev \ libelf-dev \
libdwarf-dev libdwarf-dev
...@@ -83,7 +102,7 @@ install_fb_folly_from_source(){ ...@@ -83,7 +102,7 @@ install_fb_folly_from_source(){
tar zxf release-1.8.0.tar.gz && \ tar zxf release-1.8.0.tar.gz && \
rm -f release-1.8.0.tar.gz && \ rm -f release-1.8.0.tar.gz && \
cd googletest-release-1.8.0 && \ cd googletest-release-1.8.0 && \
cmake . && \ $CMAKE . && \
make && \ make && \
$SUDO make install $SUDO make install
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
...@@ -95,8 +114,32 @@ install_fb_folly_from_source(){ ...@@ -95,8 +114,32 @@ install_fb_folly_from_source(){
git clone https://github.com/facebook/folly.git git clone https://github.com/facebook/folly.git
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
cd folly 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 mkdir _build && cd _build
cmake .. if [[ "$OS_BASEDISTRO" == "fedora" ]]; then
cmake3 ..
else
cmake ..
fi
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
make -j $(nproc) make -j $(nproc)
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
...@@ -104,6 +147,7 @@ install_fb_folly_from_source(){ ...@@ -104,6 +147,7 @@ install_fb_folly_from_source(){
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
popd popd
fi fi
echo_success "End of folly installation"
return 0 return 0
} }
...@@ -776,7 +776,7 @@ class HtmlReport(): ...@@ -776,7 +776,7 @@ class HtmlReport():
if os.path.isfile(cwd + '/archives/' + logFileName): if os.path.isfile(cwd + '/archives/' + logFileName):
if nfType == 'AMF': if nfType == 'AMF':
section_start_pattern = 'Successfully tagged oai-amf' section_start_pattern = 'Successfully tagged oai-amf'
section_end_pattern = 'OAI-SMF DOCKER IMAGE BUILD' section_end_pattern = 'OAI-AMF DOCKER IMAGE BUILD'
section_status = False section_status = False
status = False status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile: with open(cwd + '/archives/' + logFileName, 'r') as logfile:
...@@ -790,7 +790,7 @@ class HtmlReport(): ...@@ -790,7 +790,7 @@ class HtmlReport():
if section_status: if section_status:
if nfType == 'AMF': if nfType == 'AMF':
if self.git_pull_request: if self.git_pull_request:
result = re.search('oai-amf *ci-temp', line) result = re.search('oai-amf *ci-tmp', line)
else: else:
result = re.search('oai-amf *develop', line) result = re.search('oai-amf *develop', line)
if result is not None: if result is not None:
......
#/*
# * 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"]
#!/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 "$@"
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