forked from pavelzbornik/whisperX-FastAPI
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockerfile
More file actions
49 lines (40 loc) · 1.74 KB
/
Copy pathdockerfile
File metadata and controls
49 lines (40 loc) · 1.74 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
FROM nvidia/cuda:13.0.1-base-ubuntu22.04
ENV PYTHON_VERSION=3.11
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
# Install dependencies and clean up in the same layer
# hadolint ignore=DL3008
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y update \
&& apt-get -y install --no-install-recommends \
python3.11=3.11.0~rc1-1~22.04 \
git \
ffmpeg=7:4.4.2-0ubuntu0.22.04.1 \
libcudnn9-cuda-12=9.8.0.87-1 \
libatomic1 \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& ln -s -f /usr/bin/python${PYTHON_VERSION} /usr/bin/python3 \
&& ln -s -f /usr/bin/python${PYTHON_VERSION} /usr/bin/python
# Install UV for package management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
# Copy project files
COPY pyproject.toml .
COPY uv.lock .
COPY app app/
COPY tests tests/
COPY app/gunicorn_logging.conf .
# Install Python dependencies using UV with pyproject.toml
# UV automatically selects CUDA 12.8 wheels on Linux
RUN uv sync --frozen --no-dev \
&& uv pip install --system ctranslate2==4.6.0 \
&& rm -rf /root/.cache /tmp/* /root/.uv /var/cache/* \
&& find /usr/local -type d -name '__pycache__' -exec rm -rf {} + 2>/dev/null || true \
&& find /usr/local -type f -name '*.pyc' -delete \
&& find /usr/local -type f -name '*.pyo' -delete
EXPOSE 8000
# Health check to verify the application is responsive
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl --fail http://localhost:8000/health || exit 1
ENTRYPOINT ["uv", "run", "--no-sync", "gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--timeout", "0", "--log-config", "gunicorn_logging.conf", "app.main:app", "-k", "uvicorn.workers.UvicornWorker"]