Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to build image using source code directly #304

Merged
merged 1 commit into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ FROM $BASE_IMAGE
ENV PKGS_LIST=main-packages-list.txt
ARG EXTRA_PKGS_LIST
ARG PATCH_LIST
ARG INSTALL_TYPE=rpm

COPY ${PKGS_LIST} ${EXTRA_PKGS_LIST:-$PKGS_LIST} ${PATCH_LIST:-$PKGS_LIST} /tmp/
COPY ironic-${INSTALL_TYPE}-list.txt ${PKGS_LIST} ${EXTRA_PKGS_LIST:-$PKGS_LIST} ${PATCH_LIST:-$PKGS_LIST} /tmp/
COPY prepare-image.sh patch-image.sh /bin/

RUN prepare-image.sh && \
rm -f /bin/prepare-image.sh


COPY scripts/ /bin/

# IRONIC #
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ The ironic configuration can be overridden by various environment variables. The
- OS_CONDUCTOR__CLEAN_CALLBACK_TIMEOUT=1800 - timeout (seconds) to wait for a callback from the ramdisk doing the cleaning
- OS_PXE__BOOT_RETRY_TIMEOUT=1200 - timeout (seconds) to enable boot retries.

Build Ironic Image from source
------------------------------

Normally the ironic image is built using RPMs coming from the RDO project.
It is possible to build it using source code setting the **INSTALL_TYPE**
argument to **source** at build time; the full command is for example:

podman build -t ironic-image -f Dockerfile --build-arg INSTALL_TYPE=source

Apply project patches to the images during build
------------------------------------------------

Expand Down
11 changes: 11 additions & 0 deletions ironic-rpm-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
crudini
openstack-ironic-api
openstack-ironic-conductor
openstack-ironic-inspector
python3-dracclient
python3-ibmcclient
python3-ironic-prometheus-exporter
python3-proliantutils
python3-scciclient
python3-sushy
python3-sushy-oem-idrac
11 changes: 11 additions & 0 deletions ironic-source-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
crudini
elfosardo marked this conversation as resolved.
Show resolved Hide resolved
ironic @ git+https://opendev.org/openstack/ironic
ironic-inspector @ git+https://opendev.org/openstack/ironic-inspector
ironic-prometheus-exporter
proliantutils
PyMySQL>=0.8.0
python-dracclient
python-ibmcclient
python-scciclient
sushy
sushy-oem-idrac
14 changes: 2 additions & 12 deletions main-packages-list.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
crudini
dnsmasq
genisoimage
httpd
Expand All @@ -8,20 +7,11 @@ ipmitool
iproute
mariadb-server
mod_ssl
openstack-ironic-api
openstack-ironic-conductor
openstack-ironic-inspector
parted
procps
python3-dracclient
python3-gunicorn
python3-ibmcclient
python3-ironic-prometheus-exporter
psmisc
python3-jinja2
python3-mod_wsgi
python3-proliantutils
python3-scciclient
python3-sushy
python3-sushy-oem-idrac
qemu-img
sqlite
syslinux-nonlinux
34 changes: 30 additions & 4 deletions prepare-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,54 @@

set -euxo pipefail

IRONIC_PKG_LIST=/tmp/ironic-${INSTALL_TYPE}-list.txt

echo "install_weak_deps=False" >> /etc/dnf/dnf.conf
# Tell RPM to skip installing documentation
echo "tsflags=nodocs" >> /etc/dnf/dnf.conf

dnf install -y python3 python3-requests epel-release 'dnf-command(config-manager)'
dnf config-manager --set-disabled epel
curl https://raw.githubusercontent.com/openstack/tripleo-repos/master/plugins/module_utils/tripleo_repos/main.py | python3 - -b master current-tripleo
dnf upgrade -y

# RPM install #
if [[ $INSTALL_TYPE == "rpm" ]]; then
curl https://raw.githubusercontent.com/openstack/tripleo-repos/master/plugins/module_utils/tripleo_repos/main.py | python3 - -b master current-tripleo
dnf upgrade -y
xargs -rtd'\n' dnf install -y < $IRONIC_PKG_LIST
fi

# SOURCE install #
if [[ $INSTALL_TYPE == "source" ]]; then
dnf upgrade -y
dnf install -y python3-pip python3-devel gcc git-core
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed from the final image

pip3 install --upgrade pip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather avoid an unconditional upgrade of pip, we've had enough issues with it upstream

pip3 install --prefix /usr -r $IRONIC_PKG_LIST -c https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so you use the upstream constraints. This is fine, but do you realize that the services and vendor dependencies are not there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this being a PoC does not include everything
in the final version we'll have to add the rest of the dependencies that are not strictly needed in CI but instead for the real final image


# ironic and ironic-inspector system configuration
mkdir -p /var/log/ironic /var/log/ironic-inspector /var/lib/ironic /var/lib/ironic-inspector
getent group ironic >/dev/null || groupadd -r ironic
getent passwd ironic >/dev/null || useradd -r -g ironic -s /sbin/nologin ironic -d /var/lib/ironic
getent group ironic-inspector >/dev/null || groupadd -r ironic-inspector
getent passwd ironic-inspector >/dev/null || useradd -r -g ironic-inspector -s /sbin/nologin ironic-inspector -d /var/lib/ironic-inspector
fi

xargs -rtd'\n' dnf install -y < /tmp/${PKGS_LIST}

if [[ ! -z ${EXTRA_PKGS_LIST:-} ]]; then
if [[ -s /tmp/${EXTRA_PKGS_LIST} ]]; then
xargs -rtd'\n' dnf install -y < /tmp/${EXTRA_PKGS_LIST}
fi
fi
dnf install -y --enablerepo=epel inotify-tools

dnf install -y --enablerepo=epel inotify-tools python3-gunicorn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gunicorn can be installed from pypi just as well


dnf clean all
rm -rf /var/cache/{yum,dnf}/*

# apply patches if present #
if [[ ! -z ${PATCH_LIST:-} ]]; then
if [[ -s "/tmp/${PATCH_LIST}" ]]; then
/bin/patch-image.sh;
fi
fi
rm -f /bin/patch-image.sh

5 changes: 4 additions & 1 deletion scripts/configure-ironic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ if [ ! -z "${IRONIC_EXTERNAL_IP}" ]; then
export IRONIC_INSPECTOR_CALLBACK_ENDPOINT_OVERRIDE="https://${IRONIC_EXTERNAL_IP}:5050"
fi

cp /etc/ironic/ironic.conf /etc/ironic/ironic.conf_orig
if [ -f /etc/ironic/ironic.conf ]; then
# Make a copy of the original supposed empty configuration file
cp /etc/ironic/ironic.conf /etc/ironic/ironic.conf_orig
fi

# oslo.config also supports Config Opts From Environment, log them
echo '# Options set from Environment variables' | tee /etc/ironic/ironic.extra
Expand Down