Skip to content

Commit 355f201

Browse files
committed
RHAIENG-2111: chore(trustyai): disable dnf caching on konflux builds
1 parent 9b1be94 commit 355f201

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#########################
44
ARG BASE_IMAGE
55

6+
ARG PKG_CACHE="on"
7+
68
######################################################
79
# mongocli-builder (build stage only, not published) #
810
######################################################
@@ -34,6 +36,7 @@ ARG TRUSTYAI_SOURCE_CODE=jupyter/trustyai/ubi9-python-3.12
3436
COPY ${TRUSTYAI_SOURCE_CODE}/pylock.toml .
3537
COPY ${TRUSTYAI_SOURCE_CODE}/devel_env_setup.sh .
3638

39+
ARG PKG_CACHE
3740
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf \
3841
--mount=type=cache,target=/root/.cache/uv /bin/bash <<'EOF'
3942
set -Eeuxo pipefail
@@ -52,6 +55,8 @@ source ./devel_env_setup.sh
5255
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
5356
# RHAIENG-2111: building pandas requires cython from PyPI
5457
UV_LINK_MODE=copy uv pip install --strict --no-deps --refresh --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --extra-index-url https://pypi.org/simple --requirements=./pylock.toml
58+
59+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
5560
EOF
5661

5762
####################
@@ -80,17 +85,23 @@ EOF
8085
# Problem: The operation would result in removing the following protected packages: systemd
8186
# (try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages)
8287
# Solution: --best --skip-broken does not work either, so use --nobest
88+
ARG PKG_CACHE
8389
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
8490
set -Eeuxo pipefail
85-
dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=1
91+
dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=$DNF_KEEPCACHE
92+
93+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
8694
EOF
8795

8896
### END upgrade first to avoid fixable vulnerabilities
8997

9098
# Install useful OS packages
99+
ARG PKG_CACHE
91100
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
92101
set -Eeuxo pipefail
93102
dnf install -y --setopt=keepcache=1 perl mesa-libGL skopeo
103+
104+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
94105
EOF
95106

96107
# Other apps and tools installed as default user
@@ -152,9 +163,12 @@ WORKDIR /opt/app-root/bin
152163
USER root
153164

154165
# Install useful OS packages
166+
ARG PKG_CACHE
155167
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
156168
set -Eeuxo pipefail
157169
dnf install -y --setopt=keepcache=1 jq unixODBC unixODBC-devel postgresql git-lfs libsndfile libxcrypt-compat
170+
171+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
158172
EOF
159173

160174
# Copy dynamically-linked mongocli built in earlier build stage
@@ -192,6 +206,7 @@ USER 0
192206

193207
# Install jre that is needed to run the trustyai library
194208
# Also install runtime libraries for s390x/ppc64le
209+
ARG PKG_CACHE
195210
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
196211
set -Eeuxo pipefail
197212
INSTALL_PKGS="java-17-openjdk"
@@ -206,6 +221,8 @@ if [ "$ARCH" = "s390x" ] || [ "$ARCH" = "ppc64le" ]; then
206221
ln -sf /usr/lib64/libopenblasp.so.0 /usr/lib64/libopenblas.so.0
207222
ldconfig
208223
fi
224+
225+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
209226
EOF
210227

211228
# Install Python packages and Jupyterlab extensions from requirements.txt

jupyter/trustyai/ubi9-python-3.12/Dockerfile.konflux.cpu

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#########################
44
ARG BASE_IMAGE
55

6+
ARG PKG_CACHE="on"
7+
68
# External image alias for UBI repository configuration
79
FROM registry.access.redhat.com/ubi9/ubi AS ubi-repos
810

@@ -52,6 +54,7 @@ EOF
5254

5355
### END Subscribe with subscription manager
5456

57+
ARG PKG_CACHE
5558
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf \
5659
--mount=type=cache,target=/root/.cache/uv /bin/bash <<'EOF'
5760
set -Eeuxo pipefail
@@ -65,6 +68,8 @@ source ./devel_env_setup.sh
6568
# we often don't know the correct hashes and `--require-hashes` would therefore fail on non amd64, where building is common.
6669
# RHAIENG-2111: building pandas requires cython from PyPI
6770
UV_LINK_MODE=copy uv pip install --strict --no-deps --refresh --no-config --no-progress --verify-hashes --compile-bytecode --index-strategy=unsafe-best-match --extra-index-url https://pypi.org/simple --requirements=./pylock.toml
71+
72+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
6873
EOF
6974

7075
####################
@@ -98,17 +103,23 @@ EOF
98103
# Problem: The operation would result in removing the following protected packages: systemd
99104
# (try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages)
100105
# Solution: --best --skip-broken does not work either, so use --nobest
106+
ARG PKG_CACHE
101107
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
102108
set -Eeuxo pipefail
103-
dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=1
109+
dnf -y upgrade --refresh --nobest --skip-broken --nodocs --noplugins --setopt=install_weak_deps=0 --setopt=keepcache=$DNF_KEEPCACHE
110+
111+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
104112
EOF
105113

106114
### END upgrade first to avoid fixable vulnerabilities
107115

108116
# Install useful OS packages
117+
ARG DNF_KEEPCACHE
109118
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
110119
set -Eeuxo pipefail
111120
dnf install -y --setopt=keepcache=1 perl mesa-libGL skopeo
121+
122+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
112123
EOF
113124

114125
# Other apps and tools installed as default user
@@ -170,9 +181,12 @@ WORKDIR /opt/app-root/bin
170181
USER root
171182

172183
# Install useful OS packages
184+
ARG PKG_CACHE
173185
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
174186
set -Eeuxo pipefail
175187
dnf install -y --setopt=keepcache=1 jq unixODBC unixODBC-devel postgresql git-lfs libsndfile libxcrypt-compat
188+
189+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
176190
EOF
177191

178192
# Copy dynamically-linked mongocli built in earlier build stage
@@ -208,6 +222,7 @@ USER 0
208222

209223
# Install jre that is needed to run the trustyai library
210224
# Also install runtime libraries for s390x/ppc64le
225+
ARG DNF_KEEPCACHE
211226
RUN --mount=type=cache,target=/var/cache/dnf,sharing=locked,id=notebooks-dnf /bin/bash <<'EOF'
212227
set -Eeuxo pipefail
213228
INSTALL_PKGS="java-17-openjdk"
@@ -222,6 +237,8 @@ if [ "$ARCH" = "s390x" ] || [ "$ARCH" = "ppc64le" ]; then
222237
ln -sf /usr/lib64/libopenblasp.so.0 /usr/lib64/libopenblas.so.0
223238
ldconfig
224239
fi
240+
241+
if [ "${PKG_CACHE}" == "off" ]; then dnf clean all; fi
225242
EOF
226243

227244
# Install Python packages and Jupyterlab extensions from requirements.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Base Image : RHEL 9.6 with Python 3.12
22
# Architectures: linux/arm64, linux/ppc64le, linux/x86_64, linux/s360x
33
BASE_IMAGE=quay.io/aipcc/base-images/cpu:3.0-1761580156
4+
PKG_CACHE=off

0 commit comments

Comments
 (0)