Create Dockerfile
Browse files- Dockerfile +82 -0
Dockerfile
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ubuntu:22.04
|
| 2 |
+
|
| 3 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 4 |
+
|
| 5 |
+
RUN apt update && apt install -y \
|
| 6 |
+
bash \
|
| 7 |
+
curl \
|
| 8 |
+
ca-certificates \
|
| 9 |
+
python3 \
|
| 10 |
+
procps \
|
| 11 |
+
iproute2 \
|
| 12 |
+
net-tools \
|
| 13 |
+
coreutils \
|
| 14 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
+
|
| 16 |
+
WORKDIR /root
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
|
| 19 |
+
# Web app that shows sshx link (no auto-refresh)
|
| 20 |
+
RUN printf '%s\n' \
|
| 21 |
+
'from http.server import BaseHTTPRequestHandler, HTTPServer' \
|
| 22 |
+
'import os' \
|
| 23 |
+
'' \
|
| 24 |
+
'PORT = 7860' \
|
| 25 |
+
'LINK_FILE = "/tmp/sshx_link.txt"' \
|
| 26 |
+
'' \
|
| 27 |
+
'class Handler(BaseHTTPRequestHandler):' \
|
| 28 |
+
' def do_GET(self):' \
|
| 29 |
+
' self.send_response(200)' \
|
| 30 |
+
' self.send_header("Content-type","text/html")' \
|
| 31 |
+
' self.end_headers()' \
|
| 32 |
+
' link = "Starting sshx… please refresh the page after a few seconds."' \
|
| 33 |
+
' if os.path.exists(LINK_FILE):' \
|
| 34 |
+
' try:' \
|
| 35 |
+
' with open(LINK_FILE) as f:' \
|
| 36 |
+
' t = f.read().strip()' \
|
| 37 |
+
' if t:' \
|
| 38 |
+
' link = t' \
|
| 39 |
+
' except Exception:' \
|
| 40 |
+
' pass' \
|
| 41 |
+
'' \
|
| 42 |
+
' html = f"""<!doctype html>' \
|
| 43 |
+
'<html><head>' \
|
| 44 |
+
'<meta charset="utf-8">' \
|
| 45 |
+
'<title>Ubuntu Hacker Space</title>' \
|
| 46 |
+
'</head>' \
|
| 47 |
+
'<body style="background:#0b0b0b;color:#00ff9c;font-family:monospace;padding:20px">' \
|
| 48 |
+
'<h1>Ubuntu Hacker Space (Educational)</h1>' \
|
| 49 |
+
'<p>SSHX session:</p>' \
|
| 50 |
+
'<pre style="border:1px solid #00ff9c33;padding:12px;border-radius:10px;white-space:pre-wrap;word-break:break-word;">{link}</pre>' \
|
| 51 |
+
'<p><small>Manual refresh • Temporary • Free tier</small></p>' \
|
| 52 |
+
'</body></html>"""' \
|
| 53 |
+
' self.wfile.write(html.encode())' \
|
| 54 |
+
'' \
|
| 55 |
+
'HTTPServer(("0.0.0.0", PORT), Handler).serve_forever()' \
|
| 56 |
+
> app.py
|
| 57 |
+
|
| 58 |
+
CMD ["bash","-lc", "\
|
| 59 |
+
set -e; \
|
| 60 |
+
echo '===== UBUNTU CONTAINER STARTED ====='; \
|
| 61 |
+
echo 'Waiting for sshx link…' > /tmp/sshx_link.txt; \
|
| 62 |
+
: > /tmp/sshx_raw.log; \
|
| 63 |
+
echo 'Installing sshx…'; \
|
| 64 |
+
curl -fsSL https://sshx.io/get | sh; \
|
| 65 |
+
echo 'Starting sshx…'; \
|
| 66 |
+
( stdbuf -oL -eL sshx 2>&1 | tee -a /tmp/sshx_raw.log ) & \
|
| 67 |
+
echo 'Extracting sshx link…'; \
|
| 68 |
+
( for i in $(seq 1 600); do \
|
| 69 |
+
LINK=$(grep -Eo 'https?://sshx\\.io/s/[A-Za-z0-9]+' /tmp/sshx_raw.log | tail -n1); \
|
| 70 |
+
if [ -z \"$LINK\" ]; then \
|
| 71 |
+
RAW=$(grep -Eo 'sshx\\.io/s/[A-Za-z0-9]+' /tmp/sshx_raw.log | tail -n1); \
|
| 72 |
+
[ -n \"$RAW\" ] && LINK=\"https://$RAW\"; \
|
| 73 |
+
fi; \
|
| 74 |
+
if [ -n \"$LINK\" ]; then \
|
| 75 |
+
echo \"$LINK\" | tee /tmp/sshx_link.txt; \
|
| 76 |
+
break; \
|
| 77 |
+
fi; \
|
| 78 |
+
sleep 1; \
|
| 79 |
+
done ) & \
|
| 80 |
+
echo 'Web UI running on :7860'; \
|
| 81 |
+
python3 app.py \
|
| 82 |
+
"]
|