File size: 909 Bytes
0da497e
 
 
 
 
 
 
 
 
dd4466b
0da497e
 
 
 
dd4466b
 
 
0da497e
dd4466b
 
 
 
 
0da497e
 
 
 
 
1d8dc03
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
FROM python:3.13.5-slim

# Create non-root user (HF requirement)
RUN useradd -m -u 1000 user

# Set work directory
WORKDIR /home/user/app

# Copy requirements first (better cache)
COPY --chown=user:user requirements.txt .

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

# --- THE FIX: CACHE THE MODEL DURING BUILD ---
# This command downloads the model into the Docker image's cache directory.
# This means your app will start instantly without downloading it on boot!
USER user
RUN python -c "from transformers import pipeline; pipeline('zero-shot-classification', model='valhalla/distilbart-mnli-12-3')"
# ---------------------------------------------

# Copy project files
COPY --chown=user:user . .

# Expose HF port
EXPOSE 7860

# Run Django with Gunicorn (PRODUCTION SAFE)
CMD sh -c "python manage.py migrate && gunicorn expensewise_api.wsgi:application --bind 0.0.0.0:7860"