Update Dockerfile
Browse files- Dockerfile +23 -17
Dockerfile
CHANGED
|
@@ -2,7 +2,7 @@ FROM ubuntu:22.04
|
|
| 2 |
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 4 |
|
| 5 |
-
# Install
|
| 6 |
RUN apt update && apt upgrade -y && \
|
| 7 |
apt install -y \
|
| 8 |
sudo \
|
|
@@ -19,43 +19,49 @@ RUN apt update && apt upgrade -y && \
|
|
| 19 |
software-properties-common \
|
| 20 |
build-essential \
|
| 21 |
procps \
|
| 22 |
-
apache2 \
|
| 23 |
xz-utils \
|
| 24 |
net-tools
|
| 25 |
|
| 26 |
# Clean up
|
| 27 |
RUN apt clean && rm -rf /var/lib/apt/lists/*
|
| 28 |
|
| 29 |
-
# Install Node.js v22 and
|
| 30 |
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
|
| 31 |
apt install -y nodejs && npm install -g npm
|
| 32 |
|
| 33 |
# Install speedtest-cli
|
| 34 |
RUN pip3 install speedtest-cli
|
| 35 |
|
| 36 |
-
# Create user draco with password
|
| 37 |
RUN useradd -m -s /bin/bash draco && echo "draco:draco" | chpasswd && usermod -aG sudo draco
|
| 38 |
RUN usermod -u 1000 draco
|
| 39 |
|
| 40 |
-
# SSH
|
| 41 |
RUN mkdir -p /home/draco/.ssh && \
|
| 42 |
ssh-keygen -t rsa -f /home/draco/.ssh/id_rsa -N '' && \
|
| 43 |
chown -R draco:draco /home/draco/.ssh
|
| 44 |
|
|
|
|
| 45 |
USER draco
|
| 46 |
WORKDIR /home/draco
|
| 47 |
|
| 48 |
-
#
|
| 49 |
-
RUN echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
EXPOSE 7860
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
CMD bash -c
|
| 54 |
-
while true; do \
|
| 55 |
-
tmate -S /tmp/tmate.sock new-session -d; \
|
| 56 |
-
tmate -S /tmp/tmate.sock wait tmate-ready; \
|
| 57 |
-
sleep 10; \
|
| 58 |
-
while pgrep -f "tmate -S /tmp/tmate.sock" > /dev/null; do sleep 5; done; \
|
| 59 |
-
echo "Tmate exited. Restarting..."; \
|
| 60 |
-
done & \
|
| 61 |
-
python3 -m http.server 7860'
|
|
|
|
| 2 |
|
| 3 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 4 |
|
| 5 |
+
# Install required packages
|
| 6 |
RUN apt update && apt upgrade -y && \
|
| 7 |
apt install -y \
|
| 8 |
sudo \
|
|
|
|
| 19 |
software-properties-common \
|
| 20 |
build-essential \
|
| 21 |
procps \
|
|
|
|
| 22 |
xz-utils \
|
| 23 |
net-tools
|
| 24 |
|
| 25 |
# Clean up
|
| 26 |
RUN apt clean && rm -rf /var/lib/apt/lists/*
|
| 27 |
|
| 28 |
+
# Install Node.js v22 and npm
|
| 29 |
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
|
| 30 |
apt install -y nodejs && npm install -g npm
|
| 31 |
|
| 32 |
# Install speedtest-cli
|
| 33 |
RUN pip3 install speedtest-cli
|
| 34 |
|
| 35 |
+
# Create user 'draco' with password and sudo rights
|
| 36 |
RUN useradd -m -s /bin/bash draco && echo "draco:draco" | chpasswd && usermod -aG sudo draco
|
| 37 |
RUN usermod -u 1000 draco
|
| 38 |
|
| 39 |
+
# Setup SSH keys for draco user
|
| 40 |
RUN mkdir -p /home/draco/.ssh && \
|
| 41 |
ssh-keygen -t rsa -f /home/draco/.ssh/id_rsa -N '' && \
|
| 42 |
chown -R draco:draco /home/draco/.ssh
|
| 43 |
|
| 44 |
+
# Switch to draco user
|
| 45 |
USER draco
|
| 46 |
WORKDIR /home/draco
|
| 47 |
|
| 48 |
+
# Create the tmate launcher script that will run in a loop
|
| 49 |
+
RUN echo '#!/bin/bash\n\
|
| 50 |
+
while true; do\n\
|
| 51 |
+
echo "[tmate-log] Launching new tmate session..." | tee /home/draco/tmate.txt;\n\
|
| 52 |
+
tmate -S /tmp/tmate.sock new-session -d;\n\
|
| 53 |
+
tmate -S /tmp/tmate.sock wait tmate-ready;\n\
|
| 54 |
+
echo "[tmate-log] Session Ready: $(tmate -S /tmp/tmate.sock display -p \"#{tmate_ssh}\")" | tee -a /home/draco/tmate.txt;\n\
|
| 55 |
+
echo "[tmate-log] Web URL: $(tmate -S /tmp/tmate.sock display -p \"#{tmate_web}\")" | tee -a /home/draco/tmate.txt;\n\
|
| 56 |
+
echo "[tmate-log] Monitoring connection..." | tee -a /home/draco/tmate.txt;\n\
|
| 57 |
+
while pgrep -f "tmate -S /tmp/tmate.sock" > /dev/null; do sleep 5; done;\n\
|
| 58 |
+
echo "[tmate-log] ⚠️ Connection lost. Reconnecting in 5 seconds..." | tee -a /home/draco/tmate.txt;\n\
|
| 59 |
+
sleep 5;\n\
|
| 60 |
+
done\n' > /home/draco/run_tmate.sh
|
| 61 |
+
|
| 62 |
+
RUN chmod +x /home/draco/run_tmate.sh
|
| 63 |
+
|
| 64 |
EXPOSE 7860
|
| 65 |
|
| 66 |
+
# Start the tmate loop script in background and python http server on port 7860
|
| 67 |
+
CMD bash -c "/home/draco/run_tmate.sh & python3 -m http.server 7860"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|