1+ # Extended Dockerfile combining kernel-images with DevTools frontend
2+ # This extends the kernel-images base with Browser Operator DevTools static files
3+
4+ # DevTools Frontend build stage using browser-operator-core
5+ FROM --platform=linux/amd64 ubuntu:22.04 AS devtools-builder
6+
7+ # Install required packages for DevTools frontend build
8+ RUN apt-get update && apt-get install -y \
9+ curl \
10+ git \
11+ python3 \
12+ python3-pip \
13+ python-is-python3 \
14+ wget \
15+ unzip \
16+ sudo \
17+ ca-certificates \
18+ build-essential \
19+ && rm -rf /var/lib/apt/lists/*
20+
21+ # Install Node.js 18.x
22+ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
23+ apt-get install -y nodejs && \
24+ rm -rf /var/lib/apt/lists/*
25+
26+ WORKDIR /workspace
27+
28+ # Clone depot_tools
29+ RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
30+ ENV PATH="/workspace/depot_tools:${PATH}"
31+ ENV DEPOT_TOOLS_UPDATE=0
32+
33+ # Follow README instructions exactly - fetching code
34+ RUN mkdir devtools
35+ WORKDIR /workspace/devtools
36+ RUN fetch devtools-frontend
37+
38+ # Build steps
39+ WORKDIR /workspace/devtools/devtools-frontend
40+
41+ RUN gclient sync
42+ RUN /workspace/depot_tools/ensure_bootstrap
43+
44+ # Build standard DevTools first
45+ RUN npm run build
46+
47+ # Add Browser Operator fork and switch to it
48+ RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-core.git
49+ RUN git fetch upstream
50+ RUN git checkout upstream/main
51+
52+ # Build Browser Operator version
53+ RUN npm run build
54+
55+ # ============================================================================
56+ # Use kernel-images base with DevTools integration
57+ # ============================================================================
58+ FROM docker.io/golang:1.25.0 AS server-builder
59+ WORKDIR /workspace/server
60+
61+ ARG TARGETOS
62+ ARG TARGETARCH
63+ ENV CGO_ENABLED=0
64+
65+ COPY kernel-images/server/go.mod ./
66+ COPY kernel-images/server/go.sum ./
67+ RUN go mod download
68+
69+ COPY kernel-images/server/ .
70+ RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
71+ go build -ldflags="-s -w" -o /out/kernel-images-api ./cmd/api
72+
73+ # webrtc client
74+ FROM node:22-bullseye-slim AS client
75+ WORKDIR /src
76+ COPY kernel-images/images/chromium-headful/client/package*.json ./
77+ RUN npm install
78+ COPY kernel-images/images/chromium-headful/client/ .
79+ RUN npm run build
80+
81+ # xorg dependencies
82+ FROM docker.io/ubuntu:22.04 AS xorg-deps
83+ WORKDIR /xorg
84+ ENV DEBIAN_FRONTEND=noninteractive
85+ RUN set -eux; \
86+ apt-get update; \
87+ apt-get install -y \
88+ git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
89+ && rm -rf /var/lib/apt/lists/*;
90+ COPY kernel-images/images/chromium-headful/xorg-deps/ /xorg/
91+ # build xf86-video-dummy v0.3.8 with RandR support
92+ RUN set -eux; \
93+ cd xf86-video-dummy/v0.3.8; \
94+ patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
95+ autoreconf -v --install; \
96+ ./configure; \
97+ make -j$(nproc); \
98+ make install;
99+ # build custom input driver
100+ RUN set -eux; \
101+ cd xf86-input-neko; \
102+ ./autogen.sh --prefix=/usr; \
103+ ./configure; \
104+ make -j$(nproc); \
105+ make install;
106+
107+ FROM ghcr.io/onkernel/neko/base:3.0.6-v1.0.1 AS neko
108+ # ^--- now has event.SYSTEM_PONG with legacy support to keepalive
109+
110+ # Final stage: kernel-images base + DevTools static files
111+ FROM docker.io/ubuntu:22.04
112+
113+ ENV DEBIAN_FRONTEND=noninteractive
114+ ENV DEBIAN_PRIORITY=high
115+
116+ RUN apt-get update && \
117+ apt-get -y upgrade && \
118+ apt-get -y install \
119+ # UI Requirements
120+ xvfb \
121+ xterm \
122+ xdotool \
123+ scrot \
124+ imagemagick \
125+ sudo \
126+ mutter \
127+ # Python/pyenv reqs
128+ build-essential \
129+ libssl-dev \
130+ zlib1g-dev \
131+ libbz2-dev \
132+ libreadline-dev \
133+ libsqlite3-dev \
134+ curl \
135+ git \
136+ libncursesw5-dev \
137+ xz-utils \
138+ tk-dev \
139+ libxml2-dev \
140+ libxmlsec1-dev \
141+ libffi-dev \
142+ liblzma-dev \
143+ # Network tools
144+ net-tools \
145+ netcat \
146+ # PPA req
147+ software-properties-common \
148+ # Add nginx for DevTools serving
149+ nginx \
150+ # Userland apps
151+ && apt-get install -y --no-install-recommends \
152+ libreoffice \
153+ x11-apps \
154+ xpdf \
155+ gedit \
156+ xpaint \
157+ tint2 \
158+ galculator \
159+ pcmanfm \
160+ wget \
161+ xdg-utils \
162+ libvulkan1 \
163+ fonts-liberation \
164+ unzip && \
165+ apt-get clean
166+
167+ # install ffmpeg manually since the version available in apt is from the 4.x branch due to #drama.
168+ # as of writing these static builds will be the latest 7.0.x release.
169+ RUN set -eux; \
170+ URL="https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz"; \
171+ echo "Downloading FFmpeg static build from $URL"; \
172+ curl -fsSL "$URL" -o /tmp/ffmpeg.tar.xz; \
173+ tar -xJf /tmp/ffmpeg.tar.xz -C /tmp; \
174+ install -m755 /tmp/ffmpeg-*/ffmpeg /usr/local/bin/ffmpeg; \
175+ install -m755 /tmp/ffmpeg-*/ffprobe /usr/local/bin/ffprobe; \
176+ rm -rf /tmp/ffmpeg*
177+
178+ # runtime
179+ ENV USERNAME=root
180+ RUN set -eux; \
181+ apt-get update; \
182+ apt-get install -y --no-install-recommends \
183+ wget ca-certificates python2 supervisor xclip xdotool \
184+ pulseaudio dbus-x11 xserver-xorg-video-dummy \
185+ libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx7 \
186+ gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
187+ gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
188+ gstreamer1.0-pulseaudio gstreamer1.0-omx; \
189+ #
190+ # install libxcvt0 (not available in debian:bullseye)
191+ ARCH=$(dpkg --print-architecture); \
192+ wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_${ARCH}.deb; \
193+ apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_${ARCH}.deb; \
194+ rm ./libxcvt0_0.1.2-1_${ARCH}.deb; \
195+ #
196+ # workaround for an X11 problem: http://blog.tigerteufel.de/?p=476
197+ mkdir /tmp/.X11-unix; \
198+ chmod 1777 /tmp/.X11-unix; \
199+ chown $USERNAME /tmp/.X11-unix/; \
200+ #
201+ # make directories for neko
202+ mkdir -p /etc/neko /var/www /var/log/neko \
203+ /tmp/runtime-$USERNAME \
204+ /home/$USERNAME/.config/pulse \
205+ /home/$USERNAME/.local/share/xorg; \
206+ chmod 1777 /var/log/neko; \
207+ chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \
208+ chown -R $USERNAME:$USERNAME /home/$USERNAME; \
209+ # clean up
210+ apt-get clean -y; \
211+ rm -rf /var/lib/apt/lists/* /var/cache/apt/
212+
213+ # install chromium and sqlite3 for debugging the cookies file
214+ RUN add-apt-repository -y ppa:xtradeb/apps
215+ RUN apt update -y && apt install -y chromium sqlite3
216+
217+ # setup desktop env & app
218+ ENV DISPLAY_NUM=1
219+ ENV HEIGHT=768
220+ ENV WIDTH=1024
221+ ENV WITHDOCKER=true
222+
223+ # Copy kernel-images configuration and binaries
224+ COPY kernel-images/images/chromium-headful/xorg.conf /etc/neko/xorg.conf
225+ COPY kernel-images/images/chromium-headful/neko.yaml /etc/neko/neko.yaml
226+ COPY --from=neko /usr/bin/neko /usr/bin/neko
227+ COPY --from=client /src/dist/ /var/www
228+ COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
229+ COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
230+
231+ COPY kernel-images/images/chromium-headful/image-chromium/ /
232+ COPY kernel-images/images/chromium-headful/start-chromium.sh /images/chromium-headful/start-chromium.sh
233+ RUN chmod +x /images/chromium-headful/start-chromium.sh
234+ COPY kernel-images/images/chromium-headful/wrapper.sh /wrapper.sh
235+ COPY kernel-images/images/chromium-headful/supervisord.conf /etc/supervisor/supervisord.conf
236+ COPY kernel-images/images/chromium-headful/supervisor/services/ /etc/supervisor/conf.d/services/
237+
238+ # copy the kernel-images API binary built in the builder stage
239+ COPY --from=server-builder /out/kernel-images-api /usr/local/bin/kernel-images-api
240+
241+ # ============================================================================
242+ # DevTools Integration
243+ # ============================================================================
244+
245+ # Copy DevTools static files from builder
246+ COPY --from=devtools-builder /workspace/devtools/devtools-frontend/out/Default/gen/front_end /usr/share/nginx/devtools
247+
248+ # Create DevTools nginx configuration
249+ COPY nginx-devtools.conf /etc/nginx/sites-available/devtools
250+ RUN ln -s /etc/nginx/sites-available/devtools /etc/nginx/sites-enabled/devtools && \
251+ rm /etc/nginx/sites-enabled/default
252+
253+ # Add DevTools nginx service to supervisor
254+ COPY supervisor/services/nginx-devtools.conf /etc/supervisor/conf.d/services/nginx-devtools.conf
255+
256+ # Create nginx temp directories and set permissions
257+ RUN mkdir -p /var/lib/nginx/body \
258+ /var/lib/nginx/proxy \
259+ /var/lib/nginx/fastcgi \
260+ /var/lib/nginx/uwsgi \
261+ /var/lib/nginx/scgi && \
262+ chown -R www-data:www-data /var/lib/nginx && \
263+ chown -R www-data:www-data /usr/share/nginx/devtools
264+
265+ RUN useradd -m -s /bin/bash kernel
266+
267+ ENTRYPOINT [ "/wrapper.sh" ]
0 commit comments