-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathDockerfile
More file actions
225 lines (202 loc) · 6.31 KB
/
Copy pathDockerfile
File metadata and controls
225 lines (202 loc) · 6.31 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
FROM python:3.12-slim
# Set platform for multi-arch builds
ARG TARGETPLATFORM
ARG NODE_MAJOR=20
ARG USE_CHINA_MIRROR=false
ARG USE_TORCH_CPU=true
ARG SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0.dev0
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
IN_DOCKER=true \
VIBESURF_WORKSPACE=/data/vibesurf_workspace \
DISPLAY=:99 \
RESOLUTION=1440x900x24 \
PLAYWRIGHT_BROWSERS_PATH=/ms-browsers \
DEBIAN_FRONTEND=noninteractive \
GTK_IM_MODULE=fcitx \
QT_IM_MODULE=fcitx \
XMODIFIERS=@im=fcitx \
DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/session_bus_socket
# Use China mirror for faster builds in China (set USE_CHINA_MIRROR=true)
RUN if [ "$USE_CHINA_MIRROR" = "true" ]; then \
sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources; \
fi
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# Basic utilities
wget \
curl \
git \
unzip \
vim \
netcat-traditional \
gnupg \
ca-certificates \
# Browser dependencies
xvfb \
libxss1 \
libnss3 \
libnspr4 \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
xdg-utils \
fonts-liberation \
fonts-dejavu \
fonts-dejavu-core \
fonts-dejavu-extra \
fontconfig \
# Chinese fonts
fonts-noto-cjk \
fonts-noto-cjk-extra \
fonts-wqy-microhei \
fonts-wqy-zenhei \
# Input method framework and Chinese input
fcitx5 \
fcitx5-chinese-addons \
fcitx5-frontend-gtk3 \
fcitx5-frontend-gtk2 \
fcitx5-frontend-qt5 \
fcitx5-config-qt \
fcitx5-module-xorg \
im-config \
# VNC dependencies
dbus \
xauth \
x11vnc \
tigervnc-tools \
# Process management
supervisor \
net-tools \
procps \
# Python numpy dependencies
python3-numpy \
# FFmpeg for video processing
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install noVNC for web-based VNC access
RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
&& git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html
# Install Node.js using NodeSource PPA
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install nodejs -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Verify installations
RUN node -v && npm -v && npx -v && ffmpeg -version
# Install uv package manager
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Add uv to PATH
ENV PATH="/root/.local/bin:$PATH"
# Verify uv installation
RUN uv --version
# Set up working directory
WORKDIR /app
# Copy project files
COPY pyproject.toml README.md LICENSE ./
COPY vibe_surf ./vibe_surf
# Build frontend
WORKDIR /app/vibe_surf/frontend
RUN if [ "$USE_CHINA_MIRROR" = "true" ]; then \
npm config set registry https://registry.npmmirror.com; \
fi && \
npm ci && \
npm run build && \
mkdir -p ../backend/frontend && \
cp -r build/* ../backend/frontend/
# Back to app directory and clean up frontend source code to reduce image size
WORKDIR /app
RUN rm -rf /app/vibe_surf/frontend
# Set version for setuptools-scm (since .git is excluded in .dockerignore)
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION}
# Install VibeSurf using uv
RUN uv venv --python 3.12 /opt/venv && \
. /opt/venv/bin/activate && \
if [ "$USE_CHINA_MIRROR" = "true" ] && [ "$USE_TORCH_CPU" = "true" ]; then \
uv pip install -e . --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match; \
elif [ "$USE_CHINA_MIRROR" = "true" ]; then \
uv pip install -e . --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple; \
elif [ "$USE_TORCH_CPU" = "true" ]; then \
uv pip install -e . --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match; \
else \
uv pip install -e .; \
fi
# Install playwright
RUN . /opt/venv/bin/activate && \
if [ "$USE_CHINA_MIRROR" = "true" ]; then \
uv pip install playwright --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple; \
else \
uv pip install playwright; \
fi
# Activate virtual environment by default
ENV PATH="/opt/venv/bin:$PATH"
ENV VIRTUAL_ENV="/opt/venv"
# Configure fcitx5 for Chinese input
RUN mkdir -p ~/.config/fcitx5 && \
echo "[Groups/0]\n\
Name=Default\n\
Default Layout=us\n\
DefaultIM=pinyin\n\
\n\
[Groups/0/Items/0]\n\
Name=keyboard-us\n\
Layout=\n\
\n\
[Groups/0/Items/1]\n\
Name=pinyin\n\
Layout=\n\
\n\
[GroupOrder]\n\
0=Default" > ~/.config/fcitx5/profile && \
echo "[Hotkey]\n\
# Trigger Input Method (Shift+Space for better macOS compatibility)\n\
TriggerKeys=\n\
# Enumerate when press trigger key repeatedly\n\
EnumerateWithTriggerKeys=True\n\
# Temporally switch between first and current Input Method\n\
AltTriggerKeys=\n\
# Enumerate Input Method Forward\n\
EnumerateForwardKeys=\n\
# Enumerate Input Method Backward\n\
EnumerateBackwardKeys=\n\
# Skip first input method while enumerating\n\
EnumerateSkipFirst=False\n\
\n\
[Hotkey/TriggerKeys]\n\
0=Control+space\n\
1=Shift+space\n\
\n\
[Behavior]\n\
# Active By Default\n\
ActiveByDefault=False\n\
# Share Input State\n\
ShareInputState=No" > ~/.config/fcitx5/config
# Install playwright browsers (after activating venv)
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH && \
/opt/venv/bin/python -m playwright install chromium --with-deps
# Set up supervisor configuration
RUN mkdir -p /var/log/supervisor /var/log/vibesurf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Expose ports
# 9335: VibeSurf backend
# 6080: noVNC (web-based VNC)
# 5901: VNC server
EXPOSE 9335 6080 5901
# Default command
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]