1- FROM registry.access.redhat.com/ubi9/python-312:latest AS builder
1+ # Use this base image so everything comes from RPM packages (including OSC plugins)
2+ ARG BUILDER_IMAGE=quay.rdoproject.org/podified-master-centos10/openstack-openstackclient:current-tested
3+ ARG BASE_IMAGE=quay.rdoproject.org/podified-master-centos10/openstack-openstackclient:current-tested
4+
5+ FROM $BUILDER_IMAGE AS builder
26
37WORKDIR /app
48
@@ -7,7 +11,23 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
711
812# Copy dependency manifests and README first (build backend needs README.md).
913# Dependency layer is reused when only application code changes.
10- COPY pyproject.toml uv.lock README.md ./
14+ COPY --chown=cloud-admin:cloud-admin pyproject.toml uv.lock README.md ./
15+
16+ # Using `--no-install-package` in `uv sync` for these 3 packages only prevents
17+ # the top level package from installing, not their dependencies, installing
18+ # incompatible versions of the dependencies.
19+ RUN echo -e '\n [tool.uv]\n exclude-dependencies = [\n "openstackclient",\n "python-openstackclient",\n "stevedore"\n ]' >> pyproject.toml
20+
21+ # This should be safe because uv’s resolver is highly conservative and should
22+ # keep every existing package pinned to its current locked version.
23+ # Checked this with `uv lock --dry-run`
24+ RUN uv lock
25+
26+ # Create the virtual environment enabling system's site-packages (RPM packages
27+ # from base container) since `uv sync` doesn't support it.
28+ RUN uv venv --system-site-packages /app/.venv
29+
30+ # Install dependencies but without the packages that come from the base image
1131RUN uv sync --frozen --no-dev --no-editable --no-install-project
1232
1333# Copy application code and install the package into the venv.
@@ -20,7 +40,7 @@ RUN curl -o oc.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/
2040 rm oc.tar.gz
2141
2242# Final stage: smaller image without uv or build tools.
23- FROM registry.access.redhat.com/ubi9/python-312:latest
43+ FROM $BASE_IMAGE
2444
2545LABEL com.redhat.component="rhos-ls-mcps" \
2646 name="openstack-lightspeed/rhos-mcps" \
0 commit comments