-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.predictor
42 lines (34 loc) · 1.33 KB
/
Dockerfile.predictor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
FROM python:3.12-slim-bullseye
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
ENV UV_PYTHON_DOWNLOADS=never
# Location of the virtual environment
ENV UV_PROJECT_ENVIRONMENT="/venv"
# Location of the python installation via uv
ENV UV_PYTHON_INSTALL_DIR="/python"
# Byte compile the python files on installation
ENV UV_COMPILE_BYTECODE=1
# Python verision to use
ENV UV_PYTHON=python3.12
# Tweaking the PATH variable for easier use
ENV PATH="$UV_PROJECT_ENVIRONMENT/bin:$PATH"
WORKDIR /app
# Install minimal required dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*
# Install dependencies using uv
RUN --mount=type=cache,target=/root/.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-editable
# Copy only necessary files
COPY src/predictor/ /app/code/
COPY src/configs/model_config.py /app/code/configs/
COPY src/configs/database_config.py /app/code/configs/
COPY src/payload/predictor_models.py /app/code/payload/
COPY src/payload/shared_models.py /app/code/payload/
COPY src/database/ /app/code/database/
COPY .env /app/code/
WORKDIR /app/code/
CMD ["uv", "run", "uvicorn", "predictor:app", "--host", "0.0.0.0", "--port", "7070"]