#!/usr/bin/env bash
set -euo pipefail

VG_TAG=latest

# Путь к БД на хосте
DB_HOST_DIR="/opt/VideoGrace/Server/db"

mkdir -p "$DB_HOST_DIR"

docker rm -f vgserver >/dev/null 2>&1 || true

docker pull videograce.cr.cloud.ru/vgserver:$VG_TAG

docker run -tid \
  --cpus="4" \
  --name="vgserver" \
  -p 8778:8778 \
  -p 8778:8778/udp \
  -p 8779:8779/udp \
  -p 8780:8780/udp \
  -p 8781:8781/udp \
  -e VG_LOGLEVEL=2 \
  -e VG_THREADS=4 \
  -e VG_DOWNGRADECLIENTS=0 \
  -v "$DB_HOST_DIR":/home/vg_server/db \
  "videograce/vgserver:$VG_TAG"
