Skip to content

Commit 756602b

Browse files
authored
RHOAIENG-21690: chore(Dockerfiles): augument micropipenv with uv for faster package installs (#968)
* RHOAIENG-21690: chore(Dockerfiles): augument micropipenv with uv for faster package installs ``` × No solution found when resolving dependencies: ╰─▶ Because there is no version of certifi==2025.1.31 and you require certifi==2025.1.31, we can conclude that your requirements are unsatisfiable. hint: `certifi` was found on https://download.pytorch.org/whl/cu121, but not at the requested version (certifi==2025.1.31). A compatible version may be available on a subsequent index (e.g., https://pypi.org/simple). By default, uv will only consider versions that are published on the first index that contains a given package, to avoid dependency confusion attacks. If all indexes are equally trusted, use `--index-strategy unsafe-best-match` to consider all versions from all indexes, regardless of the order in which they were defined. ``` When installing as `USER 1001` in /opt/app-root ``` Using Python 3.11.9 environment at: /opt/app-root error: Permission denied (os error 13) at path "/opt/app-root/.tmpQEqqyQ" ``` Believe we should _not_ enable https://docs.astral.sh/uv/reference/settings/#compile-bytecode astral-sh/uv#6493 ``` UV_COMPILE_BYTECODE=1 --compile-bytecode ``` But sadly we have to, otherwise the images start too slow. Turns out, uv has bug installing tensorflow astral-sh/uv#12092 Tasks * remove `rm -f ./Pipfile.lock` from Dockerfiles * use `requirements.txt` instead of `Pipfile.lock` for package installs * fix: minor adjustments to CUDA Dockerfile formatting and comments * use `uv pip install` in TensorFlow CUDA Dockerfile for stricter and faster dependency management
1 parent 111c5dd commit 756602b

File tree

35 files changed

+237
-206
lines changed

35 files changed

+237
-206
lines changed

codeserver/ubi9-python-3.11/Dockerfile.cpu

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -134,13 +134,14 @@ ENV PYTHONPATH=/opt/app-root/bin/python3
134134

135135
USER 1001
136136

137-
# Install useful packages from Pipfile.lock
138-
COPY ${CODESERVER_SOURCE_CODE}/Pipfile.lock ./
137+
# Install useful packages from requirements.txt
138+
COPY ${CODESERVER_SOURCE_CODE}/requirements.txt ./
139139

140140
# Install packages and cleanup
141141
RUN echo "Installing softwares and packages" && \
142-
micropipenv install && \
143-
rm -f ./Pipfile.lock && \
142+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
143+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
144+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
144145
# Fix permissions to support pip in Openshift environments \
145146
chmod -R g+w /opt/app-root/lib/python3.11/site-packages && \
146147
fix-permissions /opt/app-root -P

codeserver/ubi9-python-3.12/Dockerfile.cpu

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -134,13 +134,14 @@ ENV PYTHONPATH=/opt/app-root/bin/python3
134134

135135
USER 1001
136136

137-
# Install useful packages from Pipfile.lock
138-
COPY ${CODESERVER_SOURCE_CODE}/Pipfile.lock ./
137+
# Install useful packages from requirements.txt
138+
COPY ${CODESERVER_SOURCE_CODE}/requirements.txt ./
139139

140140
# Install packages and cleanup
141141
RUN echo "Installing softwares and packages" && \
142-
micropipenv install && \
143-
rm -f ./Pipfile.lock && \
142+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
143+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
144+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
144145
# Fix permissions to support pip in Openshift environments \
145146
chmod -R g+w /opt/app-root/lib/python3.12/site-packages && \
146147
fix-permissions /opt/app-root -P

jupyter/datascience/ubi9-python-3.11/Dockerfile.cpu

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
2727
# Other apps and tools installed as default user
2828
USER 1001
2929

30-
# Install micropipenv to deploy packages from Pipfile.lock
31-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
30+
# Install micropipenv and uv to deploy packages from requirements.txt
31+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
3232

3333
# Install the oc client begin
3434
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -101,14 +101,15 @@ ENV PATH="$PATH:/opt/mssql-tools18/bin"
101101
# Other apps and tools installed as default user
102102
USER 1001
103103

104-
# Install Python packages and Jupyterlab extensions from Pipfile.lock
105-
COPY ${DATASCIENCE_SOURCE_CODE}/Pipfile.lock ./
104+
# Install Python packages and Jupyterlab extensions from requirements.txt
105+
COPY ${DATASCIENCE_SOURCE_CODE}/requirements.txt ./
106106
# Copy Elyra setup to utils so that it's sourced at startup
107107
COPY ${DATASCIENCE_SOURCE_CODE}/setup-elyra.sh ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
108108

109109
RUN echo "Installing softwares and packages" && \
110-
micropipenv install && \
111-
rm -f ./Pipfile.lock && \
110+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
111+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
112+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
112113
# setup path for runtime configuration
113114
mkdir /opt/app-root/runtimes && \
114115
mkdir /opt/app-root/pipeline-runtimes && \

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
2727
# Other apps and tools installed as default user
2828
USER 1001
2929

30-
# Install micropipenv to deploy packages from Pipfile.lock
31-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
30+
# Install micropipenv and uv to deploy packages from requirements.txt
31+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
3232

3333
# Install the oc client begin
3434
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -101,14 +101,15 @@ ENV PATH="$PATH:/opt/mssql-tools18/bin"
101101
# Other apps and tools installed as default user
102102
USER 1001
103103

104-
# Install Python packages and Jupyterlab extensions from Pipfile.lock
105-
COPY ${DATASCIENCE_SOURCE_CODE}/Pipfile.lock ./
104+
# Install Python packages and Jupyterlab extensions from requirements.txt
105+
COPY ${DATASCIENCE_SOURCE_CODE}/requirements.txt ./
106106
# Copy Elyra setup to utils so that it's sourced at startup
107107
COPY ${DATASCIENCE_SOURCE_CODE}/setup-elyra.sh ${DATASCIENCE_SOURCE_CODE}/utils ./utils/
108108

109109
RUN echo "Installing softwares and packages" && \
110-
micropipenv install && \
111-
rm -f ./Pipfile.lock && \
110+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
111+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
112+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
112113
# setup path for runtime configuration
113114
mkdir /opt/app-root/runtimes && \
114115
mkdir /opt/app-root/pipeline-runtimes && \

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -54,12 +54,13 @@ ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
5454

5555
USER 1001
5656

57-
COPY ${MINIMAL_SOURCE_CODE}/Pipfile.lock ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
57+
COPY ${MINIMAL_SOURCE_CODE}/requirements.txt ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
5858

59-
# Install Python dependencies from Pipfile.lock file
59+
# Install Python dependencies from requirements.txt file
6060
RUN echo "Installing softwares and packages" && \
61-
micropipenv install && \
62-
rm -f ./Pipfile.lock && \
61+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
62+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
63+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
6364
# Disable announcement plugin of jupyterlab \
6465
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
6566
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \

jupyter/minimal/ubi9-python-3.11/Dockerfile.cuda

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -182,12 +182,13 @@ ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
182182

183183
USER 1001
184184

185-
COPY ${MINIMAL_SOURCE_CODE}/Pipfile.lock ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
185+
COPY ${MINIMAL_SOURCE_CODE}/requirements.txt ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
186186

187-
# Install Python dependencies from Pipfile.lock file
187+
# Install Python dependencies from requirements.txt file
188188
RUN echo "Installing softwares and packages" && \
189-
micropipenv install && \
190-
rm -f ./Pipfile.lock && \
189+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
190+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
191+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
191192
# Disable announcement plugin of jupyterlab \
192193
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
193194
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \

jupyter/minimal/ubi9-python-3.11/Dockerfile.rocm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -88,12 +88,13 @@ ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
8888

8989
USER 1001
9090

91-
COPY ${MINIMAL_SOURCE_CODE}/Pipfile.lock ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
91+
COPY ${MINIMAL_SOURCE_CODE}/requirements.txt ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
9292

93-
# Install Python dependencies from Pipfile.lock file
93+
# Install Python dependencies from requirements.txt file
9494
RUN echo "Installing softwares and packages" && \
95-
micropipenv install && \
96-
rm -f ./Pipfile.lock && \
95+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
96+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
97+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
9798
# Disable announcement plugin of jupyterlab \
9899
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
99100
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -54,12 +54,13 @@ ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
5454

5555
USER 1001
5656

57-
COPY ${MINIMAL_SOURCE_CODE}/Pipfile.lock ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
57+
COPY ${MINIMAL_SOURCE_CODE}/requirements.txt ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
5858

59-
# Install Python dependencies from Pipfile.lock file
59+
# Install Python dependencies from requirements.txt file
6060
RUN echo "Installing softwares and packages" && \
61-
micropipenv install && \
62-
rm -f ./Pipfile.lock && \
61+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
62+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
63+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
6364
# Disable announcement plugin of jupyterlab \
6465
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
6566
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -156,12 +156,13 @@ ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
156156

157157
USER 1001
158158

159-
COPY ${MINIMAL_SOURCE_CODE}/Pipfile.lock ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
159+
COPY ${MINIMAL_SOURCE_CODE}/requirements.txt ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
160160

161-
# Install Python dependencies from Pipfile.lock file
161+
# Install Python dependencies from requirements.txt file
162162
RUN echo "Installing softwares and packages" && \
163-
micropipenv install && \
164-
rm -f ./Pipfile.lock && \
163+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
164+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
165+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
165166
# Disable announcement plugin of jupyterlab \
166167
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
167168
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ RUN dnf install -y mesa-libGL skopeo && dnf clean all && rm -rf /var/cache/yum
1414
# Other apps and tools installed as default user
1515
USER 1001
1616

17-
# Install micropipenv to deploy packages from Pipfile.lock
18-
RUN pip install --no-cache-dir -U "micropipenv[toml]"
17+
# Install micropipenv and uv to deploy packages from requirements.txt
18+
RUN pip install --no-cache-dir -U "micropipenv[toml]" "uv"
1919

2020
# Install the oc client begin
2121
RUN curl -L https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz \
@@ -88,12 +88,13 @@ ENV PATH="/usr/local/texlive/bin/linux:/usr/local/pandoc/bin:$PATH"
8888

8989
USER 1001
9090

91-
COPY ${MINIMAL_SOURCE_CODE}/Pipfile.lock ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
91+
COPY ${MINIMAL_SOURCE_CODE}/requirements.txt ${MINIMAL_SOURCE_CODE}/start-notebook.sh ./
9292

9393
# Install Python dependencies from Pipfile.lock file
9494
RUN echo "Installing softwares and packages" && \
95-
micropipenv install && \
96-
rm -f ./Pipfile.lock && \
95+
# This may have to download and compile some dependencies, and as we don't lock requirements from `build-system.requires`,
96+
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
97+
uv pip install --strict --no-deps --no-cache --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --requirements=./requirements.txt --build-constraints=./requirements.txt && \
9798
# Disable announcement plugin of jupyterlab \
9899
jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
99100
# Replace Notebook's launcher, "(ipykernel)" with Python's version 3.x.y \

0 commit comments

Comments
 (0)