This commit is contained in:
parent
e6b3569c0b
commit
238692a048
|
|
@ -1,12 +1,11 @@
|
||||||
FROM vnc-base
|
FROM vnc-base:latest
|
||||||
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive \
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
VNC_PASSWORD=123456
|
VNC_PASSWORD=123456
|
||||||
|
|
||||||
# 安装 Snap 版 Chromium
|
# 安装 Snap 版 Chromium
|
||||||
RUN snap install chromium \
|
RUN snap install chromium && ln -s /snap/bin/chromium /usr/local/bin/chromium-browser
|
||||||
&& ln -s /snap/bin/chromium /usr/local/bin/chromium-browser
|
|
||||||
|
|
||||||
RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
|
RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
|
||||||
&& git clone https://github.com/novnc/websockify.git /opt/novnc/utils/websockify
|
&& git clone https://github.com/novnc/websockify.git /opt/novnc/utils/websockify
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,87 @@
|
||||||
FROM ubuntu:22.04
|
FROM mcr.microsoft.com/playwright:v1.48.0-jammy
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive \
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
VNC_PASSWORD=123456
|
|
||||||
|
|
||||||
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources &&\
|
# ========== 安装 VNC 相关软件 ==========
|
||||||
sed -i 's@//security.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources &&\
|
RUN apt-get update && \
|
||||||
sed -i 's@//ports.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources
|
apt-get install -y \
|
||||||
|
x11vnc \
|
||||||
|
xvfb \
|
||||||
|
fluxbox \
|
||||||
|
git \
|
||||||
|
tigervnc-standalone-server \
|
||||||
|
wget \
|
||||||
|
curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# ========== 安装 noVNC ==========
|
||||||
|
RUN git clone https://github.com/novnc/noVNC.git /opt/novnc && \
|
||||||
|
git clone https://github.com/novnc/websockify.git /opt/novnc/utils/websockify
|
||||||
|
|
||||||
RUN apt-get update
|
# ========== 创建启动脚本 ==========
|
||||||
|
RUN cat > /entrypoint.sh << 'EOF'
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
RUN apt-get install -y wget curl gnupg x11vnc xvfb fluxbox git python3 snapd && rm -rf /var/lib/apt/lists/*
|
# 设置 VNC 密码(从环境变量读取)
|
||||||
|
if [ ! -z "$VNC_PASSWORD" ]; then
|
||||||
|
mkdir -p /root/.vnc
|
||||||
|
echo "$VNC_PASSWORD" | vncpasswd -f > /root/.vnc/passwd
|
||||||
|
chmod 600 /root/.vnc/passwd
|
||||||
|
VNC_SECURITY="-SecurityTypes VncAuth -PasswordFile /root/.vnc/passwd"
|
||||||
|
else
|
||||||
|
VNC_SECURITY="-SecurityTypes None"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 启动虚拟显示
|
||||||
|
Xvfb :1 -screen 0 1280x1024x24 &
|
||||||
|
export DISPLAY=:1
|
||||||
|
|
||||||
|
# 等待 Xvfb 启动
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# 启动窗口管理器
|
||||||
|
fluxbox &
|
||||||
|
|
||||||
|
# 启动 VNC 服务器(使用 tigervnc)
|
||||||
|
vncserver :1 -geometry 1280x1024 -depth 24 \
|
||||||
|
-localhost no \
|
||||||
|
-verbose \
|
||||||
|
$VNC_SECURITY || true
|
||||||
|
|
||||||
|
# 启动 noVNC Web 代理
|
||||||
|
/opt/novnc/utils/novnc_proxy --vnc localhost:5901 --listen 6080 &
|
||||||
|
|
||||||
|
# 等待服务启动
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# 获取 Playwright 安装的 Chromium 路径
|
||||||
|
CHROMIUM_PATH=$(find /ms-playwright -name "chrome" -type f -executable | head -1)
|
||||||
|
if [ -z "$CHROMIUM_PATH" ]; then
|
||||||
|
echo "Warning: Chromium not found, using system chrome"
|
||||||
|
CHROMIUM_PATH="google-chrome"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using Chromium: $CHROMIUM_PATH"
|
||||||
|
|
||||||
|
# 启动 Chromium
|
||||||
|
$CHROMIUM_PATH \
|
||||||
|
--no-sandbox \
|
||||||
|
--disable-gpu \
|
||||||
|
--remote-debugging-port=9222 \
|
||||||
|
--remote-debugging-address=0.0.0.0 \
|
||||||
|
--window-size=1280,1024 \
|
||||||
|
--disable-dev-shm-usage \
|
||||||
|
--disable-setuid-sandbox \
|
||||||
|
--user-data-dir=/tmp/chromium-profile &
|
||||||
|
|
||||||
|
# 保持容器运行
|
||||||
|
wait
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
# ========== 暴露端口 ==========
|
||||||
|
EXPOSE 6080 9222
|
||||||
|
|
||||||
|
# ========== 设置入口点 ==========
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
Loading…
Reference in New Issue