Commit 738c05ba authored by Mohammed Ismail's avatar Mohammed Ismail

CI: making pipeline faster

Signed-off-by: default avatarMohammed Ismail <mohammed.ismail@openairinterface.org>
parent e0101792
......@@ -37,6 +37,10 @@ def new_host_user = ""
def smf_tag = "develop"
def smf_branch = "develop"
// We are using a base image to speed up CI build.
// This base image is potentially subject to changes over time.
def SMF_BASE_IMAGE_TAG = params.SmfBaseImageTag
//-------------------------------------------------------------------------------
// Pipeline start
pipeline {
......@@ -81,6 +85,16 @@ pipeline {
echo "Node is ${NODE_NAME}"
}
echo "Git URL is ${GIT_URL}"
if ("MERGE".equals(env.gitlabActionType)) {
try {
myShCmd('docker image inspect --format=\'Size = {{.Size}} bytes\' oai-smf-base:' + SMF_BASE_IMAGE_TAG, new_host_flag, new_host_user, new_host)
} catch (Exception e) {
currentBuild.result = 'FAILURE'
echo '\u26D4 \u001B[31mBase Image does not exist\u001B[0m'
error "Stopping pipeline!"
}
}
}
}
}
......@@ -136,8 +150,22 @@ pipeline {
} catch (Exception e) {
echo "Maybe a previous build went wrong"
}
// 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.ubuntu18.04 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/smf_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
}
if ("MERGE".equals(env.gitlabActionType)) {
try {
// Checking if the CI Base image is still there.
// If the inspect command fails, it's not there. If it passes, let remove tag.
myShCmd('docker image inspect oai-smf-base:latest > /dev/null 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker rmi oai-smf-base:latest', new_host_flag, new_host_user, new_host)
} catch (Exception e) {
echo 'No need to remove the CI base image'
}
// "latest" is the tag used in the docker file.
myShCmd('docker image tag oai-smf-base:' +SMF_BASE_IMAGE_TAG + ' oai-smf-base:latest', new_host_flag, new_host_user, new_host)
myShCmd('docker build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/smf_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
}
myShCmd('docker build --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.ubuntu18.04 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/smf_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host)
myShCmd('docker image ls >> archives/smf_docker_image_build.log', new_host_flag, new_host_user, new_host)
}
}
......@@ -287,6 +315,10 @@ pipeline {
}
cleanup {
script {
if ("MERGE".equals(env.gitlabActionType)) {
// Remove CI Base image tag
myShCmd('docker rmi oai-smf-base:latest', new_host_flag, new_host_user, new_host)
}
// Removing temporary / intermediate images
try {
if ("MERGE".equals(env.gitlabActionType)) {
......
#/*
# * 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 SMF service
# Valid for Ubuntu-18.04 (bionic)
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# BUILDER IMAGE
#---------------------------------------------------------------------
FROM oai-smf-base:latest as oai-smf-builder
WORKDIR /openair-smf/
COPY . /openair-smf
RUN cp -Rf /openair-smf-ext-ref /openair-smf/build/ext
# Building SMF
WORKDIR /openair-smf/build/scripts
RUN ./build_smf --clean --Verbose --build-type Release --jobs
#---------------------------------------------------------------------
# TARGET IMAGE
#---------------------------------------------------------------------
FROM ubuntu:bionic as oai-smf
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
# We install some debug tools for the moment in addition of mandatory libraries
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && \
DEBIAN_FRONTEND=noninteractive apt-get install --yes \
psmisc \
net-tools \
tzdata \
bc \
tshark \
libasan4 \
libgoogle-glog0v5 \
libdouble-conversion1 \
libconfig++9v5 \
libcurl4-gnutls-dev \
&& rm -rf /var/lib/apt/lists/*
# Copying executable and generated libraries
WORKDIR /openair-smf/bin
COPY --from=oai-smf-builder /openair-smf/build/smf/build/smf oai_smf
COPY --from=oai-smf-builder /openair-smf/scripts/entrypoint.sh entrypoint.sh
COPY --from=oai-smf-builder /usr/local/lib/libpistache.so /usr/local/lib/
COPY --from=oai-smf-builder /usr/local/lib/libnghttp2_asio.so.1 /usr/local/lib/
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 /usr/lib/x86_64-linux-gnu/
COPY --from=oai-smf-builder /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 /usr/lib/x86_64-linux-gnu/
COPY --from=oai-smf-builder /openair-smf/build/smf/build/nas/libNAS.so /usr/local/lib/
RUN ldconfig
# Copying template configuration files
# The configuration folder will be flat
WORKDIR /openair-smf/etc
COPY --from=oai-smf-builder /openair-smf/etc/smf.conf .
WORKDIR /openair-smf
EXPOSE 80/tcp 9090/tcp 8805/udp
ENTRYPOINT ["/bin/bash","/openair-smf/bin/entrypoint.sh"]
CMD ["/openair-smf/bin/oai_smf", "-c", "/openair-smf/etc/smf.conf", "-o"]
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