FROM python:3.10-slim # Set up a new non-root user (Hugging Face Spaces requirement) RUN useradd -m -u 1000 user # Set up working directory WORKDIR /code # Copy requirements file and install dependencies COPY ./requirements.txt /code/requirements.txt RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # Additional NLP requirement for BERT + Spacy RUN python -m spacy download es_core_news_sm # Switch to the non-root user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy the rest of the application files with user permissions COPY --chown=user . $HOME/app # Hugging Face exposes port 7860 # Note: we need to point uvicorn to backend.app:app CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860"]