Skip to content

Commit

Permalink
Add option to build image using source code directly
Browse files Browse the repository at this point in the history
  • Loading branch information
elfosardo committed Nov 9, 2021
1 parent 9cdd0b7 commit 39c5b7d
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 19 deletions.
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
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
pip3 install --upgrade pip
pip3 install --prefix /usr -r $IRONIC_PKG_LIST -c https://raw.githubusercontent.com/openstack/requirements/master/upper-constraints.txt

# 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

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

0 comments on commit 39c5b7d

Please sign in to comment.