File size: 1,189 Bytes
e42e330
 
 
 
28b7422
 
 
 
 
aea524d
28b7422
 
 
aea524d
28b7422
 
 
13477e3
e42e330
 
 
 
 
 
 
 
 
 
 
 
 
 
f6219e4
e42e330
 
 
 
 
 
 
 
 
 
 
 
 
a5247bb
e42e330
 
375a71f
f6219e4
e42e330
a5247bb
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
FROM python:3.12-slim

WORKDIR /app

# Combining update and install to ensure proper cache handling
RUN apt-get update -y && \
    apt-get install -y --no-install-recommends \
        curl \
        poppler-utils \
        libgl1 \
        libglib2.0-0 \
        libsm6 \
        libxext6 \
        libxrender1 \
        libgomp1 \
        wget && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*

# Install poetry
RUN pip install poetry

# Configure poetry
RUN poetry config virtualenvs.create false

# Copy dependency files
COPY pyproject.toml poetry.lock* /app/

# Install dependencies
RUN poetry install --only main --no-root

# Download spacy model
RUN python -m spacy download en_core_web_trf

# Create user
RUN useradd -m -u 1000 appuser

# Copy source code
COPY --chown=appuser src /app/src
COPY --chown=appuser main.py /app/

# Change ownership
RUN chown -R appuser /app

USER appuser

EXPOSE 7860

ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV SPACY_MODEL_NAME=en_core_web_trf

CMD ["gunicorn", "src.app:app", "-k", "uvicorn.workers.UvicornWorker", "-w", "2", "--preload", "-b", "0.0.0.0:7860", "--timeout", "600", "--graceful-timeout", "180", "--keep-alive", "180"]