Docker-WebApp, die einen echten Minecraft Java-Client (Prism Launcher) in einem Container mit virtuellem Display betreibt und per noVNC im Browser anzeigt. Gedacht, um Accounts AFK an Farmen zu stellen. - Multi-Stage Dockerfile: Vite/Vue-Build + Ubuntu-Runtime (Xvfb, x11vnc, websockify, noVNC, openbox, nginx, Prism Launcher 11.0.3) - Vue 3 + Vite + TypeScript Dashboard (noVNC-iframe, Start/Stop, Status-Anzeige, Schnellstart-Anleitung) - Node-Status-API ohne externe Dependencies (/api/status, /api/mc/*) - docker-compose.yml mit PUID/PGID, konfigurierbarer Auflösung, shm_size - Persistente Accounts/Instanzen in /config (Volume)
98 lines
3.3 KiB
Bash
98 lines
3.3 KiB
Bash
#!/usr/bin/env bash
|
|
# CTmine-client Entrypoint.
|
|
# Richtet den Runtime-Benutzer, /config und die display-bezogenen Konfigurationen
|
|
# ein und startet anschließend supervisord, der alle Prozesse verwaltet.
|
|
set -euo pipefail
|
|
|
|
PUID="${PUID:-1000}"
|
|
PGID="${PGID:-1000}"
|
|
TZ="${TZ:-Europe/Berlin}"
|
|
CONFIG_DIR="${CONFIG_DIR:-/config}"
|
|
WEB_ROOT="${WEB_ROOT:-/var/www/ctmine}"
|
|
|
|
# TimeZone setzen, sofern tzdata vorhanden.
|
|
if [ -f "/usr/share/zoneinfo/${TZ}" ]; then
|
|
ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime
|
|
echo "${TZ}" > /etc/timezone
|
|
fi
|
|
|
|
echo "[entrypoint] PUID=${PUID} PGID=${PGID} TZ=${TZ}"
|
|
|
|
# --- /config anlegen und dem Runtime-Benutzer übergeben ------------------
|
|
mkdir -p "${CONFIG_DIR}/prism" "${CONFIG_DIR}/.local"
|
|
|
|
# Gruppe/Benutzer an PUID/PGID anpassen (der 'ctmine'-Benutzer wird im
|
|
# Dockerfile mit UID 1000 angelegt). So gehören Dateien im Volume dem
|
|
# Host-Benutzer.
|
|
if [ "$(id -u)" = "0" ]; then
|
|
groupmod -o -g "${PGID}" ctmine 2>/dev/null || true
|
|
usermod -o -u "${PUID}" -g "${PGID}" -d "${CONFIG_DIR}" ctmine 2>/dev/null || true
|
|
chown -R ctmine:ctmine "${CONFIG_DIR}"
|
|
fi
|
|
|
|
# --- Display-Auflösung in Supervisor-Config schreiben --------------------
|
|
# supervisord kann keine ENV-Substitution, darum generieren wir Xvfb-Start
|
|
# und x11vnc-Optionen hier als feste Dateien.
|
|
DISPLAY_WIDTH="${DISPLAY_WIDTH:-1280}"
|
|
DISPLAY_HEIGHT="${DISPLAY_HEIGHT:-720}"
|
|
DISPLAY_REFRESH="${DISPLAY_REFRESH:-60}"
|
|
DISPLAY_DEPTH="${DISPLAY_DEPTH:-24}"
|
|
|
|
cat > /tmp/xvfb.conf <<EOF
|
|
[program:xvfb]
|
|
command=/usr/bin/Xvfb :0 -screen 0 ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}x${DISPLAY_DEPTH} -ac -nolisten tcp
|
|
priority=10
|
|
autostart=true
|
|
autorestart=true
|
|
stdout_logfile=/dev/fd/1
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/fd/2
|
|
stderr_logfile_maxbytes=0
|
|
environment=HOME="/config"
|
|
EOF
|
|
|
|
# VNC-Passwort-Datei (optional). Ohne Passwort läuft x11vnc ohne Auth —
|
|
# nur für vertrauenswürdige lokale Netze gedacht.
|
|
VNC_PASSWORD="${VNC_PASSWORD:-}"
|
|
VNC_PWFILE="${CONFIG_DIR}/.vncpasswd"
|
|
if [ -n "${VNC_PASSWORD}" ]; then
|
|
printf '%s\n' "${VNC_PASSWORD}" | vncpasswd -f > "${VNC_PWFILE}"
|
|
chmod 600 "${VNC_PWFILE}"
|
|
chown ctmine:ctmine "${VNC_PWFILE}"
|
|
VNC_PWFLAG="-rfbauth ${VNC_PWFILE}"
|
|
else
|
|
rm -f "${VNC_PWFILE}"
|
|
VNC_PWFLAG="-nopw"
|
|
fi
|
|
|
|
cat > /tmp/x11vnc.conf <<EOF
|
|
[program:x11vnc]
|
|
command=/usr/bin/x11vnc -display :0 -forever -shared ${VNC_PWFLAG} -rfbport 5900
|
|
priority=20
|
|
autostart=true
|
|
autorestart=true
|
|
stdout_logfile=/dev/fd/1
|
|
stdout_logfile_maxbytes=0
|
|
stderr_logfile=/dev/fd/2
|
|
stderr_logfile_maxbytes=0
|
|
environment=HOME="/config"
|
|
EOF
|
|
|
|
# nginx braucht /run für PID + Sockets, sicherstellen dass es existiert.
|
|
mkdir -p /run /var/lib/nginx /var/log/nginx
|
|
chown -R ctmine:ctmine /var/lib/nginx /var/log/nginx 2>/dev/null || true
|
|
|
|
# Wenn Web-Root existiert, Rechte setzen.
|
|
if [ -d "${WEB_ROOT}" ]; then
|
|
chown -R ctmine:ctmine "${WEB_ROOT}" 2>/dev/null || true
|
|
fi
|
|
|
|
# --- Prism beim ersten Start ins persistente Volume kopieren --------------
|
|
# /opt/prism enthält die frische Launcher-Installation; beim ersten Start
|
|
# (oder nach Updates) wird sie nach /config/prism kopiert, damit Accounts
|
|
# und Instanzen persistent bleiben.
|
|
/opt/bootstrap-prism.sh
|
|
echo "[entrypoint] Prism Launcher unter ${CONFIG_DIR}/prism bereit."
|
|
|
|
echo "[entrypoint] Starte supervisord …"
|
|
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|