AZILS commited on
Commit
ec24da1
Β·
verified Β·
1 Parent(s): b1e4956

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -25
Dockerfile CHANGED
@@ -5,7 +5,7 @@ USER root
5
  RUN apt-get update && apt-get install -y --no-install-recommends curl jq && rm -rf /var/lib/apt/lists/*
6
 
7
  ENV DATA_DIR=/root/.antigravity_tools
8
- ENV SYNC_INTERVAL=30
9
  EXPOSE 8045
10
 
11
  COPY --chmod=755 <<'SCRIPT' /entrypoint.sh
@@ -59,16 +59,7 @@ supabase_has_data() {
59
  [ "$(echo "$r" | jq 'length' 2>/dev/null)" != "0" ]
60
  }
61
 
62
- # Only sync JSON files β€” SQLite DBs use WAL mode (unsafe to upload mid-write)
63
- # and are auto-recreated by the app's init_db() on startup.
64
- is_syncable() {
65
- case "$1" in
66
- *.json) return 0 ;;
67
- *) return 1 ;;
68
- esac
69
- }
70
-
71
- # ── Pull: Download all JSON files from Supabase ─────────────────
72
  pull_from_supabase() {
73
  echo "[Sync] Pulling from Supabase..."
74
  local count=0
@@ -83,15 +74,13 @@ pull_from_supabase() {
83
  echo "[Sync] Pull complete!"
84
  }
85
 
86
- # ── Push: Upload all syncable files to Supabase ─────────────────
87
  push_all() {
88
- echo "[Sync] Pushing all files..."
89
  find "$DATA_DIR" -type f | while read -r filepath; do
90
  local rel="${filepath#$DATA_DIR/}"
91
- if is_syncable "$rel"; then
92
- supabase_upload "$filepath" "${SUPABASE_PREFIX}/${rel}"
93
- echo "[Sync] -> $rel"
94
- fi
95
  done
96
  touch "$LAST_SYNC"
97
  echo "[Sync] Push complete at $(date '+%H:%M:%S')"
@@ -99,16 +88,12 @@ push_all() {
99
 
100
  # ── Push changed: Only upload files modified since last sync ────
101
  push_changed() {
102
- local found=0
103
  find "$DATA_DIR" -type f -newer "$LAST_SYNC" 2>/dev/null | while read -r filepath; do
104
  local rel="${filepath#$DATA_DIR/}"
105
- if is_syncable "$rel"; then
106
- supabase_upload "$filepath" "${SUPABASE_PREFIX}/${rel}"
107
- echo "[Sync] -> $rel (changed)"
108
- found=1
109
- fi
110
  done
111
- [ "$found" = "1" ] && touch "$LAST_SYNC"
112
  }
113
 
114
  # ── Main ─────────────────────────────────────────────────────────
@@ -137,7 +122,7 @@ if [ -n "$SYNC" ] && [ ! -f "$LAST_SYNC" ]; then
137
  push_all
138
  fi
139
 
140
- # Step 4: Background sync β€” push changed JSON files every N seconds
141
  if [ -n "$SYNC" ]; then
142
  (
143
  while kill -0 $APP_PID 2>/dev/null; do
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends curl jq && rm -rf /var/lib/apt/lists/*
6
 
7
  ENV DATA_DIR=/root/.antigravity_tools
8
+ ENV SYNC_INTERVAL=150
9
  EXPOSE 8045
10
 
11
  COPY --chmod=755 <<'SCRIPT' /entrypoint.sh
 
59
  [ "$(echo "$r" | jq 'length' 2>/dev/null)" != "0" ]
60
  }
61
 
62
+ # ── Pull: Download all files from Supabase ──────────────────────
 
 
 
 
 
 
 
 
 
63
  pull_from_supabase() {
64
  echo "[Sync] Pulling from Supabase..."
65
  local count=0
 
74
  echo "[Sync] Pull complete!"
75
  }
76
 
77
+ # ── Push: Upload entire directory to Supabase ───────────────────
78
  push_all() {
79
+ echo "[Sync] Pushing entire directory..."
80
  find "$DATA_DIR" -type f | while read -r filepath; do
81
  local rel="${filepath#$DATA_DIR/}"
82
+ supabase_upload "$filepath" "${SUPABASE_PREFIX}/${rel}"
83
+ echo "[Sync] -> $rel"
 
 
84
  done
85
  touch "$LAST_SYNC"
86
  echo "[Sync] Push complete at $(date '+%H:%M:%S')"
 
88
 
89
  # ── Push changed: Only upload files modified since last sync ────
90
  push_changed() {
 
91
  find "$DATA_DIR" -type f -newer "$LAST_SYNC" 2>/dev/null | while read -r filepath; do
92
  local rel="${filepath#$DATA_DIR/}"
93
+ supabase_upload "$filepath" "${SUPABASE_PREFIX}/${rel}"
94
+ echo "[Sync] -> $rel"
 
 
 
95
  done
96
+ touch "$LAST_SYNC"
97
  }
98
 
99
  # ── Main ─────────────────────────────────────────────────────────
 
122
  push_all
123
  fi
124
 
125
+ # Step 4: Background sync β€” push changed files every N seconds
126
  if [ -n "$SYNC" ]; then
127
  (
128
  while kill -0 $APP_PID 2>/dev/null; do