-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (47 loc) · 2.3 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (47 loc) · 2.3 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
FROM python:3.12-slim
# System deps: git-lfs, Node 20, and OpenCV runtime libs
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
git \
git-lfs \
curl \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# ── Python dependencies (installed as root → /usr/local/lib, accessible to all
# processes including ZeroGPU worker forks) ─────────────────────────────────
COPY eyas/requirements.txt /tmp/requirements.txt
# Try CUDA 12.4 wheel first; fall back to CPU wheel if unavailable at build time.
# ZeroGPU attaches the GPU at runtime, not during build, so CPU install is fine —
# llama-cpp-python will still find CUDA at inference time via the ZeroGPU bind-mount.
RUN pip install --no-cache-dir llama-cpp-python \
--extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124 \
|| pip install --no-cache-dir llama-cpp-python
RUN pip install --no-cache-dir -r /tmp/requirements.txt
# HF Spaces requires a non-root user
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH="/home/user/.local/bin:$PATH" \
GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_SERVER_PORT=7860
WORKDIR /app
# ── Frontend build ────────────────────────────────────────────────────────────
COPY --chown=user:user eyas/ui/frontend/package*.json ./eyas/ui/frontend/
RUN cd eyas/ui/frontend && npm ci
COPY --chown=user:user eyas/ui/frontend/ ./eyas/ui/frontend/
RUN cd eyas/ui/frontend && npm run build
# ── Application code ──────────────────────────────────────────────────────────
COPY --chown=user:user . .
# ── Pre-download models at build time ─────────────────────────────────────────
ARG HF_TOKEN=""
ENV HF_TOKEN=${HF_TOKEN}
RUN python3 scripts/download_models.py
WORKDIR /app/eyas
EXPOSE 7860
CMD ["python", "app.py"]