File size: 856 Bytes
ea6a10c
7e431a1
 
 
 
 
 
 
 
 
ea6a10c
 
7e431a1
 
 
 
 
ea6a10c
7e431a1
 
 
ea6a10c
7e431a1
 
ea6a10c
7e431a1
 
 
 
 
 
 
 
 
ea6a10c
7e431a1
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
# 1. Use the official Python slim image
FROM python:3.12-slim

# 2. Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PORT=7860

WORKDIR /app

# 3. Install ONLY necessary system dependencies
# Removed 'software-properties-common' as it is obsolete in Debian Trixie
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

# 4. Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 5. Copy application code
COPY . .

# 6. Hugging Face security best practices
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
COPY --chown=user . $HOME/app

EXPOSE 7860

# 7. Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]