mess: UV + settings KISS + fixes
This commit is contained in:
+10
-27
@@ -3,14 +3,15 @@
|
||||
|
||||
ARG PYTHON_VERSION
|
||||
ARG PYTHON_VERSION_SHORT
|
||||
ARG RUNNER
|
||||
ARG UV_VERSION
|
||||
|
||||
# ===========================================
|
||||
# Stage 1: Builder
|
||||
# ===========================================
|
||||
FROM python:${PYTHON_VERSION}-slim-bookworm AS builder
|
||||
|
||||
# Re-declare ARGs after FROM to make them available in this stage
|
||||
ARG RUNNER
|
||||
ARG UV_VERSION
|
||||
|
||||
# STFU - No need - Write logs asap
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
@@ -18,30 +19,21 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
# Install build dependencies (needs root)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install runner globally (needs root) - Save cache for future
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
pip install $RUNNER
|
||||
# Install uv globally (needs root) - Save cache for future
|
||||
COPY --from=ghcr.io/astral-sh/uv:${UV_VERSION} /uv /usr/local/bin/uv
|
||||
|
||||
# Set working directory for dependency installation
|
||||
WORKDIR /tmp
|
||||
|
||||
# Copy dependency files
|
||||
COPY pyproject.toml poetry.lock* uv.lock* Makefile ./
|
||||
COPY pyproject.toml uv.lock Makefile ./
|
||||
|
||||
# Install dependencies as root (to avoid permission issues with system packages)
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
--mount=type=cache,target=/root/.cache/pypoetry \
|
||||
--mount=type=cache,target=/root/.cache/uv \
|
||||
if [ "$RUNNER" = "poetry" ]; then \
|
||||
poetry config virtualenvs.create false && \
|
||||
poetry install --only main --no-root; \
|
||||
elif [ "$RUNNER" = "uv" ]; then \
|
||||
uv pip install --system -r pyproject.toml; \
|
||||
fi
|
||||
RUN --mount=type=cache,target=/root/.cache/uv uv sync --system
|
||||
|
||||
COPY scripts/ ./scripts/
|
||||
COPY .env.example ./
|
||||
@@ -51,16 +43,7 @@ COPY .env.example ./
|
||||
# ===========================================
|
||||
FROM builder AS test
|
||||
|
||||
ARG RUNNER
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
--mount=type=cache,target=/root/.cache/pypoetry \
|
||||
--mount=type=cache,target=/root/.cache/uv \
|
||||
if [ "$RUNNER" = "poetry" ]; then \
|
||||
poetry install --no-root; \
|
||||
elif [ "$RUNNER" = "uv" ]; then \
|
||||
uv pip install --system -e .[dev]; \
|
||||
fi
|
||||
RUN --mount=type=cache,target=/root/.cache/uv uv sync --system -e .[dev]
|
||||
|
||||
COPY alfred/ ./alfred
|
||||
COPY scripts ./scripts
|
||||
|
||||
Reference in New Issue
Block a user