Update log retention period to 30 days in custom logger and add comment on log cleanup mechanism.

This commit is contained in:
2025-08-26 17:23:20 +03:00
parent fee22f8ad4
commit 61dd85035d
3 changed files with 75 additions and 1 deletions

37
.dockerignore Normal file
View File

@@ -0,0 +1,37 @@
__pycache__/
*.py[cod]
*.pyo
*.pyd
*.so
*.egg-info/
.eggs/
.env
.venv
.vscode/
.idea/
.git/
.gitignore
# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.pyc
**/*.pyo
**/*.pyd
# Local settings
settings_example.ini
# Databases and runtime files
*.db
*.db-shm
*.db-wal
logs/
# Tests and artifacts
.coverage
.pytest_cache/
htmlcov/
**/tests/
# Stickers and large assets (if not needed at runtime)
Stick/

37
Dockerfile Normal file
View File

@@ -0,0 +1,37 @@
# syntax=docker/dockerfile:1
# Use a lightweight Python image
FROM python:3.11-slim
# Prevent Python from writing .pyc files and enable unbuffered logs
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install system dependencies (if required by Python packages)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Create non-root user
RUN useradd -m appuser \
&& chown -R appuser:appuser /app
# Install Python dependencies first for better layer caching
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy project files
COPY . .
# Ensure runtime directories exist and are writable
RUN mkdir -p logs database \
&& chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Run the bot
CMD ["python", "run_helper.py"]

View File

@@ -19,6 +19,6 @@ filename = f'{current_dir}/helper_bot_{today}.log'
logger.add(
filename,
rotation="00:00",
retention="5 days",
retention="30 days",
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {name} | {line} | {message}",
)