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"