| |
| |
| FROM python:3.12-slim AS build |
|
|
| |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ |
| WORKDIR /app |
|
|
| |
| |
| ENV UV_COMPILE_BYTECODE=1 \ |
| |
| UV_LINK_MODE=copy \ |
| |
| UV_PYTHON_INSTALL_DIR=/opt/python |
|
|
| RUN uv python install 3.12 |
| RUN uv venv |
| RUN uv pip install --no-cache-dir --upgrade pip setuptools wheel |
|
|
| |
| COPY requirements.cpu.txt ./ |
| RUN uv pip install --no-cache-dir -r ./requirements.cpu.txt |
|
|
| |
| COPY requirements.torch.gpu.txt ./ |
| RUN uv pip install --no-cache-dir -r ./requirements.torch.gpu.txt |
|
|
| |
| COPY scripts/model_download.bash /tmp/model_download.bash |
| RUN . .venv/bin/activate && \ |
| uv pip install --no-cache-dir huggingface-hub && \ |
| bash /tmp/model_download.bash && \ |
| rm /tmp/model_download.bash |
|
|
| COPY app ./app |
| COPY main.py ./ |
|
|
| |
|
|
| FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04 AS run |
| WORKDIR /app |
|
|
| ENV PYTHONDONTWRITEBYTECODE="1" \ |
| PYTHONUNBUFFERED="1" \ |
| DEBIAN_FRONTEND="noninteractive" |
|
|
| |
| |
| COPY --from=build --chmod=777 /opt/python /opt/python |
| COPY --from=build --chmod=777 /app /app |
|
|
| |
| ENV PATH="/app/.venv/bin:${PATH}" \ |
| PYTHONPATH="/app" |
|
|
| EXPOSE 8000 |
|
|
| |
| |
| ENV TORCHINDUCTOR_CACHE_DIR="/tmp/torchinductor" |
|
|
| ENTRYPOINT ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |
|
|