feat(docker): browser desktop image (Selkies Wayland + headed camofox) and optional TLS proxy

Selkies baseimage (debiantrixie, digest-pinned) with camofox 1.17.0 copied
from camofox-browser:1.17.0, run headed under labwc so the desktop shows the
same Firefox the agent drives. s6 service waits for wayland-0 and depends on
svc-de and svc-dbus so shutdown persists login state. Selkies control/view
passwords derive from CAMOFOX_ACCESS_KEY. Compose defaults to the new image;
CAMOFOX_IMAGE=camofox-browser:1.17.0 switches back. Optional caddy (profile tls).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-29 02:30:55 +08:00
1 parent 3f0327ad97
commit 880cec4d23
18 files changed
+235 -12

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
# 可选 HTTPS 入口(docker-compose.yml 的 caddy 服务,profile tls;docs/runbook/browser.md §8.4)。
# 桌面模式的视频解码(WebCodecs)与剪贴板只在安全上下文(HTTPS 或 localhost)可用。
# TLS_DOMAIN 未设:自签(Caddy 内部 CA,按访问的主机名 / IP 现场签发),浏览器需手动放行或导入根证书
# (容器内 /data/caddy/pki/authorities/local/root.crt)
# TLS_DOMAIN=media.example.com + [email protected]:ACME 自动申请(80/443 需公网可达)
# TLS_UPSTREAM:反代目标,缺省 app:4380(app 不在同一 compose 网络时改)
{
auto_https disable_redirects
}
{$TLS_DOMAIN:https://} {
tls {$TLS_ISSUER:internal} {
on_demand
}
encode zstd gzip
reverse_proxy {$TLS_UPSTREAM:app:4380} {
# SSE 与桌面 WebSocket 不缓冲
flush_interval -1
}
}
+64
View File
@@ -0,0 +1,64 @@
# 浏览器桌面镜像(原站视图桌面模式,docs/design/webtop-remote-browser.md、docs/runbook/browser.md §8):
# linuxserver baseimage-selkies(Webtop 4.0 的底座:pixelflux + labwc Wayland 桌面 + Selkies Web 客户端)
# + camofox-browser 1.17.0 以有头模式跑在同一个 Wayland 会话里 → 桌面上看到的就是 Agent 驱动的那个 Firefox。
#
# camofox 部分不重新下载:直接从旧镜像 camofox-browser:1.17.0(docker/camofox/Dockerfile 构建)复制
# node、/app 与 Camoufox 浏览器包,两个镜像的 camofox 完全一致,可随时用 CAMOFOX_IMAGE 切回旧镜像。
# 手工构建:
# docker build -t camofox-browser:1.17.0 --build-context upstream=… docker/camofox # 先有旧镜像
# docker build -t umt-browser-desktop:1.17.0 docker/browser-desktop
ARG CAMOFOX_BASE=camofox-browser:1.17.0
# baseimage-selkies debiantrixie(Selkies 2.x、labwc 0.8.3,已含 fonts-noto-cjk);按 digest 锁定,升级需重新核验
ARG SELKIES_BASE=ghcr.io/linuxserver/baseimage-selkies:debiantrixie@sha256:f3ca0b10e923a603941a996ea1c3356b9527cc53163259f4e836f61fd4523e12
FROM ${CAMOFOX_BASE} AS camofox
FROM ${SELKIES_BASE}
ARG APT_MIRROR=
# 1 = 装容器内输入法 fcitx5(拼音 + mozc,缺省装;是否启动由运行时 UMT_DESKTOP_IME=fcitx5 决定)
ARG WITH_FCITX5=1
RUN if [ -n "$APT_MIRROR" ]; then sed -i "[email protected]@${APT_MIRROR}@g" /etc/apt/sources.list.d/debian.sources; fi \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
libdbus-glib-1-2 libxt6t64 libasound2t64 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 \
libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libegl1 libgl1-mesa-dri libgbm1 \
fonts-noto-cjk fonts-noto-cjk-extra fonts-noto-color-emoji fontconfig \
&& if [ "$WITH_FCITX5" = "1" ]; then \
apt-get install -y --no-install-recommends \
fcitx5 fcitx5-chinese-addons fcitx5-mozc fcitx5-frontend-gtk3 fcitx5-config-qt- ; \
fi \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*
COPY --from=camofox /usr/local/bin/node /usr/local/bin/node
COPY --from=camofox /app /opt/camofox
COPY --from=camofox /root/.cache/camoufox /opt/camoufox
COPY root/ /
LABEL org.opencontainers.image.title="umt-browser-desktop" \
org.opencontainers.image.description="camofox-browser 1.17.0 (headed, Wayland) on linuxserver baseimage-selkies" \
org.opencontainers.image.version="1.17.0"
ENV CAMOUFOX_INSTALL_DIR=/opt/camoufox \
NODE_ENV=production \
CAMOFOX_PORT=9377 \
CAMOFOX_INTERACTIVE=desktop \
MOZ_ENABLE_WAYLAND=1 \
PIXELFLUX_WAYLAND=true \
START_DOCKER=false \
NO_GAMEPAD=true \
NO_WEBCAM=true \
CUSTOM_USER=umt \
TITLE="原站视图" \
NO_DECOR=true \
HARDEN_DESKTOP=true \
HARDEN_OPENBOX=true \
# HARDEN_OPENBOX 缺省会开 RESTART_APP(看门狗每秒重跑 autostart);浏览器由 svc-camofox 管,不需要
RESTART_APP=false \
SELKIES_ENABLE_BASIC_AUTH=true \
# s6 停服务的宽限:camofox 关机要落盘登录状态(缺省 3 秒不够)
S6_SERVICES_GRACETIME=25000 \
S6_KILL_GRACETIME=5000
EXPOSE 3000 9377
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# labwc autostart(UMT 浏览器桌面):不自启应用;浏览器窗口由 svc-camofox(camofox-browser)按会话打开。
# 容器内输入法是备选(缺省用访问者本机输入法,由 Selkies 注入上屏文本);UMT_DESKTOP_IME=fcitx5 时启用
if [ "$UMT_DESKTOP_IME" = "fcitx5" ] && command -v fcitx5 >/dev/null 2>&1; then
fcitx5 -d --replace >/dev/null 2>&1 &
fi
@@ -0,0 +1,30 @@
#!/usr/bin/with-contenv bash
# UMT 浏览器桌面:在 linuxserver 的 init-selkies-config 之后、Selkies/桌面启动之前执行(root)。
# 1) Selkies 双口令:由 CAMOFOX_ACCESS_KEY 经 HMAC 派生(app 用同一算法),不另设密钥;
# 2) labwc autostart 每次覆盖(只起可选 fcitx5,不起终端等其它应用);
# 3) 登录状态目录(与旧 camofox 镜像同一个卷 /root/.camofox)交给运行用户 abc。
set -e
ENVDIR=/run/s6/container_environment
derive() { printf '%s' "$1" | openssl dgst -sha256 -hmac "$CAMOFOX_ACCESS_KEY" -r | cut -c1-48; }
if [ -n "${CAMOFOX_ACCESS_KEY}" ]; then
printf '%s' "$(derive umt-desktop/control)" > "$ENVDIR/SELKIES_BASIC_AUTH_PASSWORD"
printf '%s' "$(derive umt-desktop/view)" > "$ENVDIR/SELKIES_BASIC_AUTH_VIEWONLY_PASSWORD"
else
echo "[umt-desktop] CAMOFOX_ACCESS_KEY 未设置:桌面口令随机生成,app 无法接入桌面模式(原站视图回退截图模式)"
printf '%s' "$(openssl rand -hex 24)" > "$ENVDIR/SELKIES_BASIC_AUTH_PASSWORD"
printf '%s' "$(openssl rand -hex 24)" > "$ENVDIR/SELKIES_BASIC_AUTH_VIEWONLY_PASSWORD"
fi
# 口令只经 Selkies 自己的 basic auth 校验;nginx 层不开(设 PASSWORD 会让 nginx 只认单口令,拦掉只读口令)
printf 'true' > "$ENVDIR/SELKIES_ENABLE_BASIC_AUTH"
rm -f "$ENVDIR/PASSWORD" "$ENVDIR/PASSWD"
LABWC_DIR="$HOME/.config/labwc"
mkdir -p "$LABWC_DIR"
cp /defaults/autostart_wayland "$LABWC_DIR/autostart"
chown root:abc "$LABWC_DIR/autostart"
chmod 550 "$LABWC_DIR/autostart"
PROFILE_ROOT="$(dirname "${CAMOFOX_PROFILE_DIR:-/root/.camofox/profiles}")"
mkdir -p "${CAMOFOX_PROFILE_DIR:-/root/.camofox/profiles}"
chown -R abc:abc "$PROFILE_ROOT"
chmod 711 /root
@@ -0,0 +1 @@
oneshot
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-umt-desktop/run
@@ -0,0 +1,17 @@
#!/usr/bin/with-contenv bash
# camofox-browser 以有头模式跑在 labwc(应用合成器 wayland-0)里:桌面画面上的窗口就是 Agent 驱动的同一个 Firefox 进程。
SOCKET_PATH="${XDG_RUNTIME_DIR}/wayland-0"
until [ -e "${SOCKET_PATH}" ]; do sleep 0.5; done
export WAYLAND_DISPLAY=wayland-0
export DISPLAY=:0
export MOZ_ENABLE_WAYLAND="${MOZ_ENABLE_WAYLAND:-1}"
export CAMOFOX_INTERACTIVE=desktop
if [[ "${UMT_DESKTOP_IME,,}" == "fcitx5" ]]; then
# Wayland 下 Firefox 经 text-input-v3 接 fcitx5;不要设 GTK_IM_MODULE(会绕过 text-input-v3)
export XMODIFIERS=@im=fcitx
fi
# Selkies 的手柄/摄像头 LD_PRELOAD 不给浏览器
unset LD_PRELOAD
cd /opt/camofox
# exec:SIGTERM 直达 node,持久化插件关机落盘(docker/camofox/Dockerfile 同样的教训)
exec s6-setuidgid abc node --max-old-space-size="${MAX_OLD_SPACE_SIZE:-128}" server.js
@@ -0,0 +1 @@
longrun