Commit e446ef05 authored by Raphael Defosseux's avatar Raphael Defosseux

feat(build): adding the healthcheck script natively in the image

 -- For RHEL podman build I had to add this `--format docker` option
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@openairinterface.org>
parent c1016471
......@@ -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('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 podman build --no-cache --target oai-amf --tag oai-amf:' + amf_tag + ' --file docker/Dockerfile.amf.rhel8 . > archives/amf_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-amf --tag oai-amf:' + amf_tag + ' --file docker/Dockerfile.amf.rhel8 --format docker . > archives/amf_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.
// If not satisfactory, we can remove it.
myShCmd('python3 ./ci-scripts/flatten_image.py --tag oai-amf:' + amf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
......
......@@ -94,6 +94,7 @@ WORKDIR /openair-amf/bin
COPY --from=oai-amf-builder \
/openair-amf/build/amf/build/oai_amf \
/openair-amf/scripts/entrypoint.sh \
/openair-amf/scripts/healthcheck.sh \
./
WORKDIR /usr/local/lib
......@@ -119,6 +120,11 @@ WORKDIR /openair-amf
# expose ports
EXPOSE 80/tcp 9090/tcp 38412/sctp
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-amf/bin/healthcheck.sh
ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
......@@ -103,6 +103,7 @@ WORKDIR /openair-amf/bin
COPY --from=oai-amf-builder \
/openair-amf/build/amf/build/oai_amf \
/openair-amf/scripts/entrypoint.sh \
/openair-amf/scripts/healthcheck.sh \
./
COPY --from=oai-amf-builder \
......@@ -122,6 +123,11 @@ WORKDIR /openair-amf
# expose ports
EXPOSE 80/tcp 9090/tcp 38412/sctp
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-amf/bin/healthcheck.sh
ENTRYPOINT ["/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
......@@ -115,6 +115,7 @@ WORKDIR /openair-amf/bin
COPY --from=oai-amf-builder \
/openair-amf/build/amf/build/oai_amf \
/openair-amf/scripts/entrypoint.sh \
/openair-amf/scripts/healthcheck.sh \
./
WORKDIR /usr/local/lib
......@@ -140,6 +141,11 @@ WORKDIR /openair-amf
# expose ports
EXPOSE 80/tcp 9090/tcp 38412/sctp
# healthcheck
HEALTHCHECK --interval=10s \
--timeout=15s \
--retries=6 \
CMD /openair-amf/bin/healthcheck.sh
ENTRYPOINT ["/bin/bash","/openair-amf/bin/entrypoint.sh"]
CMD ["/openair-amf/bin/oai_amf", "-c", "/openair-amf/etc/amf.conf", "-o"]
#!/bin/bash
set -eo pipefail
STATUS=0
AMF_PORT_FOR_NGAP=38412
AMF_PORT_FOR_N11_HTTP=80
AMF_IP_NGAP_INTERFACE=$(ifconfig $AMF_INTERFACE_NAME_FOR_NGAP | grep inet | awk {'print $2'})
AMF_IP_N11_INTERFACE=$(ifconfig $AMF_INTERFACE_NAME_FOR_N11 | grep inet | awk {'print $2'})
N2_PORT_STATUS=$(netstat -Snpl | grep -o "$AMF_IP_NGAP_INTERFACE:$AMF_PORT_FOR_NGAP")
N11_PORT_STATUS=$(netstat -tnpl | grep -o "$AMF_IP_N11_INTERFACE:$AMF_PORT_FOR_N11_HTTP")
#Check if entrypoint properly configured the conf file and no parameter is unset (optional)
NB_UNREPLACED_AT=`cat /openair-amf/etc/*.conf | grep -v contact@openairinterface.org | grep -c @ || true`
if [ $NB_UNREPLACED_AT -ne 0 ]; then
STATUS=1
echo "Healthcheck error: configuration file is not configured properly"
fi
if [[ -z $N2_PORT_STATUS ]]; then
STATUS=1
echo "Healthcheck error: N2 SCTP port $AMF_PORT_FOR_NGAP is not listening"
fi
if [[ -z $N11_PORT_STATUS ]]; then
STATUS=1
echo "Healthcheck error: N11/SBI TCP/HTTP port $AMF_PORT_FOR_N11_HTTP 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