File size: 1,252 Bytes
3fb60aa
 
 
4ff35c1
3fb60aa
e0e08d6
3fb60aa
e0e08d6
 
3fb60aa
 
 
 
e0e08d6
3fb60aa
4ff35c1
3fb60aa
 
4ff35c1
e0e08d6
4ff35c1
e0e08d6
3fb60aa
4ff35c1
3fb60aa
4ff35c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3fb60aa
 
 
4ff35c1
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
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV DISPLAY=:1

# 安裝必要套件
RUN apt-get update && apt-get install -y \
    xfce4 \
    xfce4-terminal \
    tigervnc-standalone-server \
    tigervnc-common \
    novnc \
    websockify \
    dbus-x11 \
    supervisor \
    net-tools \
    && rm -rf /var/lib/apt/lists/*

# 設定 VNC 密碼
RUN mkdir -p /root/.vnc && \
    echo "password" | vncpasswd -f > /root/.vnc/passwd && \
    chmod 600 /root/.vnc/passwd

# 建立 VNC 配置
RUN echo '#!/bin/bash\n\
vncserver -kill :1 || true\n\
rm -rf /tmp/.X1-lock /tmp/.X11-unix/X1\n\
vncserver :1 -geometry 1280x800 -depth 24 -SecurityTypes None' > /start-vnc.sh && \
    chmod +x /start-vnc.sh

# 建立網頁 VNC 啟動腳本
RUN echo '#!/bin/bash\n\
websockify --web=/usr/share/novnc/ --wrap-mode=ignore 6080 localhost:5901' > /start-novnc.sh && \
    chmod +x /start-novnc.sh

# 建立主啟動腳本
RUN echo '#!/bin/bash\n\
echo "Starting VNC server..."\n\
/start-vnc.sh\n\
echo "Starting noVNC server..."\n\
/start-novnc.sh &\n\
echo "VNC Desktop started successfully!"\n\
echo "VNC Port: 5901, noVNC Port: 6080"\n\
tail -f /dev/null' > /start-desktop.sh && \
    chmod +x /start-desktop.sh

EXPOSE 5901 6080

CMD ["/start-desktop.sh"]