first commit
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
# macOS: Apple container(https://github.com/apple/container)로 빌드·상주 실행.
|
||||
# 실행: bash deploy/install-apple-container.sh # 이미지 빌드 + 컨테이너 (재)기동
|
||||
# bash deploy/install-apple-container.sh --boot # + 로그인 시 자동 기동(LaunchAgent) 등록
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
NAME=sebrief
|
||||
|
||||
CONTAINER_BIN="$(command -v container || true)"
|
||||
if [ -z "$CONTAINER_BIN" ]; then
|
||||
echo "Apple container CLI가 없습니다: brew install container (macOS 15+, Apple Silicon)" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$ROOT/.env" ]; then
|
||||
echo "$ROOT/.env 가 없습니다: cp .env.example .env 후 MINIMAX_API_KEY를 넣으세요" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DASHBOARD=sebrief-dashboard
|
||||
DASHBOARD_PORT="${SEBRIEF_DASHBOARD_PORT:-8091}"
|
||||
|
||||
mkdir -p "$ROOT/data" "$ROOT/reports" "$ROOT/logs"
|
||||
container system start
|
||||
container build -t "$NAME" -f "$ROOT/deploy/Dockerfile" "$ROOT"
|
||||
container build -t "$DASHBOARD" -f "$ROOT/dashboard/Dockerfile" "$ROOT/dashboard"
|
||||
|
||||
# 기존 컨테이너는 갈아끼운다 (이미지 갱신 반영). container에는 restart 정책이 없어
|
||||
# 자동 기동은 --boot 의 LaunchAgent가 담당한다.
|
||||
container stop "$NAME" "$DASHBOARD" >/dev/null 2>&1 || true
|
||||
container delete "$NAME" "$DASHBOARD" >/dev/null 2>&1 || true
|
||||
container run --detach --name "$NAME" \
|
||||
--env-file "$ROOT/.env" \
|
||||
--env SEBRIEF_DATA_DIR=/app/data \
|
||||
--env SEBRIEF_REPORTS_DIR=/app/reports \
|
||||
--env SEBRIEF_LOG_DIR=/app/logs \
|
||||
--volume "$ROOT/data:/app/data" \
|
||||
--volume "$ROOT/reports:/app/reports" \
|
||||
--volume "$ROOT/logs:/app/logs" \
|
||||
"$NAME"
|
||||
container run --detach --name "$DASHBOARD" \
|
||||
--volume "$ROOT/reports:/data/reports:ro" \
|
||||
--publish "0.0.0.0:$DASHBOARD_PORT:8091" \
|
||||
"$DASHBOARD"
|
||||
|
||||
if [ "${1:-}" = "--boot" ]; then
|
||||
PLIST_SRC="$ROOT/deploy/com.sebrief.container.plist"
|
||||
PLIST_DST="$HOME/Library/LaunchAgents/com.sebrief.container.plist"
|
||||
mkdir -p "$HOME/Library/LaunchAgents"
|
||||
sed -e "s#__CONTAINER__#$CONTAINER_BIN#g" -e "s#__ROOT__#$ROOT#g" "$PLIST_SRC" > "$PLIST_DST"
|
||||
launchctl bootout "gui/$(id -u)/com.sebrief.container" 2>/dev/null || true
|
||||
launchctl bootstrap "gui/$(id -u)" "$PLIST_DST"
|
||||
echo "boot agent: $PLIST_DST (로그인 시 container system start + container start $NAME $DASHBOARD)"
|
||||
fi
|
||||
|
||||
echo "dashboard: http://localhost:$DASHBOARD_PORT"
|
||||
echo "status: container list --all"
|
||||
echo "logs: container logs --follow $NAME (파일: tail -f $ROOT/logs/sebrief.log)"
|
||||
echo "stop: container stop $NAME $DASHBOARD"
|
||||
echo "remove: container stop $NAME $DASHBOARD && container delete $NAME $DASHBOARD"
|
||||
Reference in New Issue
Block a user