File size: 942 Bytes
8cc417a
56e76e3
 
5878f39
eae0cc8
 
e7b36c2
56e76e3
 
e7b36c2
b69845a
eae0cc8
56e76e3
8cc417a
eae0cc8
56e76e3
e7b36c2
56e76e3
 
e7b36c2
56e76e3
8cc417a
 
 
e7b36c2
 
 
8cc417a
e7b36c2
 
8cc417a
eae0cc8
e7b36c2
6856fcd
e7b36c2
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
# syntax=docker/dockerfile:1
FROM python:3.12-slim

# 1. Create non‑root user
RUN useradd --create-home --shell /bin/bash --uid 1000 appuser

# 2. Environment variables - set HF_HOME to match what's used in lifespan
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    HF_HOME=/home/appuser/huggingface \
    PORT=7860 \
    PATH=/home/appuser/.local/bin:$PATH

# 3. Set working directory
WORKDIR /home/appuser/app

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

# 5. Copy code and set permissions
COPY --chown=appuser:appuser . .

# 6. Create huggingface directory with proper permissions
RUN mkdir -p /home/appuser/huggingface && \
    chown -R appuser:appuser /home/appuser

# 7. Switch to appuser
USER appuser


# 9. Expose port & run app using uvicorn
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]