-
-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·113 lines (93 loc) · 3.16 KB
/
Copy pathDockerfile
File metadata and controls
executable file
·113 lines (93 loc) · 3.16 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
ARG BUILDER_IMAGE=nvidia/cuda:12.6.0-cudnn-devel-ubuntu24.04
ARG TORCH_INDEX_URL=https://download.pytorch.org/whl/cu126
ARG FORCE_CUDA=1
ARG TORCH_CUDA_ARCH_LIST="6.1;7.0;7.5;8.0;8.6;8.9;9.0"
FROM ${BUILDER_IMAGE} AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
ARG TORCH_INDEX_URL
ARG FORCE_CUDA
ARG TORCH_CUDA_ARCH_LIST
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH" \
DEBIAN_FRONTEND=noninteractive \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
FORCE_CUDA=${FORCE_CUDA} \
TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST}
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3.12 \
python3.12-venv \
python3.12-dev \
git \
ninja-build \
g++ \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN python3.12 -m venv "$VIRTUAL_ENV"
COPY requirements.txt .
RUN uv pip install --no-cache --python "$VIRTUAL_ENV/bin/python" \
--extra-index-url "${TORCH_INDEX_URL}" \
--index-strategy unsafe-best-match \
-r requirements.txt
RUN git init /tmp/detectron2 && \
cd /tmp/detectron2 && \
git remote add origin https://github.com/facebookresearch/detectron2 && \
git fetch --depth 1 origin b599f139756bd3646a26a909caf86a1a159e53a7 && \
git checkout FETCH_HEAD && \
uv pip install --no-cache --no-build-isolation \
--python "$VIRTUAL_ENV/bin/python" . && \
rm -rf /tmp/detectron2
RUN uv pip install --no-cache --python "$VIRTUAL_ENV/bin/python" pycocotools==2.0.11
FROM ubuntu:24.04 AS runtime
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH" \
HF_HOME=/app/models/.cache/huggingface \
PYTHONPATH=/app/src \
PYTHONUNBUFFERED=1 \
TRANSFORMERS_VERBOSITY=error \
TRANSFORMERS_NO_ADVISORY_WARNINGS=1 \
DEBIAN_FRONTEND=noninteractive \
NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=compute,utility
RUN apt-get update && \
apt-get install -y --no-install-recommends \
adduser \
ca-certificates \
python3.12 \
ffmpeg \
libgomp1 \
libsm6 \
libxext6 \
ocrmypdf \
pandoc \
pdftohtml \
qpdf \
tesseract-ocr-ara \
tesseract-ocr-chi-sim \
tesseract-ocr-deu \
tesseract-ocr-ell \
tesseract-ocr-fra \
tesseract-ocr-hin \
tesseract-ocr-kor \
tesseract-ocr-kor-vert \
tesseract-ocr-mya \
tesseract-ocr-rus \
tesseract-ocr-spa \
tesseract-ocr-tam \
tesseract-ocr-tha \
tesseract-ocr-tur \
tesseract-ocr-ukr \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /app/src /app/models && \
addgroup --system python && \
adduser --system --group --home /app python && \
chown -R python:python /app
WORKDIR /app
COPY --from=builder --chown=python:python /app/.venv /app/.venv
COPY --chown=python:python --chmod=755 ./start.sh ./start.sh
COPY --chown=python:python ./src/download_models.py ./src/download_models.py
COPY --chown=python:python ./src/configuration.py ./src/configuration.py
USER python
RUN python src/download_models.py
COPY --chown=python:python ./src/. ./src