|
|
|
FROM python:3.12-slim as builder |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
RUN apt-get update && apt-get install -y \ |
|
build-essential \ |
|
curl \ |
|
git \ |
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
RUN mkdir -p /tmp/huggingface && chmod -R 777 /tmp/huggingface |
|
|
|
|
|
ENV TRANSFORMERS_CACHE=/tmp/huggingface |
|
ENV HF_HOME=/tmp/huggingface |
|
|
|
|
|
COPY requirements.txt . |
|
|
|
|
|
RUN pip install --no-cache-dir -r requirements.txt |
|
|
|
|
|
RUN python -m spacy download en_core_web_sm |
|
|
|
|
|
RUN python -c "\ |
|
from transformers import AutoTokenizer, AutoModel; \ |
|
print('Downloading deepset/deberta-v3-base-squad2...'); \ |
|
AutoTokenizer.from_pretrained('deepset/deberta-v3-base-squad2'); \ |
|
AutoModel.from_pretrained('deepset/deberta-v3-base-squad2'); \ |
|
print('Downloading distilbert-base-uncased...'); \ |
|
AutoTokenizer.from_pretrained('distilbert-base-uncased'); \ |
|
AutoModel.from_pretrained('distilbert-base-uncased')" |
|
|
|
|
|
FROM python:3.12-slim |
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY --from=builder /tmp/huggingface /tmp/huggingface |
|
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages |
|
COPY --from=builder /usr/local/bin /usr/local/bin |
|
|
|
|
|
RUN mkdir -p /tmp/uploads && chmod -R 777 /tmp/uploads /tmp/huggingface |
|
|
|
|
|
ENV PYTHONUNBUFFERED=1 |
|
ENV UPLOAD_FOLDER=/tmp/uploads |
|
ENV TRANSFORMERS_CACHE=/tmp/huggingface |
|
ENV HF_HOME=/tmp/huggingface |
|
|
|
|
|
RUN mkdir -p .streamlit && \ |
|
echo '[server]\n\ |
|
enableCORS=false\n\ |
|
enableXsrfProtection=false\n' > .streamlit/config.toml |
|
|
|
|
|
COPY . . |
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ |
|
CMD curl -f http://localhost:7860/_stcore/health || exit 1 |
|
|
|
|
|
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"] |