-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathDockerfile
42 lines (30 loc) · 1.32 KB
/
Dockerfile
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
# Use a base image with CUDA support and the desired Python version
FROM python:3.12-slim-bookworm
ARG CPU_ONLY=false
WORKDIR /app
RUN apt-get update \
&& apt-get install -y redis-server libgl1 libglib2.0-0 curl wget git procps \
&& apt-get clean
# Install Poetry and configure it
RUN pip install poetry \
&& poetry config virtualenvs.create false
COPY pyproject.toml poetry.lock ./
# Install dependencies before torch
RUN poetry install --no-interaction --no-root
# Install PyTorch separately based on CPU_ONLY flag
RUN if [ "$CPU_ONLY" = "true" ]; then \
pip install --no-cache-dir torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu; \
else \
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121; \
fi
ENV HF_HOME=/tmp/ \
TORCH_HOME=/tmp/ \
OMP_NUM_THREADS=4
RUN python -c 'from docling.pipeline.standard_pdf_pipeline import StandardPdfPipeline; artifacts_path = StandardPdfPipeline.download_models_hf(force=True);'
# Pre-download EasyOCR models in compatible groups
RUN python -c 'import easyocr; \
reader = easyocr.Reader(["fr", "de", "es", "en", "it", "pt"], gpu=True); \
print("EasyOCR models downloaded successfully")'
COPY . .
EXPOSE 8080
CMD ["poetry", "run", "uvicorn", "--port", "8080", "--host", "0.0.0.0", "main:app"]