From dc1884bcaabfca4014a33a8a2fe2974d7619b02e Mon Sep 17 00:00:00 2001 From: VaitaR Date: Wed, 12 Nov 2025 15:37:05 +0300 Subject: [PATCH 1/2] build: pin dependencies and slim docker image --- Dockerfile | 24 +++++-------------- Makefile | 4 ++-- requirements-dev.txt | 20 ++++++++++++++++ requirements.txt | 57 ++++++++++++++++---------------------------- 4 files changed, 48 insertions(+), 57 deletions(-) create mode 100644 requirements-dev.txt diff --git a/Dockerfile b/Dockerfile index d65dcbf..90fe83a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,12 @@ FROM python:3.11-slim WORKDIR /app # Install system dependencies -RUN apt-get update && apt-get install -y \ - sqlite3 \ - postgresql-client \ - curl \ - postgresql-client \ +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + curl \ + postgresql-client \ + sqlite3 \ + && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install Python dependencies @@ -25,19 +26,6 @@ RUN chmod +x /docker-entrypoint.sh # Create directories for data and logs RUN mkdir -p /app/data /app/logs -# Create config files from examples if they don't exist -# This ensures the image works even if built from a fresh git clone -RUN for example_file in config/defaults/*.example.yaml; do \ - if [ -f "$example_file" ]; then \ - filename=$(basename "$example_file" .example.yaml); \ - target="config/${filename}.yaml"; \ - if [ ! -f "$target" ]; then \ - cp "$example_file" "$target"; \ - echo "Created $target from example"; \ - fi; \ - fi; \ - done - # Healthcheck: validate settings can be loaded HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD python -c "from src.config.settings import get_settings; get_settings(); print('OK')" || exit 1 diff --git a/Makefile b/Makefile index 847715c..33a796c 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,9 @@ help: ## Show this help message @echo "$(BLUE)Available targets:$(NC)" @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}' -install: ## Install dependencies +install: ## Install development dependencies @echo "$(BLUE)Installing dependencies...$(NC)" - pip install -r requirements.txt + pip install -r requirements-dev.txt format: ## Format code with ruff @echo "$(BLUE)Formatting code with ruff...$(NC)" diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..fa4485e --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,20 @@ +-r requirements.txt + +# Testing +pytest==8.0.0 +pytest-asyncio==0.23.5 +pytest-cov==4.1.0 +pytest-mock==3.12.0 +pytest-timeout==2.2.0 + +# Code Quality +ruff==0.12.8 +mypy==1.8.0 +pre-commit==3.6.2 + +# Type stubs +types-jsonschema==4.20.0.20240316 +types-pytz==2024.1.0.20240203 +types-PyYAML==6.0.12.20240311 +types-python-dateutil==2.8.19.20240106 +types-requests==2.31.0.20240218 diff --git a/requirements.txt b/requirements.txt index 697d624..19c848d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,45 +1,28 @@ -# Core dependencies -pydantic>=2.6.0 -pydantic-settings>=2.2.0 -python-dotenv>=1.0.0 +# Runtime dependencies (pinned) +pydantic==2.6.0 +pydantic-settings==2.2.0 +python-dotenv==1.0.1 # HTTP & APIs -httpx>=0.27.0 -slack-sdk>=3.27.0 -openai>=1.12.0 -telethon>=1.41.0 +httpx==0.27.0 +slack-sdk==3.27.0 +openai==1.12.0 +telethon==1.41.1 # Utilities -pytz>=2024.1 -python-dateutil>=2.8.2 -rapidfuzz>=3.6.0 -pyyaml>=6.0.0 -jsonschema>=4.20.0 -types-jsonschema>=4.20.0 -structlog>=24.1.0 -prometheus-client>=0.20.0 -qrcode[pil]>=7.4.0 - -# Testing -pytest>=8.0.0 -pytest-asyncio>=0.23.0 -pytest-cov>=4.1.0 -pytest-mock>=3.12.0 -pytest-timeout>=2.2.0 - -# Code Quality -ruff==0.12.8 -mypy>=1.8.0 -pre-commit>=3.6.0 -types-pytz>=2024.1.0 -types-PyYAML>=6.0.0 -types-python-dateutil>=2.8.0 -types-requests>=2.31.0 +pytz==2024.1 +python-dateutil==2.8.2 +rapidfuzz==3.6.1 +pyyaml==6.0.1 +jsonschema==4.20.0 +structlog==24.1.0 +prometheus-client==0.20.0 +qrcode[pil]==7.4.2 # Database & Migrations -alembic>=1.13.0 -psycopg2-binary>=2.9.9 +alembic==1.13.1 +psycopg2-binary==2.9.9 # Streamlit & Visualization -streamlit>=1.29.0 -plotly>=5.17.0 +streamlit==1.29.0 +plotly==5.17.0 From 9379b476eb2bbcdbd4d4b7a0f548e89204fde469 Mon Sep 17 00:00:00 2001 From: VaitaR Date: Wed, 12 Nov 2025 15:44:48 +0300 Subject: [PATCH 2/2] ci: install dev dependencies in workflows --- .github/workflows/ci.yml | 4 ++-- .github/workflows/pre-commit.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a244164..dd546a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: - name: Install dependencies (matches Makefile exactly) run: | - uv pip install --python $(which python) -r requirements.txt + uv pip install --python $(which python) -r requirements-dev.txt - name: Mypy (strict) - matches Makefile exactly run: | @@ -86,7 +86,7 @@ jobs: - name: Install dependencies run: | - uv pip install --python $(which python) -r requirements.txt + uv pip install --python $(which python) -r requirements-dev.txt - name: Run tests with coverage (matches Makefile exactly) env: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 8cd3eb2..e7fef03 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -31,7 +31,7 @@ jobs: - name: Install pre-commit and dependencies run: | uv pip install --python $(which python) pre-commit - uv pip install --python $(which python) -r requirements.txt + uv pip install --python $(which python) -r requirements-dev.txt - name: Run pre-commit hooks (fastest feedback) run: |