~cytrogen/evi-run

ref: f9177ebbdb748fbfd9aec9173405de7691a3bf26 evi-run/DEPLOY.md -rw-r--r-- 4.8 KiB
f9177ebb — Cytrogen fork: 定制修改 + 敏感数据清理 9 days ago

#Local Deployment Guide (Docker Compose)

#Prerequisites

Requirement Notes
Docker Engine + Docker Compose v2 Windows: install Docker Desktop
Git To clone the repository
Hardware 2 CPU cores, 2 GB RAM, 10 GB disk (minimum)

#Required API Keys

Variable Source Required?
TELEGRAM_BOT_TOKEN Create a bot via @BotFather Yes
API_KEY_OPENAI OpenAI Platform Yes
POSTGRES_USER Choose any username Yes
POSTGRES_PASSWORD Choose a strong password Yes
POSTGRES_DB Choose a database name Yes
DATABASE_URL Built from the PG values above Yes
REDIS_URL redis://redis:6379 Yes
API_KEY_TON TON API key Optional (pay mode)
TON_ADDRESS TON wallet address Optional (pay mode)
ADDRESS_SOL Solana wallet public key Optional (token swap)
MINT_TOKEN_ADDRESS SPL token mint address Optional (pay mode)
TOKEN_BURN_ADDRESS Token burn address Optional (pay mode)

#Step-by-step Deployment

#1. Clone the repository

git clone <repo-url>
cd evi-run

#2. Create and configure .env

cp .env.example .env

Edit .env and fill in all required values. Pay attention to DATABASE_URL — it must use the Docker service name postgres as the host (not localhost):

DATABASE_URL=postgresql+psycopg://evi_user:YOUR_PASSWORD@postgres:5432/evi_db
REDIS_URL=redis://redis:6379

Important: Use the container-internal ports (5432 for PostgreSQL, 6379 for Redis), not the host-mapped ports (5434, 6380).

#3. Configure config.py

Edit config.py and set your Telegram user ID:

ADMIN_ID = 123456789              # Your Telegram ID
ADMINS_LIST = [123456789]         # List of admin Telegram IDs
TYPE_USAGE = 'private'            # 'private', 'free', or 'pay'

To find your Telegram ID, message @userinfobot.

#4. Build and start

docker compose up --build -d

#5. Verify

# Check all containers are running
docker compose ps

# Watch bot logs
docker compose logs -f bot

# Check database is healthy
docker compose logs postgres

#Architecture

The deployment runs 3 containers (4 if the optional payment module is enabled):

                 ┌─────────────┐
                 │   bot_agent  │
                 │  (Telegram)  │
                 └──────┬───┬──┘
                        │   │
            ┌───────────┘   └───────────┐
            ▼                           ▼
   ┌────────────────┐        ┌──────────────────┐
   │ postgres_agent  │        │   redis_agent     │
   │  (PostgreSQL)   │        │   (Redis)         │
   │  :5434 → :5432  │        │   :6380 → :6379   │
   └────────────────┘        └──────────────────┘

Data persistence:

  • ./data/postgres/postgres_data — PostgreSQL data
  • ./data/redis/data — Redis data
  • ./data/images — Generated images

#Enabling the Payment Module (Optional)

The fastapi service is commented out by default because the payment_module/ directory is not included in the repository. If you have the payment module:

  1. Place the payment_module/ directory in the project root
  2. Uncomment the fastapi service block in docker-compose.yml
  3. Add fastapi to the bot's depends_on section
  4. Rebuild: docker compose up --build -d

#Troubleshooting

#Bot container keeps restarting

docker compose logs bot

Common causes:

  • Invalid TELEGRAM_BOT_TOKEN
  • Invalid API_KEY_OPENAI
  • Database not ready (healthcheck should prevent this, but check docker compose logs postgres)

#Database connection errors

  • Verify DATABASE_URL in .env uses postgres as host (not localhost)
  • Verify POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB match between the .env values and DATABASE_URL

#Redis connection errors

  • Verify REDIS_URL uses redis as host (not localhost)

#Rebuilding after .env changes

Environment variables are injected via env_file in docker-compose.yml, so a simple restart should pick up changes:

docker compose down && docker compose up -d

However, if you change dependencies or code, rebuild:

docker compose up --build -d

#Resetting everything

docker compose down -v
rm -rf data/postgres data/redis
docker compose up --build -d