Skip to content

Commit 5d5dec1

Browse files
committed
fix: update Dockerfile to conditionally set pip index URL and trusted host for nexus authentication
1 parent 89ef144 commit 5d5dec1

2 files changed

Lines changed: 38 additions & 28 deletions

File tree

common/jenkins-agents/terraform-2306/docker/Dockerfile.ubi9

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,8 @@ ENV TERRAFORM_VERSION=1.4.6 \
3333
RBENV_ROOT=/opt/rbenv \
3434
RBENV_SHELL=bash \
3535
NPM_CONFIG_CAFILE=/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem \
36-
UV_INDEX_URL=https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple \
37-
PIP_TRUSTED_HOST=${nexusHost} \
38-
UV_CA_CERTIFICATE=/etc/ssl/certs/ca-bundle.crt
39-
40-
41-
ENV UV_DEFAULT_INDEX=${UV_INDEX_URL} \
42-
PIP_INDEX_URL=${UV_INDEX_URL} \
43-
PIP_CERT=${UV_CA_CERTIFICATE}
36+
UV_CA_CERTIFICATE=/etc/ssl/certs/ca-bundle.crt \
37+
PIP_CERT=/etc/ssl/certs/ca-bundle.crt
4438

4539
ENV INSTALL_PKGS="yum-utils gcc make git-core zlib zlib-devel gcc-c++ patch \
4640
readline \
@@ -72,15 +66,28 @@ RUN set -x \
7266
RUN curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh && \
7367
mkdir -p $HOME/.config/pip && \
7468
echo "[global]" > $HOME/.config/pip/pip.conf && \
75-
echo "index-url = https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple" >> $HOME/.config/pip/pip.conf && \
76-
echo "trusted-host = ${nexusHost}" >> $HOME/.config/pip/pip.conf
69+
if [ -n "${nexusHost}" ] && [ -n "${nexusAuth}" ]; then \
70+
echo "index-url = https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple" >> $HOME/.config/pip/pip.conf && \
71+
echo "trusted-host = ${nexusHost}" >> $HOME/.config/pip/pip.conf && \
72+
echo "export UV_DEFAULT_INDEX=https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple" > /etc/profile.d/uv-index.sh; \
73+
else \
74+
echo "export UV_DEFAULT_INDEX=https://pypi.org/simple" > /etc/profile.d/uv-index.sh; \
75+
fi && \
76+
yum -y clean all
7777

7878
RUN for pyVersion in 3.8 3.9 3.11; do \
7979
uv python install $pyVersion && \
80-
uv pip install --verbose --system --break-system-packages --python $pyVersion --trusted-host ${nexusHost} --prerelease=allow \
81-
virtualenv \
82-
pycodestyle \
83-
-r /tmp/requirements.txt; \
80+
if [ -n "${nexusHost}" ] && [ -n "${nexusAuth}" ]; then \
81+
uv pip install --verbose --system --break-system-packages --python $pyVersion --index-url https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple --trusted-host ${nexusHost} --prerelease=allow \
82+
virtualenv \
83+
pycodestyle \
84+
-r /tmp/requirements.txt; \
85+
else \
86+
uv pip install --verbose --system --break-system-packages --python $pyVersion --prerelease=allow \
87+
virtualenv \
88+
pycodestyle \
89+
-r /tmp/requirements.txt; \
90+
fi; \
8491
done && \
8592
rm -f /tmp/requirements.txt && \
8693
uv python pin 3.11 && \

common/jenkins-agents/terraform-2408/docker/Dockerfile.ubi9

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,8 @@ ENV TERRAFORM_VERSION=1.9.4 \
3838
TASK_VERSION=3.38.0 \
3939
UV_VERSION=0.10.9 \
4040
NPM_CONFIG_CAFILE=/etc/pki/ca-trust/extracted/pem/objsign-ca-bundle.pem \
41-
UV_INDEX_URL=https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple \
42-
PIP_TRUSTED_HOST=${nexusHost} \
43-
UV_CA_CERTIFICATE=/etc/ssl/certs/ca-bundle.crt
44-
45-
46-
ENV UV_DEFAULT_INDEX=${UV_INDEX_URL} \
47-
PIP_INDEX_URL=${UV_INDEX_URL} \
48-
PIP_CERT=${UV_CA_CERTIFICATE}
41+
UV_CA_CERTIFICATE=/etc/ssl/certs/ca-bundle.crt \
42+
PIP_CERT=/etc/ssl/certs/ca-bundle.crt
4943

5044
ENV INSTALL_PKGS="yum-utils gcc make git-core zlib zlib-devel gcc-c++ patch \
5145
readline \
@@ -76,15 +70,24 @@ RUN set -x \
7670
RUN curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh && \
7771
mkdir -p $HOME/.config/pip && \
7872
echo "[global]" > $HOME/.config/pip/pip.conf && \
79-
echo "index-url = https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple" >> $HOME/.config/pip/pip.conf && \
80-
echo "trusted-host = ${nexusHost}" >> $HOME/.config/pip/pip.conf
73+
if [ -n "${nexusHost}" ] && [ -n "${nexusAuth}" ]; then \
74+
echo "index-url = https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple" >> $HOME/.config/pip/pip.conf && \
75+
echo "trusted-host = ${nexusHost}" >> $HOME/.config/pip/pip.conf; \
76+
fi
8177

8278
RUN for pyVersion in 3.9 3.11 3.12; do \
8379
uv python install $pyVersion && \
84-
uv pip install --verbose --system --break-system-packages --python $pyVersion --trusted-host ${nexusHost} --prerelease=allow \
85-
virtualenv \
86-
pycodestyle \
87-
-r /tmp/requirements.txt; \
80+
if [ -n "${nexusHost}" ] && [ -n "${nexusAuth}" ]; then \
81+
uv pip install --verbose --system --break-system-packages --python $pyVersion --index-url https://${nexusAuth}@${nexusHost}/repository/pypi-all/simple --trusted-host ${nexusHost} --prerelease=allow \
82+
virtualenv \
83+
pycodestyle \
84+
-r /tmp/requirements.txt; \
85+
else \
86+
uv pip install --verbose --system --break-system-packages --python $pyVersion --prerelease=allow \
87+
virtualenv \
88+
pycodestyle \
89+
-r /tmp/requirements.txt; \
90+
fi; \
8891
done && \
8992
rm -f /tmp/requirements.txt && \
9093
uv python pin 3.12 && \

0 commit comments

Comments
 (0)