FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Asia/Jakarta RUN apt-get update && \ apt-get install -y \ curl wget nano vim git htop net-tools iputils-ping \ dnsutils sudo procps python3 python3-pip nodejs npm \ openssh-client tmux screen unzip jq build-essential \ inxi neofetch \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* RUN curl -sL https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64 -o /usr/local/bin/ttyd && \ chmod +x /usr/local/bin/ttyd RUN echo "rock5c" > /etc/hostname || true COPY fakes.sh /tmp/fakes.sh RUN chmod +x /tmp/fakes.sh && bash /tmp/fakes.sh && rm /tmp/fakes.sh RUN mkdir -p /gw && cd /gw && npm install http-proxy RUN cat > /gw/gateway.js << 'GWEOF' var http = require('http'); var httpProxy = require('http-proxy'); var DOMAIN = process.env.DOMAIN || ''; var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:3001', ws: true }); proxy.on('error', function(e, req, res) { if (res && res.writeHead) { res.writeHead(502); res.end('502'); } }); function ok(req) { if (!DOMAIN) return true; var h = (req.headers['x-real-domain'] || '') + '|' + (req.headers['x-forwarded-host'] || '') + '|' + (req.headers['host'] || ''); return h.indexOf(DOMAIN) !== -1; } var s = http.createServer(function(req, res) { if (ok(req)) { proxy.web(req, res); } else { res.writeHead(200, {'Content-Type':'text/plain'}); res.end('200 OK'); } }); s.on('upgrade', function(req, socket, head) { if (ok(req)) { proxy.ws(req, socket, head); } else { socket.destroy(); } }); s.listen(7860, function() { console.log('[GW] 7860'); }); GWEOF RUN cat > /gw/start.sh << 'SHEOF' #!/bin/bash ttyd --port 3001 --writable bash & sleep 2 cd /gw && exec node gateway.js SHEOF RUN chmod +x /gw/start.sh RUN useradd -m -s /bin/bash -u 1000 user && \ echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers USER user WORKDIR /home/user RUN echo 'export PS1='"'"'\[\033[01;32m\]\u@rock5c\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '"'"'' > .bashrc && \ echo 'export PATH=/usr/local/bin:$PATH' >> .bashrc && \ echo 'export HOSTNAME=rock5c' >> .bashrc && \ echo '' >> .bashrc && \ echo 'echo ""' >> .bashrc && \ echo 'echo -e "\033[1;36m .dBBBBP dBBBBBb dBBBBb dBP dBBBBb dBBBBP dBBBBBBP\033[0m"' >> .bashrc && \ echo 'echo -e "\033[1;36m BP BB dBP dBP \033[0m"' >> .bashrc && \ echo 'echo -e "\033[1;36m \`BBBBb dBP BB dBP dBP dBP dBP dBP dBBBP dBP \033[0m"' >> .bashrc && \ echo 'echo -e "\033[1;36m dBP dBP BB dBP dBP dBP dBP dBP dBP dBP \033[0m"' >> .bashrc && \ echo 'echo -e "\033[1;36m dBBBBP'"'"' dBBBBBBB dBBBBBP dBP dBBBBBP dBP dBP \033[0m"' >> .bashrc && \ echo 'echo ""' >> .bashrc && \ echo 'echo -e "\033[1;33m Radxa ROCK 5C | Ubuntu 22.04 LTS | RK3588S2\033[0m"' >> .bashrc && \ echo 'echo ""' >> .bashrc EXPOSE 7860 CMD ["/gw/start.sh"]