-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
96 lines (77 loc) · 4.79 KB
/
Copy pathDockerfile
File metadata and controls
96 lines (77 loc) · 4.79 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
# ─────────────────────────────────────────────────────────────────────
# Director-Class AI — Production Docker Image
# © 1998-2026 Miroslav Sotek. All rights reserved.
# License: Apache-2.0
# ─────────────────────────────────────────────────────────────────────
#
# Build:
# docker build -t director-ai .
#
# Run:
# docker run -p 8080:8080 director-ai
# docker run -p 8080:8080 -e DIRECTOR_USE_NLI=true director-ai
#
# Multi-stage build: builder (compile) + runtime (slim)
# ─────────────────────────────────────────────────────────────────────
# ── Stage 1: Builder ────────────────────────────────────────────────
FROM rust:1.95.0-slim@sha256:e14e87345b4d5964ddcc3491d27ee046a0f23820f340c3c1e24da6880141f7c0 AS rust-toolchain
FROM python:3.11-slim@sha256:d6e4d224f70f9e0172a06a3a2eba2f768eb146811a349278b38fff3a36463b47 AS builder
WORKDIR /build
ENV CARGO_HOME=/usr/local/cargo \
RUSTUP_HOME=/usr/local/rustup \
PATH="/usr/local/cargo/bin:${PATH}"
COPY --from=rust-toolchain /usr/local/cargo /usr/local/cargo
COPY --from=rust-toolchain /usr/local/rustup /usr/local/rustup
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential=12.12 ca-certificates=20250419 \
&& rm -rf /var/lib/apt/lists/*
COPY pyproject.toml setup.py README.md LICENSE NOTICE.md ./
COPY src/ src/
COPY packages/ packages/
COPY requirements/ requirements/
COPY backfire-kernel/ backfire-kernel/
# The production server image composes TWO wheels since the D1 re-slice
# (2026-07-16): the Apache-2.0 free core wheel (sliced by the setup.py
# build hook) plus the BUSL-1.1 director-ai-pro overlay that carries the
# server surface. The image label already declares Apache-2.0 AND BUSL-1.1;
# production use of the pro modules stays licence-gated by BUSL.
ARG EXTRAS="server"
ARG REQUIREMENTS="requirements/docker-server.txt"
ARG BUILD_REQUIREMENTS="requirements/docker-build.txt"
RUN python -m pip install --no-cache-dir --require-hashes --no-deps --prefix=/install -r "$BUILD_REQUIREMENTS" \
&& python -m pip install --no-cache-dir --require-hashes --no-deps --prefix=/install -r "$REQUIREMENTS" \
&& PYTHONPATH=/install/lib/python3.11/site-packages PATH="/install/bin:${PATH}" \
maturin build --release --manifest-path backfire-kernel/crates/backfire-ffi/Cargo.toml --out /tmp/backfire-wheel \
&& PYTHONPATH=/install/lib/python3.11/site-packages \
python -m installer --prefix=/install /tmp/backfire-wheel/backfire_kernel-*.whl \
&& PYTHONPATH=/install/lib/python3.11/site-packages PATH="/install/bin:${PATH}" \
python -m build --wheel --no-isolation --outdir /tmp/director-wheel . \
&& PYTHONPATH=/install/lib/python3.11/site-packages \
python -m installer --prefix=/install /tmp/director-wheel/director_ai-*-py3-none-any.whl \
&& PYTHONPATH=/install/lib/python3.11/site-packages PATH="/install/bin:${PATH}" \
python -m build --wheel --no-isolation --outdir /tmp/director-wheel-pro packages/director-ai-pro \
&& PYTHONPATH=/install/lib/python3.11/site-packages \
python -m installer --prefix=/install /tmp/director-wheel-pro/director_ai_pro-*-py3-none-any.whl
# ── Stage 2: Runtime ────────────────────────────────────────────────
FROM python:3.11-slim@sha256:d6e4d224f70f9e0172a06a3a2eba2f768eb146811a349278b38fff3a36463b47
LABEL maintainer="Miroslav Sotek <protoscience@anulum.li>"
LABEL description="Director-AI — Real-time LLM hallucination guardrail"
LABEL org.opencontainers.image.source="https://github.com/anulum/director-ai"
LABEL org.opencontainers.image.license="Apache-2.0 AND BUSL-1.1"
WORKDIR /app
COPY --from=builder /install /usr/local
COPY src/ src/
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
DIRECTOR_LOG_LEVEL=INFO \
DIRECTOR_SERVER_HOST=0.0.0.0 \
DIRECTOR_SERVER_PORT=8080
RUN adduser --disabled-password --gecos "" appuser \
&& mkdir -p /app/director-models/_uploads \
&& chown -R appuser:appuser /app/director-models
USER appuser
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --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"]