-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathDockerfile
More file actions
161 lines (139 loc) · 6.16 KB
/
Dockerfile
File metadata and controls
161 lines (139 loc) · 6.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# ============================================================================
# OpenARC From Scratch - Ubuntu Base + Manual Intel Setup
# NOTE:
# Newer GPUs require using the `libze` packages instead of `level-zero`.
# For Battlemage or newer, you should use `Battlemage.Dockerfile` instead.
# ============================================================================
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
# ============================================================================
# System Dependencies
# ============================================================================
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
git \
gpg \
gpg-agent \
wget \
python3 \
python3-venv \
python3-dev \
python3-pip && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
rm -rf /var/lib/apt/lists/*
# ============================================================================
# Intel GPU Drivers
# ============================================================================
RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg && \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu noble client" | \
tee /etc/apt/sources.list.d/intel-gpu-noble.list && \
apt-get update && apt-get install -y \
intel-opencl-icd \
intel-level-zero-gpu \
level-zero \
level-zero-dev && \
rm -rf /var/lib/apt/lists/*
# ============================================================================
# Intel NPU Driver
# ============================================================================
RUN apt-get update && apt-get install -y \
cmake \
build-essential \
libudev-dev && \
git clone https://github.com/intel/linux-npu-driver.git /tmp/npu-driver && \
cd /tmp/npu-driver && \
git submodule update --init --recursive && \
mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j$(nproc) && \
make install && \
ldconfig && \
cd / && rm -rf /tmp/npu-driver /var/lib/apt/lists/*
# ============================================================================
# Install uv package manager
# ============================================================================
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"
# ============================================================================
# Clone and setup OpenArc
# ============================================================================
WORKDIR /app
RUN git clone https://github.com/SearchSavior/OpenArc.git . && \
echo "OpenARC version: $(git describe --tags --always)"
# ============================================================================
# Install Python dependencies with uv
# ============================================================================
RUN uv sync && \
uv pip install "optimum-intel[openvino] @ git+https://github.com/huggingface/optimum-intel" && \
uv pip install --pre -U openvino-genai openvino-tokenizers \
--extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
# Add venv to PATH so openarc command works
ENV PATH="/app/.venv/bin:$PATH"
# ============================================================================
# Runtime Configuration
# ============================================================================
ENV NEOReadDebugKeys=1 \
OverrideGpuAddressSpace=48 \
EnableImplicitScaling=1 \
OPENARC_API_KEY=key \
OPENARC_AUTOLOAD_MODEL=""
# Create persistent config directory and symlink
RUN mkdir -p /persist && \
ln -sf /persist/openarc_config.json /app/openarc_config.json
# ============================================================================
# Build Info Logging
# ============================================================================
RUN echo "=== Build Information ===" > /app/BUILD_INFO.txt && \
echo "Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> /app/BUILD_INFO.txt && \
echo "OpenARC Version: $(git describe --tags --always)" >> /app/BUILD_INFO.txt && \
echo "" >> /app/BUILD_INFO.txt && \
echo "=== Intel Package Versions ===" >> /app/BUILD_INFO.txt && \
uv pip list | grep -E "(openvino|optimum|torch)" >> /app/BUILD_INFO.txt || true && \
echo "" >> /app/BUILD_INFO.txt && \
echo "=== System Package Versions ===" >> /app/BUILD_INFO.txt && \
dpkg -l | grep -E "intel-opencl|level-zero" | awk '{print $2 " " $3}' >> /app/BUILD_INFO.txt || true
# ============================================================================
# Startup Script
# ============================================================================
RUN cat > /usr/local/bin/start-openarc.sh <<'SCRIPT'
#!/bin/bash
set -e
echo "================================================"
echo "=== Starting OpenArc Server ==="
echo "================================================"
if [ -f /app/BUILD_INFO.txt ]; then
cat /app/BUILD_INFO.txt
echo ""
fi
echo "=== Runtime Configuration ==="
echo "Port: 8000"
echo "API Key: ${OPENARC_API_KEY:0:10}..."
echo "Auto-load Model: ${OPENARC_AUTOLOAD_MODEL:-none}"
echo ""
echo "================================================"
# Start server in background
openarc serve start --host 0.0.0.0 --port 8000 &
SERVER_PID=$!
# Auto-load model if specified
if [ -n "$OPENARC_AUTOLOAD_MODEL" ]; then
echo "Waiting for server to start..."
for i in {1..30}; do
if curl -s -f -H "Authorization: Bearer ${OPENARC_API_KEY}" http://localhost:8000/v1/models >/dev/null 2>&1; then
echo "Server ready after $i seconds"
echo "Auto-loading model: $OPENARC_AUTOLOAD_MODEL"
openarc load "$OPENARC_AUTOLOAD_MODEL" || echo "Failed to auto-load model"
break
fi
sleep 1
done
fi
# Wait for server
wait $SERVER_PID
SCRIPT
RUN chmod +x /usr/local/bin/start-openarc.sh
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f -H "Authorization: Bearer ${OPENARC_API_KEY}" http://localhost:8000/v1/models || exit 1
CMD ["/usr/local/bin/start-openarc.sh"]