fix(deploy): 서비스 목록 변수화 + rsync 전 권한 확보 + healthcheck 전서비스 추가

- deploy.sh / deploy-nas.sh: 서비스 목록을 변수로 통합하여 누락 방지
- deploy-nas.sh: rsync 전 chmod u+rwX로 Docker root 소유 파일 권한 확보
- healthcheck.sh: music-lab, blog-lab, realestate-lab, agent-office 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-11 14:27:36 +09:00
parent 678440a2bd
commit cce84de8be
3 changed files with 63 additions and 35 deletions

View File

@@ -1,6 +1,9 @@
#!/bin/bash
set -euo pipefail
# ── 서비스 목록 (한 곳에서만 관리) ──
SERVICES="backend travel-proxy deployer stock-lab music-lab blog-lab realestate-lab agent-office nginx scripts"
# 1. 자동 감지: Docker 컨테이너 내부인가?
if [ -d "/repo" ] && [ -d "/runtime" ]; then
echo "Detected Docker Container environment."
@@ -16,7 +19,7 @@ else
# 환경변수가 없으면 현재 디렉토리를 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
@@ -28,11 +31,19 @@ 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
# 파일 권한 설정값
DEPLOY_USER="bgg8988"
DEPLOY_GROUP="users"
DEPLOY_MODE="755"
for dir in $SERVICES; do
# rsync 전 대상 디렉토리 권한 확보 (Docker root 소유 파일 대응)
if [ -d "$DST/$dir" ]; then
chmod -R u+rwX "$DST/$dir/" 2>/dev/null || true
fi
rsync $RSYNC_OPTS "$SRC/$dir/" "$DST/$dir/" || {
rc=$?
if [ $rc -ne 23 ]; then
@@ -52,13 +63,8 @@ rsync -rl --no-owner --no-group "$SRC/docker-compose.yml" "$DST/docker-compose.y
}
# 파일 권한 설정 — 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
for dir in $SERVICES; do
chown -R "${DEPLOY_USER}:${DEPLOY_GROUP}" "$DST/$dir/" 2>/dev/null || true
chmod -R "$DEPLOY_MODE" "$DST/$dir/" 2>/dev/null || true
done