Skip to content

Commit 4d2c20a

Browse files
committed
impl docker for gui demo
1 parent d7cf486 commit 4d2c20a

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

Dockerfile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
###############################################
2+
# Stage 1: Build the SvelteKit GUI (Node)
3+
###############################################
4+
FROM node:22-bookworm-slim AS gui-builder
5+
6+
WORKDIR /app/gui
7+
8+
# Install GUI deps with good cache utilization
9+
COPY gui/package.json gui/package-lock.json ./
10+
RUN npm ci
11+
12+
# Build the GUI
13+
COPY gui/ .
14+
ENV PUBLIC_BASE_URL=
15+
RUN npm run build
16+
17+
18+
###############################################
19+
# Stage 2: Runtime with CUDA + Pixi
20+
###############################################
21+
FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
22+
23+
ENV DEBIAN_FRONTEND=noninteractive
24+
25+
# System dependencies commonly needed by CV/ML stacks
26+
RUN apt-get update && apt-get install -y --no-install-recommends \
27+
curl \
28+
ca-certificates \
29+
git \
30+
build-essential \
31+
pkg-config \
32+
ffmpeg \
33+
libgl1 \
34+
libglib2.0-0 \
35+
libxrender1 \
36+
libxext6 \
37+
libsm6 \
38+
&& rm -rf /var/lib/apt/lists/*
39+
40+
# Install Pixi (https://pixi.sh)
41+
RUN curl -fsSL https://pixi.sh/install.sh | bash -s -- -y \
42+
&& echo 'export PATH="/root/.pixi/bin:$PATH"' >> /root/.bashrc
43+
ENV PATH="/root/.pixi/bin:${PATH}"
44+
45+
WORKDIR /app
46+
47+
RUN mkdir -p /app/gui
48+
# Copy prebuilt GUI from the builder image to avoid building at runtime
49+
COPY --from=gui-builder /app/gui/build /app/gui/build
50+
51+
# Configure local model caches (kept inside the project tree)
52+
ENV HF_HOME=/app/pretrained_models/hf
53+
ENV TORCH_HOME=/app/pretrained_models/torch
54+
ENV OLLAMA_HOST=http://localhost:11434
55+
ENV OPENAI_API_KEY=
56+
ENV AZURE_OPENAI_URL=
57+
ENV CONFIG=config/refcoco.yaml
58+
ENV MODEL_CONFIG=config/model_config.yaml
59+
ENV PYTHONUNBUFFERED=1
60+
61+
# Resolve and install the environment
62+
COPY config /app/config
63+
COPY module_repos /app/module_repos
64+
COPY pretrained_models /app/pretrained_models
65+
COPY naver /app/naver
66+
COPY demo_gui.py /app/demo_gui.py
67+
COPY pixi.toml /app/pixi.toml
68+
COPY pyproject.toml /app/pyproject.toml
69+
COPY setup.py /app/setup.py
70+
COPY LICENSE /app/LICENSE
71+
COPY README.md /app/README.md
72+
73+
# remove the rust depdency from pixi.toml
74+
RUN sed -i '/rust = { version = "==1\.78\.0\.dev20240310", channel = "conda-forge\/label\/rust_dev" }/d' pixi.toml
75+
76+
# install rust-nighly 1.80 seperately
77+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain nightly-2024-08-15
78+
ENV PATH="/root/.cargo/bin:${PATH}"
79+
RUN pixi install -v && pixi clean cache -y
80+
81+
# Expose the GUI port
82+
EXPOSE 8000
83+
84+
# Run the FastAPI GUI (serves prebuilt SvelteKit under /)
85+
CMD pixi run python demo_gui.py --base_config "$CONFIG" --model_config "$MODEL_CONFIG"

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ We're working on the following TODOs:
4949
- [ ] Support more LLMs.
5050
- [ ] Video demo & slides presentation.
5151

52+
## Docker (GUI Demo)
53+
54+
We provide a Docker image for the GUI demo.
55+
56+
```bash
57+
docker run --runtime=nvidia --gpus=all -p <GUI-PORT>:8000 -e OPENAI_API_KEY=<OPENAI-API-KEY> -e AZURE_OPENAI_URL=<AZURE-OPENAI-URL> controlnet/naver:latest
58+
```
59+
60+
The GUI will be available at `http://0.0.0.0:<GUI-PORT>`. See details below for more information.
61+
5262
## Installation
5363

5464
### Requirements

0 commit comments

Comments
 (0)