libvirt: improve build process

- Drop CentOS & Debian images from the build process
- Add multi-stage single Dockerfile for Ubuntu
- Switch to a more clear tagging process, using UCA images
- Fix documentation for `libvirt` image

Change-Id: Ia60d0571dceb182c6e43ea639fc50f7d4ad6283d
This commit is contained in:
Mohammed Naser 2022-11-16 12:23:18 -05:00
parent 1c4ffb841c
commit 7ec5fa4189
10 changed files with 133 additions and 173 deletions

View File

@ -1,30 +1,26 @@
=======================
libvirt container image
=======================
===========================
``libvirt`` container image
===========================
This container builds a small image with Libvirt for use with OpenStack-Helm.
Manual build for Ubuntu Xenial
==============================
Here are the instructions for building Xenial image:
.. literalinclude:: ../../libvirt/build.sh
:lines: 7-13
:language: shell
Alternatively, this step can be performed by running the script directly:
If you need to build a ``libvirt`` image, you can use the ``Dockerfile`` with
the ``FROM`` build argument set to your source image and the ``RELEASE`` set to
the OpenStack release you're deploying. For example::
.. code-block:: shell
./libvirt/build.sh
docker buildx build \
--build-arg FROM=ubuntu:22.04 \
--build-arg RELEASE=zed \
libvirt/
openSUSE Leap 15
----------------
To build and openSUSE leap 15 image, you can export variables before running
the build script:
You can also use ``buildx`` to build the image for multiple architectures::
.. code-block:: shell
DISTRO=suse_15 ./libvirt/build.sh
docker buildx build \
--build-arg FROM=ubuntu:22.04 \
--build-arg RELEASE=zed \
--platform linux/amd64,linux/arm64 \
libvirt/

65
libvirt/Dockerfile Normal file
View File

@ -0,0 +1,65 @@
# syntax=docker/dockerfile:1.4
ARG FROM
FROM ${FROM}
FROM ${FROM} AS cloudarchive-generator
RUN <<EOF
set -xe
apt-get update
apt-get install -y lsb-release
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF
ARG RELEASE
RUN <<EOF /bin/bash
set -xe
if [ "$(lsb_release -sc)" = "focal" ]; then
if [[ "${RELEASE}" = "wallaby" || "${RELEASE}" = "xena" || "${RELEASE}" = "yoga" ]]; then
echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu $(lsb_release -sc)-updates/${RELEASE} main" > /etc/apt/sources.list.d/cloudarchive.list
else
echo "${RELEASE} is not supported on $(lsb_release -sc)"
exit 1
fi
elif [ "$(lsb_release -sc)" = "jammy" ]; then
if [[ "${RELEASE}" = "yoga" ]]; then
# NOTE(mnaser): Yoga shipped with 22.04, so no need to add an extra repository.
echo "" > /etc/apt/sources.list.d/cloudarchive.list
elif [[ "${RELEASE}" = "zed" ]]; then
echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu $(lsb_release -sc)-updates/${RELEASE} main" > /etc/apt/sources.list.d/cloudarchive.list
else
echo "${RELEASE} is not supported on $(lsb_release -sc)"
exit 1
fi
else
echo "Unable to detect correct Ubuntu Cloud Archive repository for $(lsb_release -sc)"
exit 1
fi
EOF
FROM ${FROM} AS runtime
COPY --from=cloudarchive-generator --link /etc/apt/sources.list.d/cloudarchive.list /etc/apt/sources.list.d/cloudarchive.list
COPY ubuntu-keyring-2012-cloud-archive.gpg /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cloud-archive.gpg
RUN <<EOF
set -xe
apt-get update
apt-get install -y --no-install-recommends \
ceph-common \
cgroup-tools \
dmidecode \
ebtables \
iproute2 \
ipxe-qemu \
kmod \
libvirt-clients \
libvirt-daemon-system \
openssh-client \
openvswitch-switch \
ovmf \
pm-utils \
qemu-block-extra \
qemu-efi \
qemu-kvm
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

View File

@ -1,19 +0,0 @@
ARG FROM=docker.io/centos:7
FROM ${FROM}
LABEL maintainer="mnaser@vexxhost.com"
ARG CEPH_RELEASE=nautilus
ARG PROJECT=nova
ARG UID=42424
ARG GID=42424
RUN set -ex ;\
yum -y install centos-release-qemu-ev centos-release-ceph-${CEPH_RELEASE} ;\
yum -y install libcgroup-tools libvirt qemu-kvm-ev ;\
groupadd -g ${GID} ${PROJECT} ;\
useradd -u ${UID} -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT} ;\
mkdir -p /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT} ;\
chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT} ;\
usermod -a -G kvm ${PROJECT} ;\
yum clean all ;\
rm -rf /var/cache/yum

View File

@ -1,24 +0,0 @@
ARG FROM=docker.io/debian:bullseye
FROM ${FROM}
ARG UBUNTU_RELEASE=bullseye
ARG CEPH_RELEASE=quincy
ARG CEPH_RELEASE_TAG=""
ARG PROJECT=nova
ARG UID=42424
ARG GID=42424
ARG CEPH_REPO=http://download.ceph.com/debian-${CEPH_RELEASE}/
ARG CEPH_KEY=http://download.ceph.com/keys/release.asc
ADD ${CEPH_KEY} /etc/apt/ceph-${CEPH_RELEASE}.key
COPY ./ubuntu-install-libvirt.sh /tmp/ubuntu-install-libvirt.sh
RUN set -ex ;\
export DEBIAN_FRONTEND=noninteractive ;\
apt-get update ;\
apt-get install --no-install-recommends -y \
apt-transport-https \
ca-certificates \
gnupg ;\
/tmp/ubuntu-install-libvirt.sh ;\
rm -rf /tmp/*

View File

@ -1,26 +0,0 @@
ARG FROM=docker.io/ubuntu:bionic
FROM ${FROM}
LABEL maintainer="pete.birley@att.com"
ARG UBUNTU_RELEASE=bionic
ARG CEPH_RELEASE=pacific
ARG CEPH_RELEASE_TAG=""
ARG PROJECT=nova
ARG UID=42424
ARG GID=42424
ARG CEPH_REPO=http://download.ceph.com/debian-${CEPH_RELEASE}/
ARG CEPH_KEY=http://download.ceph.com/keys/release.asc
ADD ${CEPH_KEY} /etc/apt/ceph-${CEPH_RELEASE}.key
COPY ./ubuntu-install-libvirt.sh /tmp/ubuntu-install-libvirt.sh
RUN set -ex ;\
export DEBIAN_FRONTEND=noninteractive ;\
apt-get update ;\
apt-get upgrade -y ;\
apt-get install --no-install-recommends -y \
apt-transport-https \
ca-certificates \
gnupg ;\
/tmp/ubuntu-install-libvirt.sh ;\
rm -rf /tmp/*

View File

@ -1,25 +0,0 @@
ARG FROM=docker.io/ubuntu:focal
FROM ${FROM}
LABEL maintainer="mnaser@vexxhost.com"
ARG UBUNTU_RELEASE=focal
ARG CEPH_RELEASE=pacific
ARG CEPH_RELEASE_TAG=""
ARG PROJECT=nova
ARG UID=42424
ARG GID=42424
ARG CEPH_REPO=http://download.ceph.com/debian-${CEPH_RELEASE}/
ARG CEPH_KEY=http://download.ceph.com/keys/release.asc
ADD ${CEPH_KEY} /etc/apt/ceph-${CEPH_RELEASE}.key
COPY ./ubuntu-install-libvirt.sh /tmp/ubuntu-install-libvirt.sh
RUN set -ex ;\
export DEBIAN_FRONTEND=noninteractive ;\
apt-get update ;\
apt-get install --no-install-recommends -y \
apt-transport-https \
ca-certificates \
gnupg ;\
/tmp/ubuntu-install-libvirt.sh ;\
rm -rf /tmp/*

View File

@ -5,11 +5,10 @@ SCRIPT_DIR=`dirname ${SCRIPT}`
cd ${SCRIPT_DIR}/..
IMAGE="libvirt"
LIBVIRT_VERSION=${LIBVIRT_VERSION:-"1.3.1-1ubuntu10.24"}
VERSION=${VERSION:-latest}
DISTRO=${DISTRO:-ubuntu_focal}
DISTRO=${DISTRO:-ubuntu_jammy}
REGISTRY_URI=${REGISTRY_URI:-"openstackhelm/"}
EXTRA_TAG_INFO=${EXTRA_TAG_INFO:-"-${LIBVIRT_VERSION}"}
docker build -f ${IMAGE}/Dockerfile.${DISTRO} --network=host -t ${REGISTRY_URI}${IMAGE}:${VERSION}-${DISTRO}${EXTRA_TAG_INFO} --build-arg LIBVIRT_VERSION="${LIBVIRT_VERSION}" ${extra_build_args} ${IMAGE}
docker build -f ${IMAGE}/Dockerfile --build-arg FROM=${DISTRO/_/:} --build-arg zed --network=host -t ${REGISTRY_URI}${IMAGE}:${VERSION}-${DISTRO}${EXTRA_TAG_INFO} ${extra_build_args} ${IMAGE}
cd -

View File

@ -1,38 +0,0 @@
#!/bin/bash
set -ex
export DEBIAN_FRONTEND=noninteractive ;\
apt-key add /etc/apt/ceph-${CEPH_RELEASE}.key ;\
rm -f /etc/apt/ceph-${CEPH_RELEASE}.key ;\
echo "deb ${CEPH_REPO} ${UBUNTU_RELEASE} main" | tee /etc/apt/sources.list.d/ceph.list ;\
if [ -z "${CEPH_RELEASE_TAG}" ]; then ceph="ceph-common"; else ceph="ceph-common=${CEPH_RELEASE_TAG}"; fi ;\
apt-get update ;\
apt-get upgrade -y ;\
apt-get install --no-install-recommends -y \
${ceph} \
cgroup-tools \
dmidecode \
ebtables \
iproute2 \
ipxe-qemu \
libvirt-clients \
libvirt-daemon-system \
openssh-client \
pm-utils \
qemu-kvm \
qemu-block-extra \
qemu-efi \
openvswitch-switch \
ovmf \
kmod ;\
groupadd -g ${GID} ${PROJECT} ;\
useradd -u ${UID} -g ${PROJECT} -M -d /var/lib/${PROJECT} -s /usr/sbin/nologin -c "${PROJECT} user" ${PROJECT} ;\
mkdir -p /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT} ;\
chown ${PROJECT}:${PROJECT} /etc/${PROJECT} /var/log/${PROJECT} /var/lib/${PROJECT} /var/cache/${PROJECT} ;\
usermod -a -G kvm ${PROJECT} ;\
apt-get clean -y ;\
rm -rf \
/var/cache/debconf/* \
/var/lib/apt/lists/* \
/var/log/* \
/tmp/* \
/var/tmp/*

Binary file not shown.

View File

@ -40,32 +40,64 @@
docker_images:
- context: libvirt
repository: openstackhelm/libvirt
dockerfile: Dockerfile.centos_7
dockerfile: Dockerfile
arch:
- linux/amd64
tags:
- latest-centos_7
- "centos_7-{{ currentdate }}"
- context: libvirt
repository: openstackhelm/libvirt
dockerfile: Dockerfile.ubuntu_bionic
tags:
- latest-ubuntu_bionic
- "ubuntu_bionic-{{ currentdate }}"
- "wallaby-focal-{{ currentdate }}"
- "wallaby-focal"
- "wallaby"
build_args:
- "CEPH_REPO=https://mirror.mirantis.com/testing/ceph-nautilus/bionic/"
- "CEPH_KEY=https://mirror.mirantis.com/testing/ceph-nautilus/bionic/archive-ceph-nautilus.key"
- "CEPH_RELEASE_TAG=14.2.9-1.0~bionic"
- FROM=ubuntu:focal
- RELEASE=wallaby
- context: libvirt
repository: openstackhelm/libvirt
dockerfile: Dockerfile.ubuntu_focal
dockerfile: Dockerfile
arch:
- linux/amd64
tags:
- latest-ubuntu_focal
- "ubuntu_focal-{{ currentdate }}"
- "xena-focal-{{ currentdate }}"
- "xena-focal"
- "xena"
build_args:
- FROM=ubuntu:focal
- RELEASE=xena
- context: libvirt
repository: openstackhelm/libvirt
dockerfile: Dockerfile.debian_bullseye
dockerfile: Dockerfile
arch:
- linux/amd64
tags:
- latest-debian_bullseye
- "debian_bullseye-{{ currentdate }}"
- "yoga-focal-{{ currentdate }}"
- "yoga-focal"
- "yoga"
build_args:
- FROM=ubuntu:focal
- RELEASE=yoga
- context: libvirt
repository: openstackhelm/libvirt
dockerfile: Dockerfile
arch:
- linux/amd64
tags:
- "yoga-jammy-{{ currentdate }}"
- "yoga-jammy"
build_args:
- FROM=ubuntu:jammy
- RELEASE=yoga
- context: libvirt
repository: openstackhelm/libvirt
dockerfile: Dockerfile
arch:
- linux/amd64
tags:
- "zed-jammy-{{ currentdate }}"
- "zed-jammy"
- "zed"
- "latest"
build_args:
- FROM=ubuntu:jammy
- RELEASE=zed
files: &libvirt_files
- libvirt/.*
- zuul.d/libvirt.yaml