File size: 1,006 Bytes
77370a4
 
a2682b3
 
 
 
 
 
 
 
77370a4
 
 
 
 
 
a2682b3
77370a4
a2682b3
 
 
fc4aec6
a2682b3
77370a4
fc4aec6
 
 
 
 
a2682b3
77370a4
a2682b3
 
 
 
 
77370a4
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
FROM python:3.12-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpq-dev \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Add a non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

# Copy and install Python dependencies
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Pre-download Spacy model
RUN python -m spacy download pt_core_news_md

# Pre-download T5 models
RUN python -c "from transformers import T5Tokenizer, T5ForConditionalGeneration; \
    T5Tokenizer.from_pretrained('unicamp-dl/ptt5-base-portuguese-vocab'); \
    T5ForConditionalGeneration.from_pretrained('recogna-nlp/ptt5-base-summ')"

# Copy application code
COPY --chown=user . /app

# Expose the application port
EXPOSE 7860

# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]