deploy prepare

This commit is contained in:
2025-08-08 09:43:34 +09:00
parent f09b90f63e
commit 05bc50269d
14 changed files with 124 additions and 31 deletions

3
.dockerignore Normal file
View File

@@ -0,0 +1,3 @@
.git/
bin/
backups/

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# tg_autopost

View File

@@ -1,5 +1,3 @@
version: "3.9"
services: services:
db: db:
build: build:
@@ -8,21 +6,25 @@ services:
container_name: mariadb container_name: mariadb
restart: unless-stopped restart: unless-stopped
environment: environment:
MYSQL_ROOT_PASSWORD: rootpass MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: tg_autopost MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: tguser MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: tgpass MYSQL_PASSWORD: ${DB_PASSWORD}
ports: ports:
- "3306:3306" - "${DB_PORT}:3306"
volumes: volumes:
- ./app/var/lib/mysql:/var/lib/mysql - ./db_storage/mysql:/var/lib/mysql
env_file:
- .env
redis: redis:
image: redis:7.2 image: redis:7.2
container_name: redis container_name: redis
restart: unless-stopped restart: unless-stopped
ports: ports:
- "6379:6379" - "${REDIS_PORT}:6379"
env_file:
- .env
django: django:
build: build:
@@ -31,7 +33,7 @@ services:
container_name: django container_name: django
command: python manage.py runserver 0.0.0.0:8000 command: python manage.py runserver 0.0.0.0:8000
volumes: volumes:
- ./app:/app - .:/app
ports: ports:
- "8000:8000" - "8000:8000"
env_file: env_file:
@@ -47,7 +49,7 @@ services:
container_name: bot container_name: bot
command: python manage.py runbot command: python manage.py runbot
volumes: volumes:
- ./app:/app - .:/app
env_file: env_file:
- .env - .env
depends_on: depends_on:
@@ -61,7 +63,7 @@ services:
container_name: celery_worker container_name: celery_worker
command: celery -A tg_autopost worker -l info command: celery -A tg_autopost worker -l info
volumes: volumes:
- ./app:/app - .:/app
env_file: env_file:
- .env - .env
depends_on: depends_on:
@@ -75,7 +77,7 @@ services:
container_name: celery_beat container_name: celery_beat
command: celery -A tg_autopost beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler command: celery -A tg_autopost beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
volumes: volumes:
- ./app:/app - .:/app
env_file: env_file:
- .env - .env
depends_on: depends_on:

View File

@@ -2,14 +2,7 @@ FROM python:3.12-slim
WORKDIR /app WORKDIR /app
RUN apt-get update && apt-get install -y \ COPY docker/bot/requirements.txt /tmp/requirements.txt
build-essential \ RUN pip install --no-cache-dir -r /tmp/requirements.txt
libmariadb-dev \
libmariadb-dev-compat \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/ COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
COPY app /app

View File

@@ -0,0 +1,3 @@
python-telegram-bot>=21.6
pytz>=2024.1
python-dateutil>=2.9.0

View File

@@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y \
pkg-config \ pkg-config \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/ COPY docker/celery/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r /tmp/requirements.txt
COPY app /app COPY . /app

View File

@@ -0,0 +1,4 @@
celery>=5.4.0
redis>=5.0.4
pytz>=2024.1
python-dateutil>=2.9.0

View File

@@ -0,0 +1,26 @@
[mysqld]
# Кодировка и сравнение по умолчанию
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
# Разрешить большие пакеты (для больших вставок и дампов)
max_allowed_packet = 256M
# Оптимизация кеша
query_cache_type = 1
query_cache_size = 64M
# Логи медленных запросов (для диагностики)
slow_query_log = 1
long_query_time = 2
slow_query_log_file = /var/lib/mysql/mysql-slow.log
# Увеличение соединений
max_connections = 500
# Таймауты
wait_timeout = 28800
interactive_timeout = 28800
# Временная зона сервера
default_time_zone = '+09:00'

View File

@@ -0,0 +1,24 @@
# Django
Django>=5.0,<6.0
django-environ>=0.11.2
django-celery-beat>=2.6.0
django-celery-results>=2.5.1
# Telegram Bot
python-telegram-bot>=21.6
# База данных (MariaDB/MySQL)
mysqlclient>=2.2.4 # Для работы Django с MariaDB
# Celery
celery>=5.4.0
redis>=5.0.4
# Для работы с временными зонами и датами
pytz>=2024.1
python-dateutil>=2.9.0
# Dev utils
black>=24.3.0 # автоформатирование
flake8>=7.0.0 # линтер
ipython>=8.22.0 # интерактивная консоль

View File

@@ -9,9 +9,9 @@ RUN apt-get update && apt-get install -y \
pkg-config \ pkg-config \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/ COPY docker/main/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r /tmp/requirements.txt
COPY app /app COPY . /app
EXPOSE 8000 EXPOSE 8000

View File

@@ -0,0 +1,8 @@
Django>=5.0,<6.0
django-environ>=0.11.2
django-celery-beat>=2.6.0
django-celery-results>=2.5.1
mysqlclient>=2.2.4
pytz>=2024.1
python-dateutil>=2.9.0
pillow>=10.0.0

View File

@@ -10,8 +10,9 @@ RUN apt-get update && apt-get install -y \
pkg-config \ pkg-config \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/ COPY docker/utils/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r /tmp/requirements.txt
COPY . /app/ COPY . /app/

View File

@@ -0,0 +1,3 @@
black>=24.3.0
flake8>=7.0.0
ipython>=8.22.0

24
requirements.txt Normal file
View File

@@ -0,0 +1,24 @@
# Django
Django>=5.0,<6.0
django-environ>=0.11.2
django-celery-beat>=2.6.0
django-celery-results>=2.5.1
# Telegram Bot
python-telegram-bot>=21.6
# База данных (MariaDB/MySQL)
mysqlclient>=2.2.4 # Для работы Django с MariaDB
# Celery
celery>=5.4.0
redis>=5.0.4
# Для работы с временными зонами и датами
pytz>=2024.1
python-dateutil>=2.9.0
# Dev utils
black>=24.3.0 # автоформатирование
flake8>=7.0.0 # линтер
ipython>=8.22.0 # интерактивная консоль