Skip to content
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
37 changes: 34 additions & 3 deletions containers/base/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,33 @@
# License for the specific language governing permissions and limitations
# under the License.

FROM registry.access.redhat.com/ubi10/ubi-minimal:latest
ARG UBI_BASE_IMAGE=registry.access.redhat.com/ubi10/ubi-minimal:latest

# --- Build stage: compile wheels from source ---
FROM ${UBI_BASE_IMAGE} AS build

ARG CONSTRAINTS_FILE=requirements.lock
COPY ${CONSTRAINTS_FILE} /deps-upper-constraints.txt

# We can force build from source of all packages optionally
ARG PIP_NO_BINARY=""
ENV PIP_NO_BINARY=${PIP_NO_BINARY}

COPY builddeps.txt /tmp/builddeps.txt
RUN pkgs=$(cat /tmp/builddeps.txt | grep -v '^#' | grep -v '^$' | tr '\n' ' ') && \
if [ -n "${pkgs}" ]; then microdnf -y install ${pkgs}; microdnf clean all; fi

COPY pythonbuilddeps.txt /tmp/pythonbuilddeps.txt
RUN pkgs=$(cat /tmp/pythonbuilddeps.txt | grep -v '^#' | grep -v '^$' | tr '\n' ' ') && \
if [ -n "${pkgs}" ]; then pip3 install --no-cache-dir -c /deps-upper-constraints.txt ${pkgs}; fi

# Second, build the wheels for the dependencies and place them in a different directory
RUN pip3 wheel --no-cache-dir --no-deps \
--find-links=/wheels/pkgs \
--wheel-dir=/wheels/deps -r /deps-upper-constraints.txt

# --- Runtime stage ---
FROM ${UBI_BASE_IMAGE}

LABEL maintainer="OpenStack Kubernetes Operator team"

Expand All @@ -28,6 +54,7 @@ ENV REQUESTS_CA_BUNDLE=/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
USER root

COPY ${CONSTRAINTS_FILE} /deps-upper-constraints.txt
# SKIP IN DOWNSTREAM
COPY rpms.repo /etc/yum.repos.d/rpms.repo

COPY bindeps.txt /tmp/bindeps.txt
Expand All @@ -38,18 +65,21 @@ RUN if [ -f "/etc/yum.repos.d/ubi.repo" ]; then rm -f /etc/yum.repos.d/ubi.repo
# As this was introduced RHEL only https://redhat.atlassian.net/browse/RHEL-30258 and later bundled differently
# for CentOS https://redhat.atlassian.net/browse/RHEL-105298
# remove this until fixed in CentOS-10-stream
# SKIP IN DOWNSTREAM
RUN rpm -e openssl-fips-provider-so --nodeps || true

RUN pkgs=$(cat /tmp/bindeps.txt | grep -v '^#' | grep -v '^$' | tr '\n' ' ') && \
if [ -n "${pkgs}" ]; then microdnf -y install ${pkgs} && microdnf clean all && rm -rf /var/cache/dnf; fi && \
rm /tmp/bindeps.txt

COPY --from=build /wheels /wheels
COPY pythondeps.txt /tmp/pythondeps.txt
RUN extrapkgs=$(cat /tmp/pythondeps.txt | grep -v '^#' | grep -v '^$' | tr '\n' ' ') && \
pip3 install --no-cache-dir --prefix=/usr \
-c /deps-upper-constraints.txt \
--find-links=/wheels/deps \
${extrapkgs} && \
rm -rf /tmp/pythondeps.txt
rm -rf /wheels /tmp/pythondeps.txt

# DNF configuration
RUN crudini --set /etc/dnf/dnf.conf main clean_requirements_on_remove True && \
Expand Down Expand Up @@ -83,7 +113,8 @@ RUN touch /usr/local/bin/kolla_extend_start && \
chmod 755 /usr/local/bin/kolla_extend_start

# Fix nsswitch.conf
RUN sed -ri '/^(passwd:|group:)/ s/systemd//g' /etc/nsswitch.conf
RUN if [ -f "/etc/nsswitch.conf" ]; then sed -ri '/^(passwd:|group:)/ s/systemd//g' /etc/nsswitch.conf; fi
RUN if [ ! -f "/etc/localtime" ]; then ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime; fi

# Create /openstack directory (convention from tcib)
RUN mkdir -p /openstack
Expand Down
3 changes: 2 additions & 1 deletion containers/base/bindeps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ curl
glibc-langpack-en
procps-ng
python3
python3-pip
sudo
tzdata
util-linux-user
which
python3-pip
5 changes: 5 additions & 0 deletions containers/base/builddeps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Build dependencies for compiling dumb-init C extension
gcc
python3-devel
python3-pip
python3-wheel
4 changes: 2 additions & 2 deletions containers/base/buildrequirements.lock.master
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flit-core==4.0.2
packaging==26.3
setuptools-scm==10.2.1
vcs-versioning==2.3.1
setuptools-scm==10.2.2
vcs-versioning==2.3.2
wheel==0.48.0

# The following packages are considered to be unsafe in a requirements file:
Expand Down
1 change: 1 addition & 0 deletions containers/base/pythonbuilddeps.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pbr
2 changes: 1 addition & 1 deletion containers/base/pythondeps.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
crudini
pbr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Most services require pbr for runtime.
It's mostly due to the use of pbr.version.

I think that most of the service images install pbr HOWEVER, I am not sure of this, and removing pbr from pythondeps could break a few services

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if it is actually used as a runtime. it can get added back in. If it is actually a requirement it will get installed no matter what. but I'll add it back in

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, update put it back in

dumb-init
pbr
4 changes: 4 additions & 0 deletions containers/base/rpms.in.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ arches:
packages:
- ca-certificates
- curl
- gcc
- glibc-langpack-en
- procps-ng
- python3
- python3-devel
- python3-pip
- python3-wheel
- sudo
- tzdata
- util-linux-user
- which