Files
bot-telegram/docker-compose.yml
2025-09-22 12:35:41 +05:00

118 lines
3.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
services:
# База данных PostgreSQL (отдельный сервис)
postgres:
image: postgres:15
container_name: telegram_bot_db
environment:
POSTGRES_DB: ${DB_NAME:-botdb}
POSTGRES_USER: ${DB_USER:-botuser}
POSTGRES_PASSWORD: ${DB_PASSWORD:-your_password_here}
ports:
- "${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 ${DB_USER:-botuser}"]
interval: 10s
timeout: 5s
retries: 5
# Telegram Bot приложение (работает ТОЛЬКО через API)
bot:
build: .
container_name: telegram_bot
environment:
# Настройки бота
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
APP_ENV: ${APP_ENV:-production}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
DEBUG: ${DEBUG:-False}
# Настройки подключения к API (НЕ к БД!)
API_HOST: api
API_PORT: 8000
API_BASE_URL: http://api:8000
API_TIMEOUT: 30
command: python app.bot/main.py
depends_on:
api:
condition: service_healthy
networks:
- bot_network
restart: unless-stopped
profiles:
- bot
- all
# 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}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
APP_ENV: ${APP_ENV:-production}
DEBUG: ${DEBUG:-False}
command: python app.api/run_server.py
ports:
- "${API_PORT:-8000}:${API_PORT:-8000}"
depends_on:
postgres:
condition: service_healthy
networks:
- bot_network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
profiles:
- api
- all
# Веб-интерфейс для управления (работает через API)
web:
build: .
container_name: telegram_bot_web
environment:
# Настройки подключения к API
API_HOST: api
API_PORT: 8000
API_BASE_URL: http://api:8000
command: python app.control-bot/main.py
ports:
- "${WEB_PORT:-3000}:3000"
depends_on:
api:
condition: service_healthy
networks:
- bot_network
restart: unless-stopped
profiles:
- web
- all
# Сети для изоляции сервисов
networks:
bot_network:
driver: bridge
# Постоянное хранение данных БД
volumes:
postgres_data: