🏗️(core) migrate from pip to uv
We want to migrate our projects from pip to uv to take the benefits of the lock file and have reproducible installations. A first uv.lock file is comitted and the Dockerfile and compose are modified to work with uv
This commit is contained in:
@@ -29,6 +29,10 @@ and this project adheres to
|
|||||||
- ✨(backend) adapt to conversation RAG
|
- ✨(backend) adapt to conversation RAG
|
||||||
- ✨(backend) add deletion endpoint
|
- ✨(backend) add deletion endpoint
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- 🏗️(backend) switch Python dependency management to uv
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
- 🐛(backend) fix missing index creation in 'index/' view
|
- 🐛(backend) fix missing index creation in 'index/' view
|
||||||
|
|||||||
+30
-21
@@ -3,9 +3,6 @@
|
|||||||
# ---- base image to inherit from ----
|
# ---- base image to inherit from ----
|
||||||
FROM python:3.12-slim-bookworm AS base
|
FROM python:3.12-slim-bookworm AS base
|
||||||
|
|
||||||
# Upgrade pip to its latest release to speed up dependencies installation
|
|
||||||
RUN python -m pip install --upgrade pip
|
|
||||||
|
|
||||||
# Upgrade system packages to install security updates
|
# Upgrade system packages to install security updates
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get -y upgrade && \
|
apt-get -y upgrade && \
|
||||||
@@ -14,13 +11,28 @@ RUN apt-get update && \
|
|||||||
# ---- Back-end builder image ----
|
# ---- Back-end builder image ----
|
||||||
FROM base AS back-builder
|
FROM base AS back-builder
|
||||||
|
|
||||||
WORKDIR /builder
|
ENV UV_COMPILE_BYTECODE=1
|
||||||
|
ENV UV_LINK_MODE=copy
|
||||||
|
|
||||||
# Copy required python dependencies
|
# Disable Python downloads, because we want to use the system interpreter
|
||||||
COPY ./src/backend /builder
|
# across both images. If using a managed Python version, it needs to be
|
||||||
|
# copied from the build image into the final image;
|
||||||
|
ENV UV_PYTHON_DOWNLOADS=0
|
||||||
|
|
||||||
RUN mkdir /install && \
|
# install uv
|
||||||
pip install --prefix=/install .
|
COPY --from=ghcr.io/astral-sh/uv:0.9.10 /uv /uvx /bin/
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
|
--mount=type=bind,source=src/backend/uv.lock,target=uv.lock \
|
||||||
|
--mount=type=bind,source=src/backend/pyproject.toml,target=pyproject.toml \
|
||||||
|
uv sync --locked --no-install-project --no-dev
|
||||||
|
|
||||||
|
COPY ./src/backend /app
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
|
uv sync --locked --no-dev
|
||||||
|
|
||||||
# ---- static link collector ----
|
# ---- static link collector ----
|
||||||
FROM base AS link-collector
|
FROM base AS link-collector
|
||||||
@@ -33,11 +45,10 @@ RUN apt-get update && \
|
|||||||
rdfind && \
|
rdfind && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy installed python dependencies
|
# Copy the application from the builder
|
||||||
COPY --from=back-builder /install /usr/local
|
COPY --from=back-builder /app /app
|
||||||
|
|
||||||
# Copy find application (see .dockerignore)
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
COPY ./src/backend /app/
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -76,14 +87,13 @@ COPY ./docker/files/usr/local/bin/entrypoint /usr/local/bin/entrypoint
|
|||||||
# docker user (see entrypoint).
|
# docker user (see entrypoint).
|
||||||
RUN chmod g=u /etc/passwd
|
RUN chmod g=u /etc/passwd
|
||||||
|
|
||||||
# Copy installed python dependencies
|
# Copy the prepared application (see .dockerignore)
|
||||||
COPY --from=back-builder /install /usr/local
|
COPY --from=back-builder /app /app
|
||||||
|
|
||||||
# Copy find application (see .dockerignore)
|
|
||||||
COPY ./src/backend /app/
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
# We wrap commands run in this container by the following entrypoint that
|
# We wrap commands run in this container by the following entrypoint that
|
||||||
# creates a user on-the-fly with the container user ID (see USER) and root group
|
# creates a user on-the-fly with the container user ID (see USER) and root group
|
||||||
# ID.
|
# ID.
|
||||||
@@ -100,10 +110,9 @@ RUN apt-get update && \
|
|||||||
apt-get install -y postgresql-client && \
|
apt-get install -y postgresql-client && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Uninstall find and re-install it in editable mode along with development
|
# Install development dependencies
|
||||||
# dependencies
|
RUN --mount=from=ghcr.io/astral-sh/uv:0.9.10,source=/uv,target=/bin/uv \
|
||||||
RUN pip uninstall -y find
|
uv sync --locked --all-extras
|
||||||
RUN pip install -e .[dev]
|
|
||||||
|
|
||||||
# Restore the un-privileged user running the application
|
# Restore the un-privileged user running the application
|
||||||
ARG DOCKER_USER
|
ARG DOCKER_USER
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./src/backend:/app
|
- ./src/backend:/app
|
||||||
- ./data/static:/data/static
|
- ./data/static:/data/static
|
||||||
|
- /app/.venv
|
||||||
depends_on:
|
depends_on:
|
||||||
postgresql:
|
postgresql:
|
||||||
condition: service_started
|
condition: service_started
|
||||||
@@ -90,6 +91,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./src/backend:/app
|
- ./src/backend:/app
|
||||||
- ./data/static:/data/static
|
- ./data/static:/data/static
|
||||||
|
- /app/.venv
|
||||||
depends_on:
|
depends_on:
|
||||||
- app
|
- app
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ extension-pkg-whitelist=
|
|||||||
|
|
||||||
# Add files or directories to the blacklist. They should be base names, not
|
# Add files or directories to the blacklist. They should be base names, not
|
||||||
# paths.
|
# paths.
|
||||||
ignore=migrations
|
ignore=migrations,.venv
|
||||||
|
|
||||||
# Add files or directories matching the regex patterns to the blacklist. The
|
# Add files or directories matching the regex patterns to the blacklist. The
|
||||||
# regex matches against base names, not paths.
|
# regex matches against base names, not paths.
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ classifiers = [
|
|||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: MIT License",
|
||||||
"Natural Language :: English",
|
"Natural Language :: English",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.12",
|
||||||
]
|
]
|
||||||
description = "An application to print markdown to pdf from a set of managed templates."
|
description = "An application to print markdown to pdf from a set of managed templates."
|
||||||
keywords = ["Django", "Contacts", "Templates", "RBAC"]
|
keywords = ["Django", "Contacts", "Templates", "RBAC"]
|
||||||
license = { file = "LICENSE" }
|
license = { file = "LICENSE" }
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = "~=3.12.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"celery[redis]==5.6.2",
|
"celery[redis]==5.6.2",
|
||||||
"django-configurations==2.5.1",
|
"django-configurations==2.5.1",
|
||||||
|
|||||||
Generated
+1711
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user