playwebit-t5-api / Dockerfile
mike23415's picture
Update Dockerfile
916aef5 verified
raw
history blame
1.02 kB
# Use a slim official Python image
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Install system dependencies for PyPDF2, python-pptx, etc.
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libfreetype6-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Set a writable cache directory for Hugging Face models
ENV HF_HOME=/app/hf_cache
RUN mkdir -p /app/hf_cache
# Pre-download T5-Base model and tokenizer
RUN python -c "from transformers import T5Tokenizer, T5ForConditionalGeneration; T5Tokenizer.from_pretrained('t5-base'); T5ForConditionalGeneration.from_pretrained('t5-base')"
# Copy the entire application
COPY . .
# Expose application port
EXPOSE 7860
# Run Gunicorn with logging (2 workers for concurrency)
CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:7860", "--log-level", "info", "app:app"]