diff --git a/.dockerignore b/.dockerignore index 714b6fe..333c990 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,7 +8,7 @@ __pycache__ *.pyc data/ data_partial/ -bot.db +db/ *.md !README.md .ruff_cache diff --git a/.gitignore b/.gitignore index b5dc801..8cdd500 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ TASK.md .env data/ data_partial/ -bot.db \ No newline at end of file +db/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cf74ed5..aea5e56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,4 @@ COPY src/ ./src/ RUN mkdir -p data data_partial -CMD ["uv", "run", "main.py"] +CMD ["uv", "run", "--no-dev", "main.py"] diff --git a/docker-compose.yml b/docker-compose.yml index dec95be..5493c4f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,4 +9,4 @@ services: volumes: - ./data:/app/data - ./data_partial:/app/data_partial - - ./bot.db:/app/bot.db + - ./db:/app/db diff --git a/src/config.py b/src/config.py index 4b911f9..6c096c1 100644 --- a/src/config.py +++ b/src/config.py @@ -22,4 +22,5 @@ BASE_DIR: Path = Path(__file__).parent.parent DATA_DIR: Path = BASE_DIR / "data" DATA_PARTIAL_DIR: Path = BASE_DIR / "data_partial" SCENARIOS_DIR: Path = BASE_DIR / "scenarios" -DB_PATH: Path = BASE_DIR / "bot.db" +DB_DIR: Path = BASE_DIR / "db" +DB_PATH: Path = DB_DIR / "bot.db" diff --git a/src/database.py b/src/database.py index d9191b8..51750d8 100644 --- a/src/database.py +++ b/src/database.py @@ -91,7 +91,10 @@ def get_connection() -> Generator[sqlite3.Connection, None, None]: def init_db() -> None: """Инициализирует схему базы данных.""" + from src.config import DB_DIR + logger.info("Инициализация базы данных...") + DB_DIR.mkdir(parents=True, exist_ok=True) with get_connection() as conn: conn.executescript("""