Добавление ssh-ключа к контейнеру tunnel
This commit is contained in:
@@ -37,6 +37,10 @@ backend/openapi.json
|
||||
# Бэкапы (создаёт scripts/backup.sh на Pi)
|
||||
backups/
|
||||
|
||||
# AI-ассистенты (локальные, в репозиторий не идут)
|
||||
CLAUDE.md
|
||||
.claude/
|
||||
|
||||
# Редактор / ОС
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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)"
|
||||
|
||||
Reference in New Issue
Block a user