From 65bebf8b85fcbf921cbbc4f2599953a9fa3ca9c6 Mon Sep 17 00:00:00 2001 From: NotBigGhost Date: Wed, 17 Jun 2026 04:45:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20ssh-=D0=BA=D0=BB=D1=8E=D1=87=D0=B0=20?= =?UTF-8?q?=D0=BA=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9=D0=BD=D0=B5=D1=80?= =?UTF-8?q?=D1=83=20tunnel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++++ deploy/tunnel/tunnel.sh | 8 ++++++++ run.ps1 | 16 ++++++++++++++++ run.sh | 1 + 4 files changed, 29 insertions(+) diff --git a/.gitignore b/.gitignore index b59be21..a8293a5 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,10 @@ backend/openapi.json # Бэкапы (создаёт scripts/backup.sh на Pi) backups/ +# AI-ассистенты (локальные, в репозиторий не идут) +CLAUDE.md +.claude/ + # Редактор / ОС .DS_Store Thumbs.db diff --git a/deploy/tunnel/tunnel.sh b/deploy/tunnel/tunnel.sh index 61b7fdf..9ec8628 100644 --- a/deploy/tunnel/tunnel.sh +++ b/deploy/tunnel/tunnel.sh @@ -9,6 +9,14 @@ VPS_TUNNEL_USER="${VPS_TUNNEL_USER:-tunnel}" : "${VPS_TUNNEL_PORT:?VPS_TUNNEL_PORT is required}" UPSTREAM="${UPSTREAM:-app:8000}" +# Ключ должен быть смонтирован файлом. Если тут пусто/папка — Docker создал каталог, +# потому что файла deploy/tunnel/id_tunnel на хосте нет. +if [ ! -f /key/id_tunnel ]; then + echo "[tunnel] ERROR: /key/id_tunnel is not a regular file." + echo "[tunnel] Put your private key at deploy/tunnel/id_tunnel on the host (its pubkey must be in authorized_keys of tunnel@VPS)." + exit 1 +fi + # Копируем ключ и выставляем строгие права (с хоста права могут не годиться, особенно с Windows). mkdir -p /root/.ssh cp /key/id_tunnel /root/.ssh/id_tunnel diff --git a/run.ps1 b/run.ps1 index 8909e74..9bf026c 100644 --- a/run.ps1 +++ b/run.ps1 @@ -101,6 +101,22 @@ switch ($appEnv) { } "test" { $compose = Join-Path $root "docker-compose.test.yml" + docker info --format '{{.ServerVersion}}' *> $null + if ($LASTEXITCODE -ne 0) { + Write-Host "Docker daemon is not reachable. Start Docker Desktop, wait until it is running, then re-run .\run.ps1" -ForegroundColor Red + exit 1 + } + $keyFile = Join-Path $root "deploy\tunnel\id_tunnel" + if (-not (Test-Path $keyFile -PathType Leaf)) { + if (Test-Path $keyFile -PathType Container) { + Write-Host "deploy\tunnel\id_tunnel is a DIRECTORY - Docker auto-created it because the key file was missing." -ForegroundColor Red + Write-Host "Remove it first: Remove-Item -Recurse -Force deploy\tunnel\id_tunnel" -ForegroundColor Yellow + } else { + Write-Host "No SSH key at deploy\tunnel\id_tunnel (the tunnel container needs it)." -ForegroundColor Red + } + Write-Host "Add your VPS-authorized key: Copy-Item `$env:USERPROFILE\.ssh\id_ed25519 deploy\tunnel\id_tunnel" -ForegroundColor Yellow + exit 1 + } Write-Host "Building and starting prod-clone in Docker (app + in-container tunnel)..." -ForegroundColor Green docker compose -f $compose up --build -d if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/run.sh b/run.sh index 96ffb46..ad90724 100644 --- a/run.sh +++ b/run.sh @@ -60,6 +60,7 @@ case "$app_env" in ( cd "$root/frontend" && npm run dev ) ;; test) + docker info >/dev/null 2>&1 || { echo "Docker-демон недоступен — запусти Docker и повтори ./run.sh"; exit 1; } echo "Сборка и запуск прод-клона в Docker (app + туннель в контейнере)…" docker compose -f "$root/docker-compose.test.yml" up --build -d echo " Публично: https://forbidden-stars.ru (Swagger: /api/docs)"