add algam

This commit is contained in:
2025-09-22 11:54:42 +05:00
parent 3c418a97b4
commit 5b9c55a4dc
34 changed files with 4700 additions and 426 deletions

View File

@@ -1,51 +1,87 @@
version: '3.8'
services:
# База данных PostgreSQL (отдельный сервис)
postgres:
image: postgres:15
container_name: telegram_bot_db
environment:
POSTGRES_DB: telegram_bot
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: ${DB_NAME:-botdb}
POSTGRES_USER: ${DB_USER:-botuser}
POSTGRES_PASSWORD: ${DB_PASSWORD:-your_password_here}
ports:
- "5432:5432"
- "${DB_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- bot_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -h localhost -p 5432 -q -U postgres"]
test: ["CMD-SHELL", "pg_isready -h localhost -p 5432 -q -U ${DB_USER:-botuser}"]
interval: 10s
timeout: 5s
retries: 5
# Единое приложение (API + database логика в одном контейнере)
app:
# Telegram Bot приложение
bot:
build: .
container_name: telegram_bot_app
container_name: telegram_bot
environment:
# Настройки подключения к внешней PostgreSQL
# Загружаем переменные из .env файла
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: telegram_bot
DB_USER: postgres
DB_PASSWORD: password
# Настройки API сервера
API_HOST: 0.0.0.0
API_PORT: 8000
API_RELOAD: "false"
LOG_LEVEL: INFO
ports:
- "8000:8000"
DB_PORT: ${DB_PORT:-5432}
DB_NAME: ${DB_NAME:-botdb}
DB_USER: ${DB_USER:-botuser}
DB_PASSWORD: ${DB_PASSWORD}
APP_ENV: ${APP_ENV:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
DEBUG: ${DEBUG:-False}
command: python main.py --mode bot
depends_on:
postgres:
condition: service_healthy
networks:
- bot_network
restart: unless-stopped
volumes:
- ./images:/app/images:ro
# API сервер (опционально)
api:
build: .
container_name: telegram_bot_api
environment:
# Настройки подключения к PostgreSQL
DB_HOST: postgres
DB_PORT: ${DB_PORT:-5432}
DB_NAME: ${DB_NAME:-botdb}
DB_USER: ${DB_USER:-botuser}
DB_PASSWORD: ${DB_PASSWORD}
# Настройки API сервера
API_HOST: 0.0.0.0
API_PORT: ${API_PORT:-8000}
API_RELOAD: "false"
LOG_LEVEL: ${LOG_LEVEL:-INFO}
APP_ENV: ${APP_ENV:-production}
command: python main.py --mode api
ports:
- "${API_PORT:-8000}:${API_PORT:-8000}"
depends_on:
postgres:
condition: service_healthy
networks:
- bot_network
restart: unless-stopped
profiles:
- api
# Сети для изоляции сервисов
networks:
bot_network:
driver: bridge
# Постоянное хранение данных БД
volumes:
postgres_data: