FROM python:3.12-alpine as base
RUN pip install uv
ENV PYTHONUNBUFFERED=1
ENV VENV_PATH=/app/venv
ENV PATH="${VENV_PATH}/bin:$PATH"
WORKDIR /app
RUN uv venv ${VENV_PATH}

FROM base as deps
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache uv pip install -r requirements.txt

FROM python:3.12-alpine as main
RUN apk add --no-cache git
RUN apk add --no-cache openssh-client
RUN pip install uv
ENV PYTHONUNBUFFERED=1
ENV VENV_PATH=/app/venv
ENV PATH="${VENV_PATH}/bin:$PATH"
WORKDIR /app
COPY requirements.txt .
COPY --from=deps /app/venv /app/venv
COPY src ./src
COPY scripts ./scripts
CMD tail -f /dev/null