From f0e6d9439ef6de44849e6707853254bfd0920fcc Mon Sep 17 00:00:00 2001 From: shay Date: Fri, 17 Apr 2026 16:22:46 -0400 Subject: [PATCH] feat(fetcher): scaffold config, requirements, pytest, Dockerfile --- fetcher/Dockerfile | 14 ++++++++++++++ fetcher/pytest.ini | 5 +++++ fetcher/requirements.txt | 5 +++++ fetcher/src/config.py | 10 ++++++++++ 4 files changed, 34 insertions(+) create mode 100644 fetcher/Dockerfile create mode 100644 fetcher/pytest.ini create mode 100644 fetcher/requirements.txt create mode 100644 fetcher/src/config.py diff --git a/fetcher/Dockerfile b/fetcher/Dockerfile new file mode 100644 index 0000000..9a18930 --- /dev/null +++ b/fetcher/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.11-slim + +WORKDIR /app +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY src ./src +RUN mkdir -p /app/data + +EXPOSE 5001 +ENV FETCHER_DB_PATH=/app/data/fetcher.db + +# Default is the API. Override CMD for cron: ["python", "-m", "src.cron"] +CMD ["gunicorn", "-b", "0.0.0.0:5001", "-w", "2", "src.api:app"] diff --git a/fetcher/pytest.ini b/fetcher/pytest.ini new file mode 100644 index 0000000..9d1efdb --- /dev/null +++ b/fetcher/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +testpaths = tests +python_files = test_*.py +pythonpath = . +addopts = -ra --strict-markers diff --git a/fetcher/requirements.txt b/fetcher/requirements.txt new file mode 100644 index 0000000..ee8f159 --- /dev/null +++ b/fetcher/requirements.txt @@ -0,0 +1,5 @@ +flask==3.0.3 +requests==2.32.3 +pytest==8.3.3 +responses==0.25.3 +gunicorn==23.0.0 diff --git a/fetcher/src/config.py b/fetcher/src/config.py new file mode 100644 index 0000000..3cdf66d --- /dev/null +++ b/fetcher/src/config.py @@ -0,0 +1,10 @@ +"""Fetcher service configuration, overridable via env vars.""" +import os + +PORT = int(os.getenv("FETCHER_PORT", "5001")) +DB_PATH = os.getenv("FETCHER_DB_PATH", "./data/fetcher.db") +GITHUB_PAT = os.getenv("GITHUB_PAT", "") +INTERNAL_TOKEN = os.getenv("FETCHER_INTERNAL_TOKEN", "") +REFRESH_INTERVAL_HOURS = int(os.getenv("FETCHER_REFRESH_INTERVAL_HOURS", "24")) +TRIAL_GC_DAYS = int(os.getenv("FETCHER_TRIAL_GC_DAYS", "7")) +API_TIMEOUT = int(os.getenv("API_TIMEOUT", "15"))