Swap to UV
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
FROM python:3.13-slim
|
||||
FROM ghcr.io/astral-sh/uv:bookworm-slim
|
||||
|
||||
ENV PUID=1000
|
||||
ENV PGID=1000
|
||||
@@ -10,11 +10,30 @@ RUN apt-get update && \
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./requirements.txt ./
|
||||
# Enable bytecode compilation
|
||||
ENV UV_COMPILE_BYTECODE=1
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
ENV UV_LINK_MODE=copy
|
||||
|
||||
COPY . .
|
||||
# Set the cache directory to /tmp instead of root
|
||||
ENV UV_CACHE_DIR=/tmp/.cache/uv
|
||||
|
||||
ENV UV_PYTHON_INSTALL_DIR=/app/.bin
|
||||
|
||||
# Install the project's dependencies using the lockfile and settings
|
||||
RUN --mount=type=cache,target=/tmp/.cache/uv \
|
||||
--mount=type=bind,source=uv.lock,target=uv.lock \
|
||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||
uv sync --frozen --no-install-project --no-dev
|
||||
|
||||
# Then, add the rest of the project source code and install it
|
||||
# Installing separately from its dependencies allows optimal layer caching
|
||||
COPY . /app
|
||||
RUN --mount=type=cache,target=/tmp/.cache/uv \
|
||||
uv sync --frozen --no-dev
|
||||
|
||||
# Place executables in the environment at the front of the path
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
RUN chmod +x *.sh && \
|
||||
dos2unix *.sh
|
||||
|
||||
Reference in New Issue
Block a user