Skip to content

Ironic Prometheus Exporter

The ironic-prometheus-exporter image is built from ContainerFiles/ironic-prometheus-exporter. Security patches are applied by scripts/ironic-cve-patching.sh.

This container packages the Ironic Prometheus Exporter service for use in the stack. The build installs the required packages, applies security updates and configuration, and prepares the service for integration.

graph LR
    A[Base image] --> B[Install packages]
    B --> C[Apply CVE patches]
    C --> D[Configure Ironic Prometheus Exporter]
    D --> E[Container ready]
ContainerFile used for the build
# syntax = docker/dockerfile:1
# This Dockerfile uses multi-stage build to customize DEV and PROD images:
# https://docs.docker.com/develop/develop-images/multistage-build/

ARG VENV_TAG=3.12-latest
FROM ghcr.io/rackerlabs/genestack-images/openstack-venv:${VENV_TAG} AS dependency_build
ARG CACHEBUST=0
ARG OS_VERSION=master
ARG OS_CONSTRAINTS=master
RUN export DEBIAN_FRONTEND=noninteractive \
  && apt-get update && apt-get upgrade -y \
  && apt-get install --no-install-recommends -y \
                                             bash \
                                             build-essential \
                                             curl \
                                             gettext \
                                             git \
                                             libssl-dev \
                                             libsystemd-dev \
                                             pkg-config \
                                             ssl-cert \
                                             xmlsec1

RUN /var/lib/openstack/bin/pip install --constraint https://opendev.org/openstack/requirements/raw/branch/${OS_CONSTRAINTS}/upper-constraints.txt \
                                       git+https://opendev.org/openstack/ironic-prometheus-exporter.git@${OS_VERSION}#egg=ironic-prometheus-exporter \
                                       gunicorn

COPY scripts/ironic-cve-patching.sh /opt/
RUN bash /opt/ironic-cve-patching.sh

RUN find / -name '*.pyc' -delete \
    && find / -name '*.pyo' -delete \
    && find / -name '__pycache__' -delete \
    && find / -name '*.whl' -delete \
    && rm -f /var/lib/openstack/lib/python*/site-packages/slapdtest/certs/client.key \
    && rm -f /var/lib/openstack/lib/python*/site-packages/slapdtest/certs/server.key \
    && sed -i '/^Usage/,/^Documentation\n^-.*$/d' /var/lib/openstack/lib/python*/site-packages/PyJWT-*.dist-info/METADATA || true

FROM python:3.12-slim-bookworm

LABEL maintainer="Rackspace"
LABEL vendor="Rackspace OpenStack Team"
LABEL org.opencontainers.image.name="ironic-prometheus-exporter"
LABEL org.opencontainers.image.description="Ironic Prometheus Exporter"

COPY --from=dependency_build /var/lib/openstack /var/lib/openstack

RUN export DEBIAN_FRONTEND=noninteractive \
    && apt-get update && apt-get upgrade -y \
    && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/* \
    && find / -name '*.pyc' -delete \
    && find / -name '*.pyo' -delete \
    && find / -name '__pycache__' -delete \
    && groupadd --system --gid 42424 ironic \
    && useradd --system --gid 42424 --uid 42424 --shell /sbin/nologin --create-home --home /var/lib/ironic ironic \
    && mkdir -p /var/lib/openstack/etc/ironic \
    && ln -s /var/lib/openstack/etc/ironic /etc/ironic \
    && chown ironic:ironic -h /etc/ironic \
    && chown -R ironic:ironic /var/lib/openstack/etc/ironic

# Set the environment variables for the ironic-prometheus-exporter
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PATH="/var/lib/openstack/bin:$PATH"

# Set the working directory
WORKDIR /var/lib/openstack

# Set the user and group to match the original build
USER 42424:42424

# Expose metrics endpoint, default to 9608
EXPOSE 9608

Build Arguments

Argument Default
VENV_TAG 3.12-latest
CACHEBUST 0
OS_VERSION master
OS_CONSTRAINTS master
Build Command
docker build \
--build-arg VENV_TAG=3.12-latest \
--build-arg CACHEBUST=0 \
--build-arg OS_VERSION=master \
--build-arg OS_CONSTRAINTS=master \
-f ContainerFiles/ironic-prometheus-exporter \
-t ironic-prometheus-exporter:local \
.

Dependencies

Container Image

The container image is available on Github Container Registry.