Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
FROM python:3.12-slim

LABEL org.opencontainers.image.source="https://github.com/rugpullnet/solana-rug"
LABEL org.opencontainers.image.description="Solana Rug Guard — background monitoring container"

WORKDIR /app

# Install solana-rug and its Telegram bot dependencies
# Install solana-rug from source
COPY scripts/ scripts/
COPY solana_rug/ solana_rug/
COPY pyproject.toml setup.py ./
COPY pyproject.toml setup.py README.md ./
RUN pip install --no-cache-dir .

# Copy entrypoint
COPY docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

RUN pip install --no-cache-dir . python-telegram-bot
# Persistent data volume
VOLUME /data

ENV TELEGRAM_BOT_TOKEN=""
# Default config via env
ENV WATCH_TOKENS=""
ENV WATCH_INTERVAL=300
ENV WEBHOOK_URL=""
ENV SQLITE_HISTORY=/data/history.sqlite3
ENV SOLANA_RPC_URL=""

CMD ["python", "-m", "scripts.telegram_bot"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD python3 -c "import os; exit(0 if os.path.isfile(os.environ.get('SQLITE_HISTORY','/data/history.sqlite3')) else 1)"

ENTRYPOINT ["/entrypoint.sh"]
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.9"

services:
solana-rug:
build: .
container_name: solana-rug-monitor
restart: unless-stopped
volumes:
- solana-rug-data:/data
environment:
- WATCH_TOKENS=DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263,EPjFWdd5AufQSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
- WATCH_INTERVAL=300
- WEBHOOK_URL=
- THRESHOLD=40
- SOLANA_RPC_URL=

volumes:
solana-rug-data:
57 changes: 57 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh
# docker-entrypoint.sh — cron-like monitoring loop for solana-rug Docker image.
#
# Reads WATCH_TOKENS (comma-separated mint addresses) and checks each
# on the configured interval, storing results in SQLite and optionally
# posting webhook alerts.

set -e

if [ "$WATCH_TOKENS" = "***" ] || [ -z "$WATCH_TOKENS" ]; then
echo "ERROR: WATCH_TOKENS env var is required (comma-separated mint addresses)"
exit 1
fi

echo "=== Solana Rug Guard Docker Monitor ==="
echo "Watch list: $WATCH_TOKENS"
echo "Interval: ${WATCH_INTERVAL}s"
echo "History: $SQLITE_HISTORY"
echo "Webhook: ${WEBHOOK_URL:-disabled}"
echo ""

# Trap SIGTERM for graceful shutdown
trap 'echo "Shutting down..."; exit 0' SIGTERM SIGINT

while true; do
echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] Checking tokens..."

OLD_IFS="$IFS"
IFS=','
for mint in $WATCH_TOKENS; do
mint=$(echo "$mint" | tr -d ' ')
echo " Checking $mint..."

if [ -n "$WEBHOOK_URL" ]; then
python3 -m scripts.rugguard token "$mint" --json 2>/dev/null | \
curl -s -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d @- >/dev/null 2>&1 && \
echo " Webhook sent" || \
echo " Webhook failed"
fi

# Also store in history via watch command (if history is persisted)
env SQLITE_HISTORY="$SQLITE_HISTORY" \
python3 -m scripts.rugguard watch "$mint" \
--iterations 1 --interval 1 \
--history "$SQLITE_HISTORY" \
${WEBHOOK_URL:+--webhook "$WEBHOOK_URL"} \
${THRESHOLD:+--threshold "$THRESHOLD"} \
2>&1 | sed 's/^/ /'
done
IFS="$OLD_IFS"

echo " Sleeping for ${WATCH_INTERVAL}s..."
sleep "$WATCH_INTERVAL" &
wait $!
done
3 changes: 1 addition & 2 deletions scripts/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from __future__ import annotations

import json
import logging
import os
import sqlite3
Expand Down Expand Up @@ -149,7 +148,7 @@ def _format_report(mint: str) -> str:
symbol = report.token.symbol or report.token.name or f"{mint[:4]}...{mint[-4:]}"
lines = [
f"*🛡️ {symbol} Safety Report*",
f"",
"",
f"**Score:** {report.safety_score}/100 — **{report.risk_level}**",
f"**Mint:** `{mint}`",
"",
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Backward-compatible setup.py for solana-rug."""
from setuptools import setup

setup()
Loading