Skip to content

Commit 5efad36

Browse files
committed
Ubuntu: Replace python/pip by UV
1 parent e6232d1 commit 5efad36

3 files changed

Lines changed: 48 additions & 31 deletions

File tree

ubuntu-20.04-qt6.6/Dockerfile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ RUN apt-get update -q && apt-get -y -q install --no-install-recommends \
4343
make \
4444
ninja-build \
4545
p7zip-full \
46-
python3 \
47-
python3-pip \
48-
python3-setuptools \
49-
python3-wheel \
5046
software-properties-common \
5147
wget \
5248
xvfb \
@@ -58,13 +54,6 @@ RUN apt-get update -q && apt-get -y -q install --no-install-recommends \
5854
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
5955
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
6056

61-
# Set Python3 as default Python version
62-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 100
63-
RUN update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 100
64-
65-
# Allow installing pip packages system-wide since there's no risk in a container
66-
ENV PIP_BREAK_SYSTEM_PACKAGES=1
67-
6857
# Install Rust
6958
# Make .cargo/ writable for everyone to allow running the container as non-root.
7059
ARG RUST_VERSION="1.87.0"
@@ -181,6 +170,22 @@ RUN wget -c "$LINUXDEPLOY_URL" -O /usr/local/bin/linuxdeploy-x86_64.AppImage \
181170
&& chmod a+x /usr/local/bin/linuxdeploy-plugin-qt-x86_64.AppImage \
182171
&& linuxdeploy-x86_64.AppImage --list-plugins
183172

173+
# Install UV
174+
# Set its python directory to a known, user-writable path to allow accessing the
175+
# python versions installed during docker build from within CI runs which are
176+
# run as non-root.
177+
ARG UV_VERSION="0.7.13"
178+
ARG UV_URL="https://github.com/astral-sh/uv/releases/download/$UV_VERSION/uv-x86_64-unknown-linux-gnu.tar.gz"
179+
ENV UV_PYTHON_INSTALL_DIR="/.uv/python"
180+
RUN wget -c "${UV_URL}" -O /tmp.tar.gz \
181+
&& tar -xzf /tmp.tar.gz --strip-components=1 -C /usr/local/bin/ \
182+
&& rm /tmp.tar.gz \
183+
&& mkdir -p $UV_PYTHON_INSTALL_DIR && chmod 777 $UV_PYTHON_INSTALL_DIR
184+
185+
# Pre-install a Python version
186+
ARG PYTHON_VERSION="3.13"
187+
RUN uv python install $PYTHON_VERSION
188+
184189
# Install latest OpenSSL to avoid possible issues if servers some day stop
185190
# working with an old OpenSSL library (as already happened in the past).
186191
ARG OPENSSL_VERSION="3.4.1"

ubuntu-22.04/Dockerfile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ RUN apt-get update -q && apt-get -y -q install --no-install-recommends \
3838
occt-misc \
3939
openssl \
4040
pkg-config \
41-
python3 \
42-
python3-pip \
43-
python3-setuptools \
44-
python3-wheel \
4541
qt6-base-dev \
4642
qt6-image-formats-plugins \
4743
qt6-l10n-tools \
@@ -53,12 +49,6 @@ RUN apt-get update -q && apt-get -y -q install --no-install-recommends \
5349
zlib1g-dev \
5450
&& rm -rf /var/lib/apt/lists/*
5551

56-
# Set Python3 as default Python version
57-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 100
58-
59-
# Allow installing pip packages system-wide since there's no risk in a container
60-
ENV PIP_BREAK_SYSTEM_PACKAGES=1
61-
6252
# Install Rust
6353
# Make .cargo/ writable for everyone to allow running the container as non-root.
6454
ARG RUST_VERSION="1.87.0"
@@ -70,5 +60,21 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
7060
&& chmod 777 $RUSTUP_HOME \
7161
&& chmod 777 $CARGO_HOME
7262

63+
# Install UV
64+
# Set its python directory to a known, user-writable path to allow accessing the
65+
# python versions installed during docker build from within CI runs which are
66+
# run as non-root.
67+
ARG UV_VERSION="0.7.13"
68+
ARG UV_URL="https://github.com/astral-sh/uv/releases/download/$UV_VERSION/uv-x86_64-unknown-linux-gnu.tar.gz"
69+
ENV UV_PYTHON_INSTALL_DIR="/.uv/python"
70+
RUN wget -c "${UV_URL}" -O /tmp.tar.gz \
71+
&& tar -xzf /tmp.tar.gz --strip-components=1 -C /usr/local/bin/ \
72+
&& rm /tmp.tar.gz \
73+
&& mkdir -p $UV_PYTHON_INSTALL_DIR && chmod 777 $UV_PYTHON_INSTALL_DIR
74+
75+
# Pre-install a Python version
76+
ARG PYTHON_VERSION="3.13"
77+
RUN uv python install $PYTHON_VERSION
78+
7379
# LibrePCB's unittests expect that there is a USERNAME environment variable
7480
ENV USERNAME="root"

ubuntu-24.04/Dockerfile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ RUN apt-get update -q && apt-get -y -q install --no-install-recommends \
3838
occt-misc \
3939
openssl \
4040
pkg-config \
41-
python3 \
42-
python3-pip \
43-
python3-setuptools \
44-
python3-wheel \
4541
qt6-base-dev \
4642
qt6-image-formats-plugins \
4743
qt6-l10n-tools \
@@ -53,12 +49,6 @@ RUN apt-get update -q && apt-get -y -q install --no-install-recommends \
5349
zlib1g-dev \
5450
&& rm -rf /var/lib/apt/lists/*
5551

56-
# Set Python3 as default Python version
57-
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 100
58-
59-
# Allow installing pip packages system-wide since there's no risk in a container
60-
ENV PIP_BREAK_SYSTEM_PACKAGES=1
61-
6252
# Install Rust
6353
# Make .cargo/ writable for everyone to allow running the container as non-root.
6454
ARG RUST_VERSION="1.87.0"
@@ -70,5 +60,21 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
7060
&& chmod 777 $RUSTUP_HOME \
7161
&& chmod 777 $CARGO_HOME
7262

63+
# Install UV
64+
# Set its python directory to a known, user-writable path to allow accessing the
65+
# python versions installed during docker build from within CI runs which are
66+
# run as non-root.
67+
ARG UV_VERSION="0.7.13"
68+
ARG UV_URL="https://github.com/astral-sh/uv/releases/download/$UV_VERSION/uv-x86_64-unknown-linux-gnu.tar.gz"
69+
ENV UV_PYTHON_INSTALL_DIR="/.uv/python"
70+
RUN wget -c "${UV_URL}" -O /tmp.tar.gz \
71+
&& tar -xzf /tmp.tar.gz --strip-components=1 -C /usr/local/bin/ \
72+
&& rm /tmp.tar.gz \
73+
&& mkdir -p $UV_PYTHON_INSTALL_DIR && chmod 777 $UV_PYTHON_INSTALL_DIR
74+
75+
# Pre-install a Python version
76+
ARG PYTHON_VERSION="3.13"
77+
RUN uv python install $PYTHON_VERSION
78+
7379
# LibrePCB's unittests expect that there is a USERNAME environment variable
7480
ENV USERNAME="root"

0 commit comments

Comments
 (0)