Files
users/scripts/deploy-to-nas.sh

41 lines
1.4 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 神射手 - 一键部署到公司 NAS (ckbnas 192.168.1.201)
# 功能rsync 同步代码 → NAS 上 docker compose 构建并启动
# 数据库:使用 NAS 上已有 MongoDB192.168.1.201:27017
# 用法:与 NAS 同网下执行 ./scripts/deploy-to-nas.sh
set -e
cd "$(dirname "$0")/.."
NAS_HOST="${NAS_HOST:-192.168.1.201}"
NAS_USER="${NAS_USER:-fnvtk}"
NAS_PATH="${NAS_PATH:-/volume1/docker/shensheshou}"
DOCKER="/volume1/@appstore/ContainerManager/usr/bin/docker"
echo "==> 神射手部署到 NAS ($NAS_USER@$NAS_HOST)"
echo " 目标路径: $NAS_PATH"
echo ""
# 1. 同步代码(排除 node_modules、.git、.next
echo "==> 同步代码到 NAS..."
rsync -avz --progress \
--exclude='node_modules' \
--exclude='.git' \
--exclude='.next' \
--exclude='.env.local' \
--exclude='*.log' \
./ "${NAS_USER}@${NAS_HOST}:${NAS_PATH}/"
# 2. 在 NAS 上构建并启动
echo ""
echo "==> 在 NAS 上构建并启动容器..."
ssh -o ConnectTimeout=10 "${NAS_USER}@${NAS_HOST}" "cd ${NAS_PATH} && \
${DOCKER} compose -f docker-compose.nas.yml build --no-cache && \
echo 'zhiqun1984' | sudo -S ${DOCKER} compose -f docker-compose.nas.yml up -d"
echo ""
echo "==> 部署完成"
echo " 访问: http://${NAS_HOST}:3117"
echo " 健康检查: curl -s http://${NAS_HOST}:3117/api/monitoring?action=health"
echo " 查看日志: ssh ${NAS_USER}@${NAS_HOST} '${DOCKER} logs -f shensheshou'"