-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (42 loc) · 2 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (42 loc) · 2 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
# ---- CPU target ----
FROM python:3.12-slim AS cpu
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 libglib2.0-0 libsm6 libxrender1 libxext6 \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -r clockd && useradd -r -g clockd -d /app -s /sbin/nologin clockd
WORKDIR /app
COPY pyproject.toml .
COPY src/ src/
COPY configs/server.yaml configs/server.yaml
# Install CPU-only PyTorch first (much smaller than the default CUDA bundle),
# then install the project which will reuse the existing torch.
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu \
&& pip install --no-cache-dir . \
&& mkdir -p /tmp/clockd_uploads \
&& python -c "from ultralytics import YOLO; YOLO('yolo26n.pt')" \
&& chown -R clockd:clockd /app /tmp/clockd_uploads
USER clockd
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
CMD ["uvicorn", "clockd.main:app", "--host", "0.0.0.0", "--port", "8000"]
# ---- GPU target ----
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 AS gpu
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.12 python3.12-venv python3-pip \
libgl1 libglib2.0-0 libsm6 libxrender1 libxext6 \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -r clockd && useradd -r -g clockd -d /app -s /sbin/nologin clockd
WORKDIR /app
COPY pyproject.toml .
COPY src/ src/
COPY configs/server.yaml configs/server.yaml
RUN pip install --no-cache-dir . \
&& pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu124 \
&& mkdir -p /tmp/clockd_uploads \
&& chown -R clockd:clockd /app /tmp/clockd_uploads
USER clockd
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD python3 -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
CMD ["uvicorn", "clockd.main:app", "--host", "0.0.0.0", "--port", "8000"]