File size: 2,604 Bytes
ea15582
 
 
 
39341db
359e66b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39341db
 
359e66b
39341db
359e66b
 
 
 
 
39341db
ea15582
 
39341db
359e66b
 
 
 
 
 
 
 
 
39341db
cd269fe
359e66b
 
39341db
 
 
 
 
 
 
 
 
 
 
359e66b
 
 
39341db
cd269fe
 
 
 
359e66b
39341db
ea15582
 
39341db
cd269fe
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
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8

# Install required packages including desktop, Node.js, tools
RUN apt update && apt upgrade -y && \
    apt install -y \
      sudo \
      curl \
      wget \
      git \
      gnupg \
      openssh-client \
      neofetch \
      tmate \
      python3 \
      python3-pip \
      ca-certificates \
      software-properties-common \
      build-essential \
      procps \
      xz-utils \
      net-tools \
      make \
      ffmpeg \
      nano \
      vim \
      htop \
      unzip \
      zip \
      iputils-ping \
      tree \
      lsof \
      netcat \
      tmux \
      locales \
      lxde \
      xrdp && \
    locale-gen en_US.UTF-8 && \
    apt clean && rm -rf /var/lib/apt/lists/*

# Configure XRDP to use LXDE
RUN echo "lxsession -s LXDE -e LXDE" > /etc/xrdp/startwm.sh && chmod +x /etc/xrdp/startwm.sh

# Install Node.js v22
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
    apt update && apt install -y nodejs && \
    npm install -g npm && \
    apt clean && rm -rf /var/lib/apt/lists/*

# Install speedtest-cli
RUN pip3 install --no-cache-dir speedtest-cli

# Create user 'draco' with sudo rights and fixed UID
RUN useradd -m -s /bin/bash -u 1000 draco && \
    echo "draco:draco" | chpasswd && \
    usermod -aG sudo draco

# Setup SSH keys for draco user
RUN mkdir -p /home/draco/.ssh && \
    ssh-keygen -t rsa -f /home/draco/.ssh/id_rsa -N '' && \
    chown -R draco:draco /home/draco/.ssh

# Create reconnecting tmate launcher (⚠️ NO INDENTATION inside heredoc!)
RUN cat << 'EOF' > /home/draco/run_tmate.sh
#!/bin/bash
while true; do
echo "[tmate-log] Launching new tmate session..." | tee /home/draco/tmate.txt
tmate -S /tmp/tmate.sock new-session -d
tmate -S /tmp/tmate.sock wait tmate-ready
echo "[tmate-log] SSH: $(tmate -S /tmp/tmate.sock display -p "#{tmate_ssh}")" | tee -a /home/draco/tmate.txt
echo "[tmate-log] Web: $(tmate -S /tmp/tmate.sock display -p "#{tmate_web}")" | tee -a /home/draco/tmate.txt
echo "[tmate-log] Monitoring connection..." | tee -a /home/draco/tmate.txt
while pgrep -f "tmate -S /tmp/tmate.sock" > /dev/null; do
sleep 5
done
echo "[tmate-log] ⚠️ Connection lost. Reconnecting in 5 seconds..." | tee -a /home/draco/tmate.txt
sleep 5
done
EOF

RUN chmod +x /home/draco/run_tmate.sh && chown draco:draco /home/draco/run_tmate.sh

# Switch to draco user
USER draco
WORKDIR /home/draco

# Expose ports: XRDP and HTTP
EXPOSE 3389 7890

# Start tmate reconnect loop and HTTP server
CMD bash -c "/home/draco/run_tmate.sh & python3 -m http.server 7890"