diff --git a/opencode/compose.yaml b/opencode/compose.yaml index fef239a..a426da5 100644 --- a/opencode/compose.yaml +++ b/opencode/compose.yaml @@ -12,6 +12,28 @@ services: command: - | command -v git >/dev/null 2>&1 || /sbin/apk add --no-cache git curl ca-certificates + + # Background Git sync loop for /root/.config/opencode + ( + while true; do + sleep 60 + if [ -d /root/.config/opencode/.git ]; then + cd /root/.config/opencode || continue + git fetch origin main -q 2>/dev/null || continue + LOCAL=$$(git rev-parse HEAD 2>/dev/null) + REMOTE=$$(git rev-parse origin/main 2>/dev/null) + if [ -n "$$REMOTE" ] && [ "$$LOCAL" != "$$REMOTE" ]; then + CHANGED=$$(git diff --name-only "$$LOCAL" "$$REMOTE") + git pull --ff-only origin main -q + # Restart container only if opencode.jsonc changed + if echo "$$CHANGED" | grep -q "opencode.jsonc"; then + kill 1 + fi + fi + fi + done + ) & + exec opencode web --port 4096 --hostname 0.0.0.0 --print-logs --log-level "$${LOG_LEVEL}" environment: - HOME=/root