- deploy.sh: flock으로 동시 배포 방지, deployer를 빌드 대상에서 제외 - deploy.sh: 배포 후 헬스체크 (4개 서비스 /health 확인) - deploy.sh: 릴리즈 백업 최근 5개만 유지, 원자적 백업 (mv) - deploy-nas.sh: .env 동기화 제거 (운영 시크릿 보호), __pycache__ 제외 - deployer: threading.Lock으로 동시 배포 방어, TimeoutExpired 개별 처리 - docker-compose: deployer 포트 localhost 바인딩, stock-lab 환경변수 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.3 KiB
Bash
44 lines
1.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_EXCLUDES="--exclude .git --exclude __pycache__ --exclude *.pyc --exclude data/"
|
|
|
|
for dir in backend travel-proxy deployer stock-lab music-lab nginx scripts; do
|
|
rsync -a --delete $RSYNC_EXCLUDES \
|
|
"$SRC/$dir/" "$DST/$dir/"
|
|
done
|
|
|
|
# compose 파일만 동기화 (.env는 절대 동기화하지 않음 — 운영 시크릿 보호)
|
|
rsync -a "$SRC/docker-compose.yml" "$DST/docker-compose.yml"
|
|
|
|
echo "SYNC_OK"
|