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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Переменная с вызовом docker-compose
DC = docker-compose -f docker/docker-compose.yml

# Переменная с вызовом docker-compose production
PDC = docker compose -f docker/docker-compose.prod.yml

# 🐳 Команды с docker-compose:

# Запуск docker-compose без аргументов
Expand All @@ -25,6 +28,10 @@ stop:
up:
$(DC) up -d

# Поднятие контейнеров в фоновом режиме production
pup:
$(DC) up -d

# Поднятие контейнеров с логами
uplog:
$(DC) up
Expand All @@ -33,6 +40,10 @@ uplog:
build:
$(DC) build

# Сборка образов production
pbuild:
$(PDC) build

# Поднятие с пересборкой в фоновом режиме
upnolog:
$(DC) up --build -d
Expand Down Expand Up @@ -69,6 +80,7 @@ logs:
ps:
$(DC) ps


# 🐍 Проверка кода по flake8
lint:
flake8 core bot --max-line-length=79 --exclude=migrations && \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 📋 <b>"ToDoAiogramBot"</b> - сервис для управления задачами и отправки напоминаний, связанный с телеграм-ботом.

Образец бота: https://t.me/MyTasksRemindBot

## 💬 Команды телеграм-бота:

Expand Down
125 changes: 66 additions & 59 deletions docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,102 @@
version: '3.9'

services:
postgres:
image: postgres:15
restart: always
env_file:
- .env
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5

redis:
image: redis:7-alpine
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3

django:
build:
context: .
context: ..
dockerfile: docker/Dockerfile.django
command: >
sh -c "/wait-for-it.sh postgres:5432 --
/wait-for-it.sh redis:6379 --
python manage.py runserver 0.0.0.0:8000"
volumes:
- .:/app
- ..:/app
ports:
- "8000:8000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
- postgres
- redis
env_file:
- .env
- ../.env
restart: unless-stopped
deploy:
resources:
limits:
memory: 200M

migrate:
build:
context: .
context: ..
dockerfile: docker/Dockerfile.django
volumes:
- .:/app
- ..:/app
env_file:
- .env
- ../.env
depends_on:
postgres:
condition: service_healthy
command: >
sh -c "/wait-for-it.sh postgres:5432 --
python manage.py migrate"
profiles: ["migrate"]
- postgres
command: /bin/bash -c "while ! pg_isready -h postgres -p 5432; do sleep 2; done; python manage.py migrate"
deploy:
resources:
limits:
memory: 150M

postgres:
image: postgres:15-alpine
restart: always
env_file:
- ../.env
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "35432:5432"
deploy:
resources:
limits:
memory: 150M
command: postgres -c shared_buffers=64MB -c effective_cache_size=128MB

redis:
image: redis:7-alpine
ports:
- "6379:6379"
restart: unless-stopped
deploy:
resources:
limits:
memory: 50M
command: redis-server --maxmemory 32mb --maxmemory-policy allkeys-lru

celery:
build:
context: .
context: ..
dockerfile: docker/Dockerfile.django
command: >
sh -c "/wait-for-it.sh redis:6379 --
celery -A core.project worker --loglevel=info"
sh -c "/wait-for-it.sh redis:6379 -- && celery -A core.project worker --loglevel=info --concurrency=1 --max-tasks-per-child=50"
env_file:
- .env
- ../.env
depends_on:
redis:
condition: service_healthy
postgres:
condition: service_healthy
- redis
- postgres
volumes:
- .:/app
- ..:/app
restart: unless-stopped
deploy:
resources:
limits:
memory: 100M

bot:
build:
context: .
context: ..
dockerfile: docker/Dockerfile.bot
env_file:
- .env
- ../.env
depends_on:
django:
condition: service_started
redis:
condition: service_healthy
- django
- redis
restart: unless-stopped
volumes:
- .:/app
working_dir: /app/bot
command: sh -c "while true; do python -u bot.py; sleep 10; done"
deploy:
resources:
limits:
memory: 200M

volumes:
pgdata: