Commit 9c5df62c authored by Raphael Defosseux's avatar Raphael Defosseux

feat(build): support for Ubuntu 22 and adding healthcheck in target image

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent e83c17c2
...@@ -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-nrf --tag oai-nrf:' + nrf_tag + ' --file docker/Dockerfile.nrf.ubuntu18 . > archives/nrf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host) myShCmd('docker build --no-cache --target oai-nrf --tag oai-nrf:' + nrf_tag + ' --file docker/Dockerfile.nrf.ubuntu . > archives/nrf_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 {
...@@ -252,7 +252,7 @@ pipeline { ...@@ -252,7 +252,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-nrf --tag oai-nrf:' + nrf_tag + ' --file docker/Dockerfile.nrf.rhel8 . > archives/nrf_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-nrf --tag oai-nrf:' + nrf_tag + ' --file docker/Dockerfile.nrf.rhel8 --format docker . > archives/nrf_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-nrf:' + nrf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host) myShCmd('python3 ./ci-scripts/flatten_image.py --tag oai-nrf:' + nrf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
......
...@@ -29,25 +29,27 @@ ...@@ -29,25 +29,27 @@
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# BUILDER IMAGE # BUILDER IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
ARG BASE_IMAGE=ubuntu:bionic
FROM oai-nrf-base:latest as oai-nrf-builder FROM oai-nrf-base:latest as oai-nrf-builder
# Copying source code
WORKDIR /openair-nrf/ WORKDIR /openair-nrf/
COPY . /openair-nrf COPY . /openair-nrf
RUN cp -Rf /openair-nrf-ext-ref /openair-nrf/build/ext RUN cp -Rf /openair-nrf-ext-ref /openair-nrf/build/ext
# Building NRF # Building NRF
WORKDIR /openair-nrf/build/scripts WORKDIR /openair-nrf/build/scripts
RUN ./build_nrf --clean --Verbose --build-type Release --jobs && \ RUN ldconfig && \
./build_nrf --clean --Verbose --build-type Release --jobs && \
ldd /openair-nrf/build/nrf/build/nrf && \ ldd /openair-nrf/build/nrf/build/nrf && \
mv /openair-nrf/build/nrf/build/nrf /openair-nrf/build/nrf/build/oai_nrf mv /openair-nrf/build/nrf/build/nrf /openair-nrf/build/nrf/build/oai_nrf
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# TARGET IMAGE # TARGET IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM ubuntu:bionic as oai-nrf FROM $BASE_IMAGE as oai-nrf
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
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
...@@ -57,30 +59,44 @@ RUN apt-get update && \ ...@@ -57,30 +59,44 @@ RUN apt-get update && \
iputils-ping \ iputils-ping \
bc \ bc \
tzdata \ tzdata \
libasan4 \ # Ubuntu 18 --> libasan4
libgoogle-glog0v5 \ # Ubuntu 20 --> libasan5
libdouble-conversion1 \ # Ubuntu 22 --> libasan6
libasan? \
libconfig++9v5 \ libconfig++9v5 \
libldap-2.4-2 \ # Ubuntu 18/20 --> libldap-2.4-2
# Ubuntu 22 --> libldap-2.5-0
libldap-2.?-? \
libkrb5-3 \ libkrb5-3 \
libgssapi-krb5-2 \ libgssapi-krb5-2 \
libcurl4-gnutls-dev \
librtmp1 \ librtmp1 \
libpsl5 \ libpsl5 \
&& rm -rf /var/lib/apt/lists/* # Ubuntu 18 --> boost62/65 -> will remove both
# Ubuntu 20 --> boost67/71 -> will remove 67
# Ubuntu 22 --> boost74
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-nrf/bin WORKDIR /openair-nrf/bin
COPY --from=oai-nrf-builder \ COPY --from=oai-nrf-builder \
/openair-nrf/build/nrf/build/oai_nrf \ /openair-nrf/build/nrf/build/oai_nrf \
/openair-nrf/scripts/entrypoint.sh \ /openair-nrf/scripts/entrypoint.sh \
/openair-nrf/scripts/healthcheck.sh \
./ ./
COPY --from=oai-nrf-builder \ COPY --from=oai-nrf-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/x86_64-linux-gnu/libcurl-gnutls.so.4 \ /usr/local/lib/libpistache.so \
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 \ # Ubuntu 18 --> boost 67 will be copied
/usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 \ /usr/lib/libboost_system.so.1.* \
/usr/lib/libboost_thread.so.1.* \
/usr/local/lib/ /usr/local/lib/
RUN ldconfig && \ RUN ldconfig && \
...@@ -93,6 +109,11 @@ WORKDIR /openair-nrf ...@@ -93,6 +109,11 @@ WORKDIR /openair-nrf
# expose ports # expose ports
EXPOSE 80/tcp 9090/tcp EXPOSE 80/tcp 9090/tcp
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-nrf/bin/healthcheck.sh
ENTRYPOINT ["/bin/bash","/openair-nrf/bin/entrypoint.sh"] ENTRYPOINT ["/bin/bash","/openair-nrf/bin/entrypoint.sh"]
CMD ["/openair-nrf/bin/oai_nrf", "-c", "/openair-nrf/etc/nrf.conf", "-o"] CMD ["/openair-nrf/bin/oai_nrf", "-c", "/openair-nrf/etc/nrf.conf", "-o"]
...@@ -36,7 +36,7 @@ def _parse_args() -> argparse.Namespace: ...@@ -36,7 +36,7 @@ def _parse_args() -> argparse.Namespace:
'--tag', '-t', '--tag', '-t',
action='store', action='store',
required=True, required=True,
help='Image Tag in image-name:image tag format', help='Image Tag in image-name:image-tag format',
) )
return parser.parse_args() return parser.parse_args()
...@@ -49,6 +49,9 @@ def perform_flattening(tag): ...@@ -49,6 +49,9 @@ def perform_flattening(tag):
if re.search('podman', podman_check.strip()): if re.search('podman', podman_check.strip()):
cli = 'sudo podman' cli = 'sudo podman'
image_prefix = 'localhost/' image_prefix = 'localhost/'
# since HEALTHCHECK is not supported by podman import
# we don't flatten
return 0
if cli == '': if cli == '':
cmd = 'which docker || true' cmd = 'which docker || true'
docker_check = subprocess.check_output(cmd, shell=True, universal_newlines=True) docker_check = subprocess.check_output(cmd, shell=True, universal_newlines=True)
...@@ -74,6 +77,7 @@ def perform_flattening(tag): ...@@ -74,6 +77,7 @@ def perform_flattening(tag):
cmd += ' --change "WORKDIR /openair-nrf" ' cmd += ' --change "WORKDIR /openair-nrf" '
cmd += ' --change "EXPOSE 80/tcp" ' cmd += ' --change "EXPOSE 80/tcp" '
cmd += ' --change "EXPOSE 9090/tcp" ' cmd += ' --change "EXPOSE 9090/tcp" '
cmd += ' --change "HEALTHCHECK --interval=10s --timeout=15s --retries=6 CMD /openair-nrf/bin/healthcheck.sh" '
cmd += ' --change "CMD [\\"/openair-nrf/bin/oai_nrf\\", \\"-c\\", \\"/openair-nrf/etc/nrf.conf\\", \\"-o\\"]" ' cmd += ' --change "CMD [\\"/openair-nrf/bin/oai_nrf\\", \\"-c\\", \\"/openair-nrf/etc/nrf.conf\\", \\"-o\\"]" '
cmd += ' --change "ENTRYPOINT [\\"/bin/bash\\", \\"/openair-nrf/bin/entrypoint.sh\\"]" ' cmd += ' --change "ENTRYPOINT [\\"/bin/bash\\", \\"/openair-nrf/bin/entrypoint.sh\\"]" '
cmd += ' - ' + image_prefix + tag cmd += ' - ' + image_prefix + tag
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-nrf-builder FROM registry.access.redhat.com/ubi8/ubi:latest AS oai-nrf-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
...@@ -54,7 +52,6 @@ RUN rm -f /etc/rhsm-host && \ ...@@ -54,7 +52,6 @@ RUN rm -f /etc/rhsm-host && \
echo "/usr/local/lib64" >> /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
...@@ -72,17 +69,22 @@ RUN ./build_nrf --clean --Verbose --build-type Release --jobs && \ ...@@ -72,17 +69,22 @@ RUN ./build_nrf --clean --Verbose --build-type Release --jobs && \
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# TARGET IMAGE # TARGET IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM registry.access.redhat.com/ubi8/ubi:latest as oai-nrf FROM registry.access.redhat.com/ubi8/ubi-minimal:latest as oai-nrf
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
RUN yum update -y && \ RUN microdnf update -y && \
yum install -y --enablerepo="ubi-8-codeready-builder" \ microdnf install -y \
tzdata \
libasan \
procps-ng \
psmisc \ psmisc \
net-tools \ net-tools \
procps-ng\ libicu \
libevent && \ boost \
yum clean all -y && \ libevent \
findutils \
libconfig && \
microdnf clean all -y && \
rm -rf /var/cache/yum /var/cache/dnf rm -rf /var/cache/yum /var/cache/dnf
# Copying executable and generated libraries # Copying executable and generated libraries
...@@ -95,17 +97,7 @@ COPY --from=oai-nrf-builder \ ...@@ -95,17 +97,7 @@ COPY --from=oai-nrf-builder \
COPY --from=oai-nrf-builder \ COPY --from=oai-nrf-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/libgflags.so.2.1 \ /usr/local/lib/libnghttp2_asio.so.1 \
/usr/lib64/libglog.so.0 \
/usr/lib64/libdouble-conversion.so.1 \
/usr/lib64/libconfig++.so.9 \
/usr/lib64/libboost_system.so.1.66.0 \
/usr/lib64/libboost_thread.so.1.66.0 \
/usr/lib64/libboost_filesystem.so.1.66.0 \
/usr/lib64/libboost_chrono.so.1.66.0 \
/usr/lib64/libboost_atomic.so.1.66.0 \
/usr/lib64/libboost_date_time.so.1.66.0 \
/usr/lib64/libboost_regex.so.1.66.0 \
/usr/lib64/ /usr/lib64/
RUN ldconfig && \ RUN ldconfig && \
......
...@@ -21,17 +21,18 @@ ...@@ -21,17 +21,18 @@
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #
# Dockerfile for the Open-Air-Interface NRF service # Dockerfile for the Open-Air-Interface NRF service
# Valid for Ubuntu-18.04 (bionic) # Valid for Ubuntu-18.04 (bionic),
# Ubuntu-20.04 (focal),
# Ubuntu-22.04 (jammy)
# The port exposed by container are 8080/tcp , 9090/tcp change it according to your setup # The port exposed by container are 8080/tcp , 9090/tcp change it according to your setup
# #
#--------------------------------------------------------------------- #---------------------------------------------------------------------
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# BUILDER IMAGE # BASE IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM ubuntu:bionic as oai-nrf-builder ARG BASE_IMAGE=ubuntu:bionic
FROM $BASE_IMAGE as oai-nrf-base
ARG NEEDED_GIT_PROXY
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \ RUN apt-get update && \
...@@ -42,7 +43,6 @@ RUN apt-get update && \ ...@@ -42,7 +43,6 @@ RUN apt-get update && \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# 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
...@@ -50,20 +50,28 @@ RUN git config --global https.postBuffer 123289600 && \ ...@@ -50,20 +50,28 @@ RUN git config --global https.postBuffer 123289600 && \
COPY . /openair-nrf COPY . /openair-nrf
WORKDIR /openair-nrf WORKDIR /openair-nrf
# Installing and Building NRF # Installing all the needed libraries/packages to build and run NRF
WORKDIR /openair-nrf/build/scripts
RUN ./build_nrf --install-deps --force && \
cp -Rf /openair-f/build/ext /openair-nrf-ext-ref
#---------------------------------------------------------------------
# BUILDER IMAGE
#---------------------------------------------------------------------
FROM oai-nrf-base as oai-nrf-builder
# Building NRF
WORKDIR /openair-nrf/build/scripts WORKDIR /openair-nrf/build/scripts
RUN ./build_nrf --install-deps --force RUN ldconfig && \
RUN ./build_nrf --clean --Verbose --build-type Release --jobs && \ ./build_nrf --clean --Verbose --build-type Release --jobs && \
ldd /openair-nrf/build/nrf/build/nrf && \ ldd /openair-nrf/build/nrf/build/nrf && \
mv /openair-nrf/build/nrf/build/nrf /openair-nrf/build/nrf/build/oai_nrf mv /openair-nrf/build/nrf/build/nrf /openair-nrf/build/nrf/build/oai_nrf
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# TARGET IMAGE # TARGET IMAGE
#--------------------------------------------------------------------- #---------------------------------------------------------------------
FROM ubuntu:bionic as oai-nrf FROM $BASE_IMAGE as oai-nrf
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
RUN apt-get update && \ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \ DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
...@@ -73,30 +81,44 @@ RUN apt-get update && \ ...@@ -73,30 +81,44 @@ RUN apt-get update && \
iputils-ping \ iputils-ping \
bc \ bc \
tzdata \ tzdata \
libasan4 \ # Ubuntu 18 --> libasan4
libgoogle-glog0v5 \ # Ubuntu 20 --> libasan5
libdouble-conversion1 \ # Ubuntu 22 --> libasan6
libasan? \
libconfig++9v5 \ libconfig++9v5 \
libldap-2.4-2 \ # Ubuntu 18/20 --> libldap-2.4-2
# Ubuntu 22 --> libldap-2.5-0
libldap-2.?-? \
libkrb5-3 \ libkrb5-3 \
libgssapi-krb5-2 \ libgssapi-krb5-2 \
libcurl4-gnutls-dev \
librtmp1 \ librtmp1 \
libpsl5 \ libpsl5 \
&& rm -rf /var/lib/apt/lists/* # Ubuntu 18 --> boost62/65 -> will remove both
# Ubuntu 20 --> boost67/71 -> will remove 67
# Ubuntu 22 --> boost74
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-nrf/bin WORKDIR /openair-nrf/bin
COPY --from=oai-nrf-builder \ COPY --from=oai-nrf-builder \
/openair-nrf/build/nrf/build/oai_nrf \ /openair-nrf/build/nrf/build/oai_nrf \
/openair-nrf/scripts/entrypoint.sh \ /openair-nrf/scripts/entrypoint.sh \
/openair-nrf/scripts/healthcheck.sh \
./ ./
COPY --from=oai-nrf-builder \ COPY --from=oai-nrf-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/x86_64-linux-gnu/libcurl-gnutls.so.4 \ /usr/local/lib/libpistache.so \
/usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 \ # Ubuntu 18 --> boost 67 will be copied
/usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 \ /usr/lib/libboost_system.so.1.* \
/usr/lib/libboost_thread.so.1.* \
/usr/local/lib/ /usr/local/lib/
RUN ldconfig && \ RUN ldconfig && \
...@@ -109,6 +131,11 @@ WORKDIR /openair-nrf ...@@ -109,6 +131,11 @@ WORKDIR /openair-nrf
# expose ports # expose ports
EXPOSE 80/tcp 9090/tcp EXPOSE 80/tcp 9090/tcp
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-nrf/bin/healthcheck.sh
ENTRYPOINT ["/bin/bash","/openair-nrf/bin/entrypoint.sh"] ENTRYPOINT ["/bin/bash","/openair-nrf/bin/entrypoint.sh"]
CMD ["/openair-nrf/bin/oai_nrf", "-c", "/openair-nrf/etc/nrf.conf", "-o"] CMD ["/openair-nrf/bin/oai_nrf", "-c", "/openair-nrf/etc/nrf.conf", "-o"]
#!/bin/bash
set -eo pipefail
STATUS=0
NRF_IP_SBI_INTERFACE=$(ifconfig $NRF_INTERFACE_NAME_FOR_SBI | grep inet | awk {'print $2'})
NRF_SBI_PORT_STATUS=$(netstat -tnpl | grep -o "$NRF_IP_SBI_INTERFACE:$NRF_INTERFACE_PORT_FOR_SBI")
#Check if entrypoint properly configured the conf file and no parameter is unset(optional)
NB_UNREPLACED_AT=`cat /openair-nrf/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 $NRF_SBI_PORT_STATUS ]]; then
STATUS=1
echo "Healthcheck error: UNHEALTHY SBI TCP/HTTP port $NRF_INTERFACE_PORT_FOR_SBI is not listening."
fi
exit $STATUS
\ No newline at end of file
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