automated update: 2026-06-10 21:13:39
This commit is contained in:
+6
-28
@@ -1,50 +1,28 @@
|
|||||||
FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
|
FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
software-properties-common \
|
python3.12 python3.12-venv python3.12-dev libgl1 libglib2.0-0 libxext6 git curl g++ tini \
|
||||||
&& add-apt-repository ppa:deadsnakes/ppa -y \
|
|
||||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
python3.12 python3.12-venv python3.12-dev \
|
|
||||||
libgl1 libglib2.0-0 libxext6 git curl g++ tini \
|
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python \
|
|
||||||
&& ln -sf /usr/bin/python3.12 /usr/bin/python3
|
&& ln -sf /usr/bin/python3.12 /usr/bin/python3
|
||||||
|
|
||||||
# Install uv
|
|
||||||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
|
||||||
&& cp /root/.local/bin/uv /usr/local/bin/uv \
|
&& cp /root/.local/bin/uv /usr/local/bin/uv
|
||||||
&& chmod 755 /usr/local/bin/uv
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Clone your repo (ensure this repo has the updated cli.py locally!)
|
|
||||||
RUN git clone --depth 1 https://github.com/sudolulo/if_curator_headless.git . \
|
RUN git clone --depth 1 https://github.com/sudolulo/if_curator_headless.git . \
|
||||||
&& uv sync --extra gpu \
|
&& uv sync --extra gpu && uv add croniter && uv cache clean
|
||||||
&& uv add croniter \
|
|
||||||
&& uv cache clean
|
|
||||||
|
|
||||||
# Copy helper scripts
|
|
||||||
COPY entrypoint.sh scheduler.py /app/
|
COPY entrypoint.sh scheduler.py /app/
|
||||||
RUN chmod +x /app/entrypoint.sh
|
RUN chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
# Setup non-root user and persistent model paths
|
RUN groupadd -g 568 apps && useradd -u 568 -g apps -m -s /bin/bash appuser \
|
||||||
RUN groupadd -g 568 apps \
|
|
||||||
&& useradd -u 568 -g apps -m -s /bin/bash appuser \
|
|
||||||
&& mkdir -p /models/.insightface /models/huggingface \
|
&& mkdir -p /models/.insightface /models/huggingface \
|
||||||
&& chown -R appuser:apps /app /models
|
&& chown -R appuser:apps /app /models
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
|
ENV HF_HOME=/models/huggingface INSIGHTFACE_HOME=/models
|
||||||
|
|
||||||
# Baked-in configurations
|
HEALTHCHECK CMD test -f /app/entrypoint.sh || exit 1
|
||||||
ENV FORCE_CPU=false \
|
|
||||||
HF_HOME=/models/huggingface \
|
|
||||||
INSIGHTFACE_HOME=/models
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=5m --timeout=10s --start-period=600s --retries=3 \
|
|
||||||
CMD test -f /app/entrypoint.sh || exit 1
|
|
||||||
|
|
||||||
ENTRYPOINT ["tini", "--", "/app/entrypoint.sh"]
|
ENTRYPOINT ["tini", "--", "/app/entrypoint.sh"]
|
||||||
|
|
||||||
|
|||||||
+8
-26
@@ -1,48 +1,30 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
export PYTHONUNBUFFERED=1
|
export PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
# Function to log model status before each run
|
|
||||||
check_models() {
|
check_models() {
|
||||||
echo "📦 Checking models..."
|
echo "📦 Checking models..."
|
||||||
|
# Paths updated to point to persistent root /models
|
||||||
if [ -d "/models/.insightface/models/buffalo_l" ]; then
|
if [ -d "/models/.insightface/models/buffalo_l" ]; then
|
||||||
echo " ✅ InsightFace Buffalo_L: present"
|
echo " ✅ InsightFace Buffalo_L: present"
|
||||||
else
|
else
|
||||||
echo " ⬇️ InsightFace Buffalo_L: not found — will download on first run (~300MB)"
|
echo " ⬇️ InsightFace Buffalo_L: downloading..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "/models/huggingface/hub" ] && [ "$(find /models/huggingface/hub -maxdepth 1 -type d 2>/dev/null | wc -l)" -gt 1 ]; then
|
|
||||||
echo " ✅ HuggingFace models: present"
|
|
||||||
else
|
|
||||||
echo " ⬇️ HuggingFace models: not found — will download on first run (SigLIP ~1GB, YOLOv9c ~500MB)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "🚀 Starting if-curator..."
|
echo "🚀 Starting if-curator..."
|
||||||
}
|
}
|
||||||
|
|
||||||
SCHEDULE="${CRON_SCHEDULE:-}"
|
|
||||||
AUTO="${AUTO_MODE:-false}"
|
AUTO="${AUTO_MODE:-false}"
|
||||||
|
|
||||||
# Check if interactive mode is viable
|
|
||||||
if [ "$AUTO" != "true" ] && [ ! -t 0 ]; then
|
if [ "$AUTO" != "true" ] && [ ! -t 0 ]; then
|
||||||
echo "❌ AUTO_MODE is not enabled and no TTY is attached."
|
echo "❌ AUTO_MODE must be true for non-interactive execution."
|
||||||
echo "❌ Set AUTO_MODE=true for headless/automated runs."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Always run once on startup
|
|
||||||
echo "▶ Running on startup..."
|
|
||||||
check_models
|
check_models
|
||||||
uv run if-curator
|
if [ -n "${CRON_SCHEDULE:-}" ]; then
|
||||||
|
|
||||||
if [ -z "$SCHEDULE" ]; then
|
|
||||||
echo "▶ No CRON_SCHEDULE set — exiting"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "▶ CRON_SCHEDULE set to: $SCHEDULE"
|
|
||||||
echo "▶ Switching to scheduled mode..."
|
echo "▶ Switching to scheduled mode..."
|
||||||
exec uv run python3 /app/scheduler.py
|
exec uv run python3 /app/scheduler.py
|
||||||
|
else
|
||||||
|
echo "▶ Running once..."
|
||||||
|
uv run python -m if_curator.cli
|
||||||
|
fi
|
||||||
|
|
||||||
|
|||||||
+9
-32
@@ -3,46 +3,23 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
try:
|
|
||||||
from croniter import croniter
|
from croniter import croniter
|
||||||
except ImportError:
|
|
||||||
print("❌ croniter not installed. Run: uv add croniter")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
SCHEDULE = os.environ["CRON_SCHEDULE"]
|
|
||||||
MODELS_DIR = os.environ.get("HF_HOME", "/models/huggingface")
|
|
||||||
# Changed to /models to match the updated INSIGHTFACE_HOME pointing to /models
|
|
||||||
INSIGHTFACE_BASE = os.environ.get("INSIGHTFACE_HOME", "/models")
|
|
||||||
|
|
||||||
|
SCHEDULE = os.environ.get("CRON_SCHEDULE", "0 3 * * SUN")
|
||||||
RUN_ENV = {**os.environ, "PYTHONUNBUFFERED": "1"}
|
RUN_ENV = {**os.environ, "PYTHONUNBUFFERED": "1"}
|
||||||
|
|
||||||
def check_models():
|
def run_curator():
|
||||||
print("📦 Checking models...", flush=True)
|
print(f"\n▶ [{time.strftime('%Y-%m-%d %H:%M:%S')}] Starting if-curator...", flush=True)
|
||||||
buffalo = Path(INSIGHTFACE_BASE) / ".insightface" / "models" / "buffalo_l"
|
subprocess.run(["uv", "run", "python", "-m", "if_curator.cli"], env=RUN_ENV)
|
||||||
if buffalo.exists():
|
|
||||||
print(" ✅ InsightFace Buffalo_L: present", flush=True)
|
|
||||||
else:
|
|
||||||
print(" ⬇️ InsightFace Buffalo_L: not found — will download", flush=True)
|
|
||||||
|
|
||||||
hf_hub = Path(MODELS_DIR) / "hub"
|
now = time.time()
|
||||||
if hf_hub.exists() and any(hf_hub.iterdir()):
|
cron = croniter(SCHEDULE, now)
|
||||||
print(" ✅ HuggingFace models: present", flush=True)
|
|
||||||
else:
|
|
||||||
print(" ⬇️ HuggingFace models: not found — will download", flush=True)
|
|
||||||
print("🚀 Starting if-curator...", flush=True)
|
|
||||||
|
|
||||||
NOW = time.time()
|
|
||||||
cron = croniter(SCHEDULE, NOW)
|
|
||||||
next_run = cron.get_next(float)
|
next_run = cron.get_next(float)
|
||||||
|
|
||||||
|
print(f"▶ Scheduler active. Next run: {time.ctime(next_run)}")
|
||||||
while True:
|
while True:
|
||||||
now = time.time()
|
if time.time() >= next_run:
|
||||||
if now >= next_run:
|
run_curator()
|
||||||
print(f"\n▶ [{time.strftime('%Y-%m-%d %H:%M:%S')}] Starting if-curator...", flush=True)
|
|
||||||
check_models()
|
|
||||||
subprocess.run(["uv", "run", "if-curator"], env=RUN_ENV)
|
|
||||||
next_run = cron.get_next(float)
|
next_run = cron.get_next(float)
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user