File size: 1,923 Bytes
2bdf377 | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # ββββββββββββββββββββββββββββββββββββββββββββββ
# Backend Dockerfile β FastAPI + BERT (PyTorch)
# ββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
# System dependencies needed by PyTorch / transformers / Pillow
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libgl1 \
libglib2.0-0 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy dependency spec and install Python packages FIRST (layer cache)
COPY pyproject.toml ./
RUN pip install --upgrade pip \
&& pip install --no-cache-dir \
fastapi \
"uvicorn[standard]" \
torch \
transformers \
pillow \
requests \
pydantic \
"python-multipart" \
"google-genai" \
python-dotenv \
newsapi-python \
beautifulsoup4 \
serpapi \
motor \
pymongo \
"python-jose[cryptography]" \
"passlib[bcrypt]" \
email-validator \
mistralai \
slowapi \
pytesseract
# Copy application source code
COPY app/ ./app/
# Copy pre-trained BERT model directories
COPY enhanced_bert_liar_model/ ./enhanced_bert_liar_model/
COPY enhanced_bert_welfake_model/ ./enhanced_bert_welfake_model/
# Copy the server entry-point
COPY run_api.py ./
# Create logs directory
RUN mkdir -p logs
# Expose the FastAPI port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Run with uvicorn
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|