-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
460 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM python:3.12-slim | ||
|
||
WORKDIR /app | ||
|
||
# Устанавливаем зависимости для системы (например, для Poetry и компиляции пакетов) | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
curl \ | ||
libffi-dev \ | ||
libssl-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Устанавливаем Poetry | ||
ENV POETRY_VERSION=1.6.1 | ||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
# Добавляем Poetry в PATH | ||
ENV PATH="/root/.local/bin:$PATH" | ||
|
||
# Копируем файлы проекта в контейнер | ||
COPY pyproject.toml poetry.lock ./ | ||
|
||
# Устанавливаем зависимости проекта | ||
RUN poetry install --no-root --only main | ||
|
||
# Копируем оставшиеся файлы проекта в контейнер | ||
COPY . . | ||
|
||
# Определяем команду по умолчанию для контейнера | ||
CMD ["poetry", "run", "python", "main.py"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from tortoise import Tortoise | ||
|
||
|
||
async def init(): | ||
await Tortoise.init( | ||
db_url='sqlite://db.sqlite3', | ||
modules={'models': ['app.database.models']} | ||
) | ||
# Генерируем схемы | ||
await Tortoise.generate_schemas() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from tortoise import models, fields | ||
|
||
|
||
class GoalTimeMessageChat(models.Model): | ||
id = fields.IntField(pk=True) | ||
name = fields.CharField(max_length=255) | ||
chat_id = fields.IntField() | ||
message_id = fields.IntField() | ||
goal_time = fields.DatetimeField() | ||
|
||
created_at = fields.DatetimeField(auto_now_add=True) | ||
|
||
class Meta: | ||
table = "goal_time_message_chat" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
version: '3.8' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: app | ||
volumes: | ||
- .:/app | ||
command: python main.py | ||
depends_on: | ||
- redis | ||
environment: | ||
- CELERY_BROKER_URL=redis://redis:6379/0 | ||
- CELERY_RESULT_BACKEND=redis://redis:6379/0 | ||
|
||
celery: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: celery | ||
volumes: | ||
- .:/app | ||
command: celery -A main worker --loglevel=info | ||
depends_on: | ||
- redis | ||
environment: | ||
- CELERY_BROKER_URL=redis://redis:6379/0 | ||
- CELERY_RESULT_BACKEND=redis://redis:6379/0 | ||
|
||
celery_beat: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: celery_beat | ||
volumes: | ||
- .:/app | ||
command: celery -A main beat --loglevel=info | ||
depends_on: | ||
- redis | ||
environment: | ||
- CELERY_BROKER_URL=redis://redis:6379/0 | ||
- CELERY_RESULT_BACKEND=redis://redis:6379/0 | ||
|
||
redis: | ||
image: redis:6.2 | ||
container_name: redis | ||
ports: | ||
- "6379:6379" | ||
|
||
postgres: | ||
image: postgres:17 | ||
container_name: postgres | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: postgres | ||
ports: | ||
- "5432:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
import asyncio | ||
|
||
from loguru import logger | ||
|
||
async def main(): | ||
from app import database | ||
|
||
|
||
def configure_logging(): | ||
pass | ||
|
||
|
||
async def main(): | ||
configure_logging() | ||
|
||
await database.init() | ||
|
||
logger.info('Starting bot...') | ||
|
||
|
||
if __name__ == '__main__': | ||
asyncio.run(main()) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters