File size: 923 Bytes
738956e
 
db89442
738956e
 
 
 
db89442
834f531
 
 
db89442
 
 
834f531
db89442
738956e
db89442
 
 
 
738956e
 
db89442
 
738956e
db89442
738956e
 
db89442
 
 
12c1f3d
3034962
db89442
d820e86
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
FROM python:3.11-slim

# 1. System setup
RUN apt-get update && apt-get install -y \
    git \
    && rm -rf /var/lib/apt/lists/*

# 2. Create User (HF expects ID 1000)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

WORKDIR $HOME/app

# 3. Cache Dependencies (The "Fast Build" trick)
# We copy ONLY requirements first so this layer stays cached 
# unless you change your requirements.txt file.
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 4. Copy Project Files
COPY --chown=user . .

# 5. Safety Net for Directories
RUN mkdir -p root/network root/db root/api

# 6. Port Configuration
# HF ignores EXPOSE, but it's good practice. 
# The CMD below is what actually matters.
EXPOSE 7860

# 7. Launch
CMD ["uvicorn", "root.server:app", "--host", "0.0.0.0", "--port", "7860"]