feat(api): migrate to uv package manager

- Add uv as dependency manager for faster installations
- Remove pinned versions from apk packages for better maintenance
- Fix lxml installation and dependency issues in requirements.txt
- Add environment setup steps in Dockerfile

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
rjshrjndrn 2025-03-13 12:59:59 +01:00
parent 8acee7d357
commit bd2a59266d
3 changed files with 19 additions and 14 deletions

View file

@ -1,18 +1,24 @@
FROM python:3.12-alpine
LABEL maintainer="KRAIEM Taha Yassine<tahayk2@gmail.com>"
RUN apk add --no-cache tini=0.19.0-r0 xmlsec=1.2.37-r0 && \
WORKDIR /app
COPY . .
RUN mv env.default .env
RUN apk add --no-cache tini xmlsec && \
export UV_SYSTEM_PYTHON=true && \
pip install uv && \
apk add --no-cache --virtual .build-deps \
build-base=0.5-r3 \
libressl=3.6.1-r0 \
libffi-dev=3.4.4-r0 \
libressl-dev=3.6.1-r0 \
libxslt-dev=1.1.37-r0 \
libxml2-dev=2.10.4-r0 \
xmlsec-dev=1.2.37-r0 && \
pip install --no-cache-dir --upgrade -r requirements.txt && \
build-base \
libressl \
libffi-dev \
libressl-dev \
libxslt-dev \
libxml2-dev \
xmlsec-dev && \
uv pip install --no-cache-dir --upgrade -r requirements.txt && \
# Solve the libxml2 library version mismatch by reinstalling lxml with matching libxml2
pip uninstall -y lxml && \
pip install --no-cache-dir --no-binary lxml lxml --force-reinstall && \
uv pip uninstall lxml && \
uv pip install --no-cache-dir --no-binary lxml lxml --force-reinstall && \
# Create non-root user
adduser -u 1001 openreplay -D && \
# Cleanup build dependencies

View file

@ -21,7 +21,6 @@ gunicorn = "==23.0.0"
python-decouple = "==3.8"
pydantic = {extras = ["email"], version = "==2.10.6"}
apscheduler = "==3.11.0"
lxml = "!=4.7.0,<=5.2.1,>=4.6.5"
python3-saml = "==1.16.0"
python-multipart = "==0.0.20"
redis = "==5.2.1"

View file

@ -19,8 +19,8 @@ apscheduler==3.11.0
# TODO: enable after xmlsec fix https://github.com/xmlsec/python-xmlsec/issues/252
#--no-binary is used to avoid libxml2 library version incompatibilities between xmlsec and lxml
lxml >= 4.6.5, !=4.7.0, <=5.2.1
python3-saml==1.16.0 --no-binary=lxml
python3-saml==1.16.0
--no-binary=lxml
python-multipart==0.0.20
redis==5.2.1