Spaces:
Sleeping
Sleeping
| FROM python:3.11 | |
| WORKDIR /code | |
| COPY ./requirements.txt /code/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
| # Set up a new user named "user" with UID 1000 to prevent permission issues on Hugging Face | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Pre-download and cache Hugging Face models in the user's home directory during build phase | |
| RUN python -c "from transformers import AutoTokenizer, AutoModelForSequenceClassification; \ | |
| AutoTokenizer.from_pretrained('kmack/malicious-url-detection'); \ | |
| AutoModelForSequenceClassification.from_pretrained('kmack/malicious-url-detection'); \ | |
| AutoTokenizer.from_pretrained('distilbert-base-uncased'); \ | |
| AutoModelForSequenceClassification.from_pretrained('distilbert-base-uncased')" | |
| WORKDIR $HOME/app | |
| COPY --chown=user . $HOME/app | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |