-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile-lb
More file actions
48 lines (39 loc) · 2 KB
/
Dockerfile-lb
File metadata and controls
48 lines (39 loc) · 2 KB
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
43
44
45
46
47
48
ARG PYTHON_VERSION=3.11
ARG PYTORCH_BASE=pytorch/pytorch:2.9.1-cuda12.8-cudnn9-runtime
FROM ${PYTORCH_BASE}
# Validate base image Python matches requested version
ARG PYTHON_VERSION
RUN python -c "import sys; expected='$PYTHON_VERSION'; actual='.'.join(map(str,sys.version_info[:2])); assert actual==expected, f'Python mismatch: expected {expected}, got {actual}'"
WORKDIR /app
# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Set timezone to avoid tzdata prompts
ENV TZ=Etc/UTC
# Enable HuggingFace transfer acceleration
ENV HF_HUB_ENABLE_HF_TRANSFER=1
# Relocate HuggingFace cache outside /root/.cache to exclude from volume sync
ENV HF_HOME=/hf-cache
# Configure APT cache to persist under /root/.cache for volume sync
RUN mkdir -p /root/.cache/apt/archives/partial \
&& echo 'Dir::Cache "/root/.cache/apt";' > /etc/apt/apt.conf.d/01cache
# Install system dependencies and uv
# Note: build-essential not pre-installed to reduce image size (400MB savings)
# Automatic detection will install it when needed (no manual action required)
# Advanced: Users can pre-install via system_dependencies=["build-essential"]
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates git \
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
&& cp ~/.local/bin/uv /usr/local/bin/uv \
&& chmod +x /usr/local/bin/uv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy app code and install dependencies
COPY README.md pyproject.toml uv.lock ./
COPY src/ ./
RUN uv export --format requirements-txt --no-dev --no-hashes > requirements.txt \
&& uv pip install --system -r requirements.txt
EXPOSE 80
# CMD will be overridden by RunPod at runtime to run the specific generated handler
# The handler factory generates handler_{resource_name}.py files
# RunPod will invoke: uvicorn handler_{resource_name}:app --host 0.0.0.0 --port 80
CMD ["uvicorn", "lb_handler:app", "--host", "0.0.0.0", "--port", "80", "--timeout-keep-alive", "600"]