diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2d1fc85 --- /dev/null +++ b/.dockerignore @@ -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/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8a580d1 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/logs/custom_logger.py b/logs/custom_logger.py index dd31621..a142214 100644 --- a/logs/custom_logger.py +++ b/logs/custom_logger.py @@ -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}", )