1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

F #4089: Add Centos7 dockerfile (#4400)

This commit is contained in:
Christian González 2020-03-23 12:43:12 +01:00 committed by GitHub
parent 74dc8eb6a1
commit 629a2a38d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,7 +83,7 @@ function get_tag_name {
# This function takes care of removing all temporary directories in case
# something fails
#-------------------------------------------------------------------------------
function clean_err {
function clean {
docker rm -f $container_id > /dev/null 2>&1 || true
docker image rm -f one$sid > /dev/null 2>&1
@ -96,19 +96,6 @@ function clean_err {
rm -rf $dockerdir
}
#-------------------------------------------------------------------------------
# This function takes care of checking if the container FS will fit in the size
# passed as parameter, if not it will used the size of the container FS + 200MB
#-------------------------------------------------------------------------------
function get_size {
# Get tarbal size
tar_size=$(stat -c%s $tarball | awk '{ byte =$1 /1024/1024; print byte}' | cut -d '.' -f 1)
if [ "$tar_size" -ge "$size" ]; then
size=$(($tar_size + 200))
fi
}
set -e -o pipefail
#-------------------------------------------------------------------------------
@ -148,7 +135,8 @@ img_raw=$dockerdir/img.raw
img_qcow=$dockerdir/img.qcow
# Trap for cleaning temporary directories
trap clean_err ERR
trap clean ERR
trap clean EXIT
mkdir -p $dockerdir
mkdir -p $dockerdir/mnt
@ -184,9 +172,18 @@ RUN apt-get clean && \
EOC
)
;;
redhat)
centos|redhat)
terminal="/bin/bash"
contextpkg=$dockerdir/context.rpm
contexturl=$CONTEXT_URL/v$selected_tag/one-context-$selected_tag-1.el7.noarch.rpm
commands=$(cat <<EOC
COPY context.rpm /root/context.rpm
RUN yum update -y
RUN yum install -y epel-release \
initscripts \
e2fsprogs
RUN yum localinstall -y /root/context.rpm
RUN rm /root/context.rpm
EOC
)
;;
@ -250,15 +247,18 @@ container_id=$(docker run -d $image_id /bin/true)
docker export -o $tarball $container_id > /dev/null 2>&1
docker rm $container_id > /dev/null 2>&1
docker image rm one$sid > /dev/null 2>&1
#-------------------------------------------------------------------------------
# Dump container FS and create image
#-------------------------------------------------------------------------------
# Ensure $size have a good value
get_size
# Get tarbal size
tar_size=$(stat -c%s $tarball | awk '{ byte =$1 /1024/1024; print byte}' | cut -d '.' -f 1)
# Ensure $size is enough to fit the fs
if [ "$tar_size" -ge "$size" ]; then
echo "Not enough space, image size must be at least ${tar_size}Mb" 1>&2
exit 1
fi
qemu-img create -f raw $img_raw ${size}M > /dev/null 2>&1
@ -292,9 +292,4 @@ else
cat $img_raw
fi
#-------------------------------------------------------------------------------
# Clean up files & dirs
#-------------------------------------------------------------------------------
rm -rf $dockerdir
exit 0