Skip to content

Commit e778908

Browse files
committed
RHAIENG-2189: configure PIP_INDEX_URL
1 parent f90c565 commit e778908

File tree

6 files changed

+54
-5
lines changed

6 files changed

+54
-5
lines changed

codeserver/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ FROM ${BASE_IMAGE} AS cpu-base
7272

7373
WORKDIR /opt/app-root/bin
7474

75-
# RHAIENG-2189: this is AIPCC migration phase 1.5
75+
### BEGIN RHAIENG-2189: this is AIPCC migration phase 1.5
7676
ENV PIP_EXTRA_INDEX_URL=https://pypi.org/simple
7777
ENV UV_EXTRA_INDEX_URL=https://pypi.org/simple
78+
### END RHAIENG-2189: this is AIPCC migration phase 1.5
7879

7980
# OS Packages needs to be installed as root
8081
USER 0

jupyter/minimal/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ FROM registry.access.redhat.com/ubi9/ubi AS ubi-repos
1111
####################
1212
FROM ${BASE_IMAGE} AS cpu-base
1313

14-
# RHAIENG-2189: this is AIPCC migration phase 1.5
14+
### BEGIN RHAIENG-2189: this is AIPCC migration phase 1.5
1515
ENV PIP_EXTRA_INDEX_URL=https://pypi.org/simple
1616
ENV UV_EXTRA_INDEX_URL=https://pypi.org/simple
17+
### END RHAIENG-2189: this is AIPCC migration phase 1.5
1718

1819
WORKDIR /opt/app-root/bin
1920

runtimes/datascience/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ FROM ${BASE_IMAGE} AS cpu-base
1010

1111
ARG TARGETARCH
1212

13-
# RHAIENG-2189: this is AIPCC migration phase 1.5
13+
### BEGIN RHAIENG-2189: this is AIPCC migration phase 1.5
1414
ENV PIP_EXTRA_INDEX_URL=https://pypi.org/simple
1515
ENV UV_EXTRA_INDEX_URL=https://pypi.org/simple
16+
### END RHAIENG-2189: this is AIPCC migration phase 1.5
1617

1718
WORKDIR /opt/app-root/bin
1819

runtimes/minimal/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ ARG BASE_IMAGE
88
####################
99
FROM ${BASE_IMAGE} AS cpu-base
1010

11-
# RHAIENG-2189: this is AIPCC migration phase 1.5
11+
### BEGIN RHAIENG-2189: this is AIPCC migration phase 1.5
1212
ENV PIP_EXTRA_INDEX_URL=https://pypi.org/simple
1313
ENV UV_EXTRA_INDEX_URL=https://pypi.org/simple
14+
### END RHAIENG-2189: this is AIPCC migration phase 1.5
1415

1516
WORKDIR /opt/app-root/bin
1617

scripts/dockerfile_fragments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def main():
6161
""")
6262

6363
replacements = {
64+
"RHAIENG-2189: this is AIPCC migration phase 1.5": textwrap.dedent(r"""
65+
ENV PIP_EXTRA_INDEX_URL=https://pypi.org/simple
66+
ENV UV_EXTRA_INDEX_URL=https://pypi.org/simple"""),
67+
6468
"Subscribe with subscription manager": textwrap.dedent(subscription_manager_register_refresh),
6569
"upgrade first to avoid fixable vulnerabilities": textwrap.dedent(ntb.process_template_with_indents(rt"""
6670
{subscription_manager_register_refresh}

tests/containers/base_image_test.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import binascii
4+
import contextlib
45
import inspect
56
import json
67
import logging
@@ -11,6 +12,7 @@
1112
import textwrap
1213
from typing import TYPE_CHECKING, Any
1314

15+
import allure
1416
import pytest
1517
import testcontainers.core.container
1618

@@ -20,7 +22,7 @@
2022
LOGGER = logging.getLogger(__name__)
2123

2224
if TYPE_CHECKING:
23-
from collections.abc import Callable
25+
from collections.abc import Callable, Generator
2426

2527
import pytest_subtests
2628

@@ -43,6 +45,23 @@ def _run_test(self, image: str, test_fn: Callable[[testcontainers.core.container
4345
# If the return doesn't happen in the try block, fail the test
4446
pytest.fail("The test did not pass as expected.")
4547

48+
@contextlib.contextmanager
49+
def _test_container(self, image: str) -> Generator[testcontainers.core.container.DockerContainer]:
50+
"""Context manager that starts a test container and yields it."""
51+
container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0])
52+
container.with_command("/bin/sh -c 'sleep infinity'")
53+
try:
54+
container.start()
55+
yield container
56+
return
57+
except Exception as e:
58+
pytest.fail(f"Unexpected exception in test: {e}")
59+
finally:
60+
docker_utils.NotebookContainer(container).stop(timeout=0)
61+
62+
# If the return doesn't happen in the try block, fail the test
63+
pytest.fail("The test did not pass as expected.")
64+
4665
def test_elf_files_can_link_runtime_libs(self, subtests: pytest_subtests.SubTests, image):
4766
def test_fn(container: testcontainers.core.container.DockerContainer):
4867
def check_elf_file():
@@ -250,6 +269,28 @@ def test_fn(container: testcontainers.core.container.DockerContainer):
250269

251270
self._run_test(image=image, test_fn=test_fn)
252271

272+
@allure.issue("RHAIENG-2189")
273+
def test_python_package_index(self, image: str, subtests: pytest_subtests.SubTests):
274+
"""Checks that we use the Python Package Index we mean to use.
275+
https://redhat-internal.slack.com/archives/C05TTTYG599/p1764240587118899?thread_ts=1764234802.564119&cid=C05TTTYG599
276+
"""
277+
278+
expected_env = {
279+
"PIP_EXTRA_INDEX_URL": "https://pypi.org/simple",
280+
"UV_EXTRA_INDEX_URL": "https://pypi.org/simple",
281+
}
282+
283+
with self._test_container(image=image) as container:
284+
_, output = container.exec(["env"])
285+
output = output.decode().strip()
286+
287+
actual = {}
288+
for line in output.splitlines():
289+
key, value = line.split("=", maxsplit=1)
290+
actual[key] = value
291+
292+
assert actual.items() >= expected_env.items()
293+
253294

254295
def encode_python_function_execution_command_interpreter(
255296
python: str, function: Callable[..., Any], *args: list[Any]

0 commit comments

Comments
 (0)