diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile new file mode 100644 index 0000000..d133293 --- /dev/null +++ b/scripts/docker/Dockerfile @@ -0,0 +1,24 @@ +FROM node:20-slim AS builder + +WORKDIR /app +COPY package*.json ./ +RUN npm ci + +COPY . . +RUN npm run build + +FROM node:20-slim + +RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/web/dist ./web/dist +COPY --from=builder /app/package*.json ./ +RUN npm ci --production + +EXPOSE 3000 +VOLUME ["/app/data"] + +CMD ["node", "dist/index.js"] diff --git a/scripts/docker/docker-compose.yml b/scripts/docker/docker-compose.yml new file mode 100644 index 0000000..bba69c3 --- /dev/null +++ b/scripts/docker/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.8' + +services: + tsmusicbot: + build: + context: ../.. + dockerfile: scripts/docker/Dockerfile + container_name: tsmusicbot + ports: + - "3000:3000" + volumes: + - ./data:/app/data + restart: unless-stopped + environment: + - NODE_ENV=production diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..1550c31 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "╔══════════════════════════════════════╗" +echo "║ TSMusicBot Installer ║" +echo "╚══════════════════════════════════════╝" +echo "" + +INSTALL_DIR="/opt/tsmusicbot" +SERVICE_NAME="tsmusicbot" + +# Detect OS +if [ -f /etc/os-release ]; then + . /etc/os-release + OS=$ID +else + echo "Unsupported OS" + exit 1 +fi + +echo "[1/5] Installing system dependencies..." +case $OS in + ubuntu|debian) + sudo apt-get update -qq + sudo apt-get install -y -qq curl ffmpeg + ;; + centos|rhel|fedora) + sudo yum install -y curl ffmpeg + ;; + arch|manjaro) + sudo pacman -S --noconfirm curl ffmpeg + ;; + *) + echo "Unsupported OS: $OS. Please install Node.js 20 and FFmpeg manually." + ;; +esac + +echo "[2/5] Installing Node.js 20 LTS..." +if ! command -v node &> /dev/null || [[ $(node -v | cut -d. -f1 | tr -d 'v') -lt 20 ]]; then + curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - + sudo apt-get install -y -qq nodejs 2>/dev/null || sudo yum install -y nodejs 2>/dev/null +fi +echo "Node.js $(node -v) installed" + +echo "[3/5] Downloading TSMusicBot..." +sudo mkdir -p "$INSTALL_DIR" +if [ -d "$(pwd)/dist" ]; then + sudo cp -r "$(pwd)"/* "$INSTALL_DIR/" +else + echo "Please run this script from the TSMusicBot source directory after building." + exit 1 +fi + +echo "[4/5] Installing npm dependencies..." +cd "$INSTALL_DIR" +sudo npm install --production + +echo "[5/5] Creating systemd service..." +sudo tee /etc/systemd/system/${SERVICE_NAME}.service > /dev/null <nul 2>&1 +if %errorlevel% neq 0 ( + echo Node.js is not installed. Please install Node.js 20 LTS from https://nodejs.org + pause + exit /b 1 +) + +:: Check if ffmpeg is available +where ffmpeg >nul 2>&1 +if %errorlevel% neq 0 ( + echo FFmpeg not found in PATH. Checking local directory... + if exist "%~dp0ffmpeg\ffmpeg.exe" ( + set PATH=%~dp0ffmpeg;%PATH% + echo Using bundled FFmpeg. + ) else ( + echo FFmpeg is required. Please install FFmpeg or place it in the ffmpeg\ directory. + pause + exit /b 1 + ) +) + +:: Install dependencies if needed +if not exist "%~dp0node_modules" ( + echo Installing dependencies... + cd /d "%~dp0" + call npm install --production +) + +:: Start the application +cd /d "%~dp0" +node dist/index.js + +pause diff --git a/web/src/router/index.ts b/web/src/router/index.ts index 5971a59..66da02a 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -33,6 +33,11 @@ const router = createRouter({ name: 'settings', component: () => import('../views/Settings.vue'), }, + { + path: '/setup', + name: 'setup', + component: () => import('../views/Setup.vue'), + }, ], }); diff --git a/web/src/views/Setup.vue b/web/src/views/Setup.vue new file mode 100644 index 0000000..b82dec6 --- /dev/null +++ b/web/src/views/Setup.vue @@ -0,0 +1,229 @@ + + + + +