Update Dockerfile
Browse files- Dockerfile +38 -30
Dockerfile
CHANGED
|
@@ -1,30 +1,38 @@
|
|
| 1 |
-
# Base image with Python and Pytorch
|
| 2 |
-
FROM python:3.11-slim
|
| 3 |
-
|
| 4 |
-
# Install system dependencies
|
| 5 |
-
RUN apt-get update && apt-get install -y \
|
| 6 |
-
tesseract-ocr \
|
| 7 |
-
libglib2.0-0 \
|
| 8 |
-
libsm6 \
|
| 9 |
-
libxext6 \
|
| 10 |
-
libxrender-dev \
|
| 11 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
-
|
| 13 |
-
# Set
|
| 14 |
-
WORKDIR /app
|
| 15 |
-
|
| 16 |
-
# Copy requirements
|
| 17 |
-
COPY requirements.txt .
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Base image with Python and Pytorch (swap slim for full if more libs needed)
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# Install system dependencies
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
tesseract-ocr \
|
| 7 |
+
libglib2.0-0 \
|
| 8 |
+
libsm6 \
|
| 9 |
+
libxext6 \
|
| 10 |
+
libxrender-dev \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
# Set working directory
|
| 14 |
+
WORKDIR /app
|
| 15 |
+
|
| 16 |
+
# Copy requirements and install them
|
| 17 |
+
COPY requirements.txt .
|
| 18 |
+
|
| 19 |
+
# Install Python dependencies — add torch explicitly
|
| 20 |
+
RUN pip install --no-cache-dir torch transformers uvicorn fastapi pdfplumber pytesseract newspaper3k
|
| 21 |
+
|
| 22 |
+
# Create model cache directory with full permissions
|
| 23 |
+
RUN mkdir -p /app/model && chmod -R 777 /app/model
|
| 24 |
+
|
| 25 |
+
# Set TRANSFORMERS_CACHE env var for caching models to /app/model
|
| 26 |
+
ENV TRANSFORMERS_CACHE=/app/model
|
| 27 |
+
|
| 28 |
+
# Download and cache T5 model at build time
|
| 29 |
+
RUN python -c "from transformers import pipeline; pipeline('summarization', model='t5-base', cache_dir='/app/model')"
|
| 30 |
+
|
| 31 |
+
# Copy your application code into container
|
| 32 |
+
COPY app/ .
|
| 33 |
+
|
| 34 |
+
# Expose your application port
|
| 35 |
+
EXPOSE 7860
|
| 36 |
+
|
| 37 |
+
# Run the FastAPI application with Uvicorn
|
| 38 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|