-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.gpu
More file actions
83 lines (61 loc) · 3.51 KB
/
Dockerfile.gpu
File metadata and controls
83 lines (61 loc) · 3.51 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
# ─────────────────────────────────────────────────────────────────────
# Director-Class AI — GPU Docker Image (ONNX CUDA)
# (C) 1998-2026 Miroslav Sotek. All rights reserved.
# License: GNU AGPL v3 | Commercial licensing available
# ─────────────────────────────────────────────────────────────────────
#
# Build:
# docker build -f Dockerfile.gpu -t director-ai:gpu .
#
# Run:
# docker run --gpus all -p 8080:8080 director-ai:gpu
#
# onnxruntime-gpu bundles CUDA/CuDNN; the host only needs the NVIDIA
# driver (>=535) exposed via --gpus all.
# ─────────────────────────────────────────────────────────────────────
# ── Stage 1: Install Python packages ──────────────────────────────────
FROM python:3.11-slim@sha256:d6e4d224f70f9e0172a06a3a2eba2f768eb146811a349278b38fff3a36463b47 AS builder
WORKDIR /build
COPY pyproject.toml README.md LICENSE NOTICE.md ./
COPY src/ src/
COPY requirements/ requirements/
RUN pip install --no-cache-dir --require-hashes --no-deps --prefix=/install \
-r requirements/docker-gpu.txt \
&& pip install --no-cache-dir --no-deps --prefix=/install .
# ── Stage 2: Export ONNX model ────────────────────────────────────────
FROM python:3.11-slim@sha256:d6e4d224f70f9e0172a06a3a2eba2f768eb146811a349278b38fff3a36463b47 AS model-builder
COPY --from=builder /install /usr/local
COPY src/ /app/src/
WORKDIR /app
ENV PYTHONPATH=/app/src
# optimum: build-time only for ONNX export (not in runtime image)
RUN printf 'optimum==2.1.0 --hash=sha256:bc3af32e1236a9b2c2ca1d27ed9d3ab1b6591e24c6bcd47f9671a8198a30ea88\n' \
> /tmp/optimum-req.txt \
&& pip install --no-cache-dir --no-deps --require-hashes -r /tmp/optimum-req.txt
RUN python -c "\
from director_ai.core.nli import export_onnx; \
export_onnx(output_dir='/models/onnx')"
# ── Stage 3: Runtime ──────────────────────────────────────────────────
FROM python:3.11-slim@sha256:d6e4d224f70f9e0172a06a3a2eba2f768eb146811a349278b38fff3a36463b47
LABEL maintainer="Miroslav Sotek <protoscience@anulum.li>"
LABEL description="Director-AI GPU — ONNX CUDA hallucination guardrail"
LABEL org.opencontainers.image.source="https://github.com/anulum/director-ai"
LABEL org.opencontainers.image.license="AGPL-3.0-or-later"
WORKDIR /app
COPY --from=builder /install /usr/local
COPY --from=model-builder /models /app/models
COPY src/ src/
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
DIRECTOR_LOG_LEVEL=INFO \
DIRECTOR_SERVER_HOST=0.0.0.0 \
DIRECTOR_SERVER_PORT=8080 \
DIRECTOR_USE_NLI=true \
DIRECTOR_ONNX_PATH=/app/models/onnx
RUN adduser --disabled-password --gecos "" appuser
USER appuser
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD python -c "import requests; r=requests.get('http://localhost:8080/v1/health'); r.raise_for_status()" || exit 1
ENTRYPOINT ["python", "-m", "director_ai.cli"]
CMD ["serve", "--port", "8080"]