From d6743f7669cee83930f9669262822912ac96a2d1 Mon Sep 17 00:00:00 2001 From: chk <79915315+ChKendel@users.noreply.github.com> Date: Mon, 9 Mar 2026 21:49:54 +0100 Subject: [PATCH] Port im Browser-Javascript --- docker-compose.yaml | 24 ++++++++++++++++++ install.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++ web/index.html | 2 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yaml create mode 100644 install.sh diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..a3f8ec5 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,24 @@ +version: "3.9" + +services: + appRobotControlRed: + image: node:20-bullseye + # Alternativ: node:20-alpine (kleiner, aber evtl. openssl/ca/certs nachziehen) + container_name: appRobotControlRed + network_mode: host + working_dir: /app + volumes: + - /home/chk/Documents/appRobotControlScara:/app + environment: + # Deine App liest diese Variablen (config.js ist schon vorbereitet) + - FluidNcHost=fluidncred.local + - FluidNcPort=80 + - PORT=3000 + ports: + - "3000:3000" + command: > + /bin/bash -lc " + npm ci || npm install && + node server/server.js + " + restart: unless-stopped \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..07331b3 --- /dev/null +++ b/install.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +set -euo pipefail + +# --- Konfiguration --- +REPO_NAME="appRobotControlScara" +REPO_URL="http://thinkcentre.local:3000/ChK/appRobotControlScara.git" +TARGET_DIR="/home/chk/Documents/appRobotControlScara" + + + +echo "[1/6] Pakete aktualisieren & Git installieren..." +sudo apt-get update -y +sudo apt-get install -y git ca-certificates curl + +echo "[2/6] Docker & Compose installieren (falls nicht vorhanden)..." +if ! command -v docker >/dev/null 2>&1; then + curl -fsSL https://get.docker.com | sudo sh + sudo usermod -aG docker "$USER" + echo ">> Ab- und wieder anmelden, damit die docker-Gruppe aktiv wird (oder 'newgrp docker')." +fi + +# Compose-Plugin prüfen/holen (bei Debian/Raspbian Bullseye/Bookworm meist verfügbar) +if ! docker compose version >/dev/null 2>&1; then + echo "Docker Compose Plugin scheint zu fehlen. Bitte OS-spezifisch nachinstallieren." + echo "Bei Raspberry Pi OS: 'sudo apt-get install -y docker-compose-plugin'" +fi + +echo "[3/6] Zielverzeichnis vorbereiten: ${TARGET_DIR}" +sudo mkdir -p "${TARGET_DIR}" +sudo chown -R "$USER":"$USER" "${TARGET_DIR}" + +echo "[4/6] Repository klonen/aktualisieren..." +if [ -d "${TARGET_DIR}/.git" ]; then + cd "${TARGET_DIR}" + git fetch --all + git pull --ff-only +else + git clone "${REPO_URL}" "${TARGET_DIR}" + cd "${TARGET_DIR}" +fi + +echo "[5/6] .env optional anlegen (falls gewünscht)..." +if [ ! -f ".env" ]; then + cat > .env <> .env erstellt (Standardwerte)." +fi + + +echo "[6/6] Certs erstellen" + +chmod +x scripts/create_certs.sh +./scripts/create_certs.sh + + +echo "Docker in portainer eintragen" \ No newline at end of file diff --git a/web/index.html b/web/index.html index a4d8a74..c487e1a 100644 --- a/web/index.html +++ b/web/index.html @@ -121,7 +121,7 @@ let ws; function connectWS() { - ws = new WebSocket("wss://" + window.location.hostname + ":3000"); + ws = new WebSocket("wss://" + window.location.hostname + ":" + window.location.port); ws.onopen = () => { console.log("WS connected");