Skip to content

Commit fde2223

Browse files
committed
chore(superset): Use uv instead of pip
1 parent 36fcf26 commit fde2223

1 file changed

Lines changed: 34 additions & 26 deletions

File tree

superset/Dockerfile

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
# syntax=docker/dockerfile:1.16.0@sha256:e2dd261f92e4b763d789984f6eab84be66ab4f5f08052316d8eb8f173593acf7
2-
# check=error=true
2+
# check=error=true;skip=InvalidDefaultArgInFrom
3+
4+
ARG UV_VERSION
5+
6+
# TODO (@NickLarsenNZ): Get the image into our registry
7+
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv-image
38

49
FROM local-image/shared/statsd-exporter AS statsd_exporter-builder
510

611
FROM local-image/stackable-devel AS opa-authorizer-builder
712

813
ARG PYTHON_VERSION
14+
ARG STACKABLE_USER_UID
915

1016
COPY superset/stackable/opa-authorizer /tmp/opa-authorizer
1117

18+
COPY --from=uv-image --chown=${STACKABLE_USER_UID}:0 /uv /uvx /bin/
19+
1220
RUN <<EOF
1321
microdnf update
1422
microdnf install \
1523
gcc \
16-
gcc-c++ \
17-
python${PYTHON_VERSION} \
18-
python${PYTHON_VERSION}-devel \
19-
python${PYTHON_VERSION}-pip
24+
gcc-c++
2025
microdnf clean all
2126
rm -rf /var/cache/yum
2227

23-
pip${PYTHON_VERSION} install \
28+
uv venv --python "${PYTHON_VERSION}" --system-site-packages /stackable/app
29+
. /stackable/app/bin/activate
30+
31+
uv pip install \
2432
--no-cache-dir \
2533
--upgrade \
2634
poetry==2.1.1 \
2735
pytest==8.3.4
2836

2937
cd /tmp/opa-authorizer
3038

31-
poetry sync
32-
poetry run pytest
33-
poetry build
39+
# Warnings are disabled because they come from various third party testing libraries
40+
# that we have no control over.
41+
uv run pytest --disable-warnings
42+
uv build
3443
EOF
3544

3645
FROM local-image/stackable-devel AS builder
@@ -45,8 +54,9 @@ ARG UV_VERSION
4554
ARG NODEJS_VERSION
4655
ARG STACKABLE_USER_UID
4756

48-
RUN microdnf module enable -y nodejs:${NODEJS_VERSION} && \
49-
microdnf update \
57+
COPY --from=uv-image --chown=${STACKABLE_USER_UID}:0 /uv /uvx /bin/
58+
59+
RUN microdnf update \
5060
&& microdnf install \
5161
cyrus-sasl-devel \
5262
# Needed by ./configure to work out SQLite compilation flags, see snippet [1] at the end of file
@@ -61,10 +71,6 @@ RUN microdnf module enable -y nodejs:${NODEJS_VERSION} && \
6171
libffi-devel \
6272
openldap-devel \
6373
openssl-devel \
64-
python${PYTHON_VERSION} \
65-
python${PYTHON_VERSION}-devel \
66-
python${PYTHON_VERSION}-pip \
67-
python${PYTHON_VERSION}-wheel \
6874
libpq-devel \
6975
# Needed to build Superset UI assets
7076
npm \
@@ -92,13 +98,8 @@ WORKDIR /stackable
9298
# See https://github.com/hadolint/hadolint/issues/1042.
9399
# hadolint ignore=DL3042
94100
RUN <<EOF
95-
python${PYTHON_VERSION} -m venv --system-site-packages /stackable/app
96-
97-
source /stackable/app/bin/activate
98-
99-
# Upgrade pip to the latest version
100-
# Also install uv to get support for build constraints
101-
pip install --no-cache-dir --upgrade pip setuptools==75.2.0 uv==${UV_VERSION}
101+
uv venv --python "${PYTHON_VERSION}" --system-site-packages /stackable/app
102+
. /stackable/app/bin/activate
102103

103104
cd "$(/stackable/patchable --images-repo-root=src checkout superset ${PRODUCT_VERSION})"
104105

@@ -117,7 +118,7 @@ uv pip install --no-cache-dir build
117118
# Build superset wheel from superset root folder
118119
# This picks up the UI assets from the npm build
119120
cd ..
120-
python${PYTHON_VERSION} -m build --wheel
121+
uv build
121122
uv pip install --no-cache-dir dist/apache_superset-*-py3-none-any.whl --constraint /tmp/constraints.txt --build-constraints /tmp/build-constraints.txt
122123

123124
# Install additional dependencies
@@ -198,20 +199,27 @@ COPY --from=builder --chown=${STACKABLE_USER_UID}:0 /stackable/ ${HOME}/
198199
COPY --from=statsd_exporter-builder --chown=${STACKABLE_USER_UID}:0 /statsd_exporter/statsd_exporter /stackable/statsd_exporter
199200
COPY --from=statsd_exporter-builder --chown=${STACKABLE_USER_UID}:0 /statsd_exporter/statsd_exporter-${SHARED_STATSD_EXPORTER_VERSION}.cdx.json /stackable/statsd_exporter-${SHARED_STATSD_EXPORTER_VERSION}.cdx.json
200201

202+
COPY --from=uv-image --chown=${STACKABLE_USER_UID}:0 /uv /uvx /bin/
203+
201204
RUN <<EOF
202205
microdnf update
203206
microdnf install \
204207
cyrus-sasl \
205208
openldap \
206209
openldap-clients \
207-
openssl-libs \
208-
openssl-pkcs11 \
209-
"python${PYTHON_VERSION}"
210+
openssl-libs
210211

211212
microdnf clean all
212213
rm -rf /var/cache/yum
213214

214215
chmod g=u /stackable/statsd_exporter /stackable/statsd_exporter-${SHARED_STATSD_EXPORTER_VERSION}.cdx.json
216+
217+
# There is currently no way to tell `uv` where to write to, and it assumes `$HOME` for the XDG paths.
218+
export XDG_DATA_HOME=/usr/local/share
219+
export XDG_CACHE_HOME=/var/cache
220+
uv venv --python "${PYTHON_VERSION}" --system-site-packages /stackable/app
221+
chown -R "${STACKABLE_USER_UID}:0" /stackable/app/bin
222+
. /stackable/app/bin/activate
215223
EOF
216224

217225
# ----------------------------------------

0 commit comments

Comments
 (0)