docker-compose: streamline Redis and Telegram bot configurations; ensure consistent environment variable usage and health checks

This commit is contained in:
vchikalkin 2025-08-16 20:02:18 +03:00
parent e4233c506b
commit 68983bbd32
2 changed files with 24 additions and 27 deletions

View File

@ -1,52 +1,44 @@
services: services:
redis: redis:
env_file:
- .env
image: redis:8-alpine image: redis:8-alpine
restart: always restart: always
env_file:
- .env
command: ['redis-server', '--requirepass', '${REDIS_PASSWORD}']
ports: ports:
- "127.0.0.1:6379:6379" - '127.0.0.1:6379:6379'
volumes: volumes:
- redis-data:/data - redis-data:/data
command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}"]
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
healthcheck: healthcheck:
test: ["CMD", "redis-cli", "ping"] test: ['CMD', 'redis-cli', 'ping']
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3
start_period: 30s start_period: 30s
next-downloader-bot: next-downloader-bot:
env_file:
- .env
build: build:
context: . context: .
dockerfile: ./apps/bot/Dockerfile dockerfile: ./apps/bot/Dockerfile
restart: always restart: always
env_file:
- .env
depends_on: depends_on:
- redis - redis
- telegram-bot-api - telegram-bot-api
telegram-bot-api: telegram-bot-api:
image: aiogram/telegram-bot-api:latest
restart: always restart: always
env_file: env_file:
- .env - .env
image: aiogram/telegram-bot-api:latest
# environment: # environment:
# TELEGRAM_API_ID: "<api-id>" # TELEGRAM_API_ID: "<api-id>"
# TELEGRAM_API_HASH: "<api-hash>" # TELEGRAM_API_HASH: "<api-hash>"
ports:
- '127.0.0.1:8081:8081'
volumes: volumes:
- telegram-bot-api-data:/var/lib/telegram-bot-api - telegram-bot-api-data:/var/lib/telegram-bot-api
ports:
- "127.0.0.1:8081:8081"
volumes: volumes:
telegram-bot-api-data: telegram-bot-api-data:

View File

@ -1,12 +1,12 @@
services: services:
redis: redis:
env_file:
- .env
image: redis:8-alpine image: redis:8-alpine
restart: always restart: always
env_file:
- .env
command: ['redis-server', '--requirepass', '${REDIS_PASSWORD}']
volumes: volumes:
- redis-data:/data - redis-data:/data
command: ['redis-server', '--requirepass', '${REDIS_PASSWORD}']
deploy: deploy:
resources: resources:
limits: limits:
@ -23,26 +23,31 @@ services:
start_period: 30s start_period: 30s
next-downloader-bot: next-downloader-bot:
image: "${DOCKERHUB_USERNAME}/next-downloader-bot:${BOT_IMAGE_TAG}" image: '${DOCKERHUB_USERNAME}/next-downloader-bot:${BOT_IMAGE_TAG}'
restart: always
env_file: env_file:
- .env - .env
restart: always
depends_on: depends_on:
- redis - redis
- telegram-bot-api - telegram-bot-api
telegram-bot-api:
restart: always
deploy: deploy:
resources: resources:
limits: limits:
cpus: '0.50' cpus: '0.50'
memory: 512M memory: 512M
telegram-bot-api:
image: aiogram/telegram-bot-api:latest
restart: always
env_file: env_file:
- .env - .env
image: aiogram/telegram-bot-api:latest
volumes: volumes:
- telegram-bot-api-data:/var/lib/telegram-bot-api - telegram-bot-api-data:/var/lib/telegram-bot-api
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
volumes: volumes:
telegram-bot-api-data: telegram-bot-api-data: