Files
web-page-backend/scripts/deploy-nas.sh
gahusb a3f9f1cb39 fix(deploy): agent-office를 배포 rsync 대상에 추가
deploy-nas.sh의 rsync/chown 루프에 agent-office 디렉토리가
누락되어 NAS 런타임에 복사되지 않던 문제 수정.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 14:23:52 +09:00

69 lines
2.3 KiB
Bash

#!/bin/bash
set -euo pipefail
# 1. 자동 감지: Docker 컨테이너 내부인가?
if [ -d "/repo" ] && [ -d "/runtime" ]; then
echo "Detected Docker Container environment."
SRC="/repo"
DST="/runtime"
else
# 2. Host 환경: .env 로드 시도
if [ -f ".env" ]; then
echo "Loading .env file..."
set -a; source .env; set +a
fi
# 환경변수가 없으면 현재 디렉토리를 SRC로
SRC="${REPO_PATH:-$(pwd)}"
DST="${RUNTIME_PATH:-}"
if [ -z "$DST" ]; then
echo "Error: RUNTIME_PATH is not set. Please create .env file with RUNTIME_PATH defined."
exit 1
fi
fi
echo "Source: $SRC"
echo "Target: $DST"
cd "$SRC"
# 레포에서 운영으로 반영할 항목들만 복사/동기화 (필요한 것만 적기)
# backend, travel-proxy, deployer, nginx, scripts, docker-compose.yml, .env 등
RSYNC_OPTS="-rl --delete --no-owner --no-group --exclude .git --exclude __pycache__ --exclude *.pyc --exclude data/"
for dir in backend travel-proxy deployer stock-lab music-lab blog-lab realestate-lab agent-office nginx scripts; do
rsync $RSYNC_OPTS "$SRC/$dir/" "$DST/$dir/" || {
rc=$?
if [ $rc -ne 23 ]; then
echo "rsync failed for $dir with exit code $rc"
exit $rc
fi
}
done
# compose 파일만 동기화 (.env는 절대 동기화하지 않음 — 운영 시크릿 보호)
rsync -rl --no-owner --no-group "$SRC/docker-compose.yml" "$DST/docker-compose.yml" || {
rc=$?
if [ $rc -ne 23 ]; then
echo "rsync failed for docker-compose.yml with exit code $rc"
exit $rc
fi
}
# 파일 권한 설정 — bgg8988:users 755
# 호스트(bgg8988)에서는 본인 소유 파일만 변경 가능, deployer 컨테이너(root)에서는 전부 가능
DEPLOY_USER="bgg8988"
DEPLOY_GROUP="users"
DEPLOY_MODE="755"
echo "Setting ownership ${DEPLOY_USER}:${DEPLOY_GROUP} and mode ${DEPLOY_MODE}..."
for dir in backend travel-proxy deployer stock-lab music-lab blog-lab realestate-lab agent-office nginx scripts; do
chown -R "${DEPLOY_USER}:${DEPLOY_GROUP}" "$DST/$dir/" 2>/dev/null || true
chmod -R "$DEPLOY_MODE" "$DST/$dir/" 2>/dev/null || true
done
chown "${DEPLOY_USER}:${DEPLOY_GROUP}" "$DST/docker-compose.yml" 2>/dev/null || true
chmod "$DEPLOY_MODE" "$DST/docker-compose.yml" 2>/dev/null || true
echo "SYNC_OK"